aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/blogc-make/rules.c18
-rw-r--r--src/blogc-make/utils.c34
-rw-r--r--src/blogc-make/utils.h2
-rwxr-xr-xtests/blogc-make/check_blogc_make.sh.in182
-rw-r--r--tests/blogc-make/check_utils.c349
5 files changed, 571 insertions, 14 deletions
diff --git a/src/blogc-make/rules.c b/src/blogc-make/rules.c
index 591ad21..06223c0 100644
--- a/src/blogc-make/rules.c
+++ b/src/blogc-make/rules.c
@@ -367,24 +367,19 @@ pagination_tags_outputlist(bm_ctx_t *ctx)
bc_trie_free(local);
if (last_page == NULL)
- break;
+ continue;
long pages = strtol(last_page, NULL, 10);
free(last_page);
- char *prefix = bc_strdup_printf("%s/%s/%s", tag_prefix,
- ctx->settings->tags[k], pagination_prefix);
-
for (size_t i = 0; i < pages; i++) {
char *j = bc_strdup_printf("%d", i + 1);
- char *f = bm_generate_filename(ctx->short_output_dir, prefix,
- j, html_ext);
+ char *f = bm_generate_filename2(ctx->short_output_dir, tag_prefix,
+ ctx->settings->tags[k], pagination_prefix, j, html_ext);
rv = bc_slist_append(rv, bm_filectx_new(ctx, f, NULL, NULL));
free(j);
free(f);
}
-
- free(prefix);
}
bc_trie_free(variables);
@@ -425,16 +420,14 @@ pagination_tags_exec(bm_ctx_t *ctx, bc_slist_t *outputs, bc_trie_t *args)
// tag and page from the file path right now :/
char *tag = NULL;
for (size_t i = 0; ctx->settings->tags[i] != NULL; i++) {
- char *prefix = bc_strdup_printf("%s/%s/%s", tag_prefix,
- ctx->settings->tags[i], pagination_prefix);
bool b = false;
// it is impossible to have more output files per tag than the whole
// amount of output pages
for (size_t k = 1; k <= bc_slist_length(outputs); k++) {
char *j = bc_strdup_printf("%d", k);
- char *f = bm_generate_filename(ctx->short_output_dir, prefix,
- j, html_ext);
+ char *f = bm_generate_filename2(ctx->short_output_dir, tag_prefix,
+ ctx->settings->tags[i], pagination_prefix, j, html_ext);
free(j);
if (0 == strcmp(fctx->short_path, f)) {
tag = ctx->settings->tags[i];
@@ -445,7 +438,6 @@ pagination_tags_exec(bm_ctx_t *ctx, bc_slist_t *outputs, bc_trie_t *args)
}
free(f);
}
- free(prefix);
if (b)
break;
}
diff --git a/src/blogc-make/utils.c b/src/blogc-make/utils.c
index 91b7b53..8f69e44 100644
--- a/src/blogc-make/utils.c
+++ b/src/blogc-make/utils.c
@@ -28,7 +28,7 @@ bm_generate_filename(const char *dir, const char *prefix, const char *fname,
bool have_ext = ext != NULL && ext[0] != '\0';
bool have_ext_noslash = have_ext && ext[0] != '/';
bool is_index = have_fname && have_ext && (
- (0 == strcmp(fname, "index")) && ext[0] == '/');
+ (0 == strcmp(fname, "index")) && ext[0] == '/') && !have_prefix;
bc_string_t *rv = bc_string_new();
@@ -70,6 +70,38 @@ bm_generate_filename(const char *dir, const char *prefix, const char *fname,
char*
+bm_generate_filename2(const char *dir, const char *prefix, const char *fname,
+ const char *prefix2, const char *fname2, const char *ext)
+{
+ bool have_prefix = prefix != NULL && prefix[0] != '\0';
+ bool have_fname = fname != NULL && fname[0] != '\0';
+ bool have_prefix2 = prefix2 != NULL && prefix2[0] != '\0';
+
+ bc_string_t *p = bc_string_new();
+
+ if (have_prefix)
+ bc_string_append(p, prefix);
+
+ if (have_prefix && (have_fname || have_prefix2))
+ bc_string_append_c(p, '/');
+
+ if (have_fname)
+ bc_string_append(p, fname);
+
+ if (have_fname && have_prefix2)
+ bc_string_append_c(p, '/');
+
+ if (have_prefix2)
+ bc_string_append(p, prefix2);
+
+ char *rv = bm_generate_filename(dir, p->str, fname2, ext);
+ bc_string_free(p, true);
+
+ return rv;
+}
+
+
+char*
bm_abspath(const char *path, bc_error_t **err)
{
if (err == NULL || *err != NULL)
diff --git a/src/blogc-make/utils.h b/src/blogc-make/utils.h
index 5353c01..cbcfc0e 100644
--- a/src/blogc-make/utils.h
+++ b/src/blogc-make/utils.h
@@ -13,6 +13,8 @@
char* bm_generate_filename(const char *dir, const char *prefix, const char *fname,
const char *ext);
+char* bm_generate_filename2(const char *dir, const char *prefix, const char *fname,
+ const char *prefix2, const char *fname2, const char *ext);
char* bm_abspath(const char *path, bc_error_t **err);
#endif /* _MAKE_UTILS_H */
diff --git a/tests/blogc-make/check_blogc_make.sh.in b/tests/blogc-make/check_blogc_make.sh.in
index 36dfceb..423b83e 100755
--- a/tests/blogc-make/check_blogc_make.sh.in
+++ b/tests/blogc-make/check_blogc_make.sh.in
@@ -38,6 +38,7 @@ ${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc-make -f "${TEMP}/proj/blogcfile" 2
cat > "${TEMP}/proj/content/post/foo.txt" <<EOF
TITLE: Foo
DATE: 2016-10-01
+TAGS: qwe
----------------
This is foo.
EOF
@@ -45,6 +46,7 @@ EOF
cat > "${TEMP}/proj/content/post/bar.txt" <<EOF
TITLE: Bar
DATE: 2016-09-01
+TAGS: qwe
----------------
This is bar.
EOF
@@ -53,6 +55,7 @@ for i in $(seq -f "%02g" 1 11); do
cat > "${TEMP}/proj/content/post/post${i}.txt" <<EOF
TITLE: Post ${i}
DATE: 2016-09-${i}
+TAGS: asd
----------------
This is Post ${i}.
EOF
@@ -79,6 +82,7 @@ ${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc-make -f "${TEMP}/proj/blogcfile" 2
grep "_build/index\\.html" "${TEMP}/output.txt"
grep "_build/atom\\.xml" "${TEMP}/output.txt"
grep "_build/page/1/index\\.html" "${TEMP}/output.txt"
+grep -v "_build/page/2/index\\.html" "${TEMP}/output.txt"
grep "_build/post/foo/index\\.html" "${TEMP}/output.txt"
grep "_build/post/bar/index\\.html" "${TEMP}/output.txt"
@@ -755,6 +759,125 @@ diff -uN "${TEMP}/proj/_build/post/post11/index.html" "${TEMP}/expected-post-pos
rm -rf "${TEMP}/proj/_build"
+### default settings with some posts and tags pagination
+
+cat > "${TEMP}/proj/blogcfile" <<EOF
+[global]
+AUTHOR_NAME = Lol
+AUTHOR_EMAIL = author@example.com
+SITE_TITLE = Lol's Website
+SITE_TAGLINE = WAT?!
+BASE_DOMAIN = http://example.org
+
+[settings]
+atom_posts_per_page = 0
+posts_per_page = 3
+
+[posts]
+foo
+bar
+post01
+post02
+post03
+post04
+post05
+post06
+post07
+post08
+post09
+post10
+post11
+
+[tags]
+qwe
+asd
+EOF
+
+${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc-make -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt"
+grep "_build/post/post01/index\\.html" "${TEMP}/output.txt"
+grep "_build/post/post02/index\\.html" "${TEMP}/output.txt"
+grep "_build/post/post03/index\\.html" "${TEMP}/output.txt"
+grep "_build/post/post04/index\\.html" "${TEMP}/output.txt"
+grep "_build/post/post05/index\\.html" "${TEMP}/output.txt"
+grep "_build/post/post06/index\\.html" "${TEMP}/output.txt"
+grep "_build/post/post07/index\\.html" "${TEMP}/output.txt"
+grep "_build/post/post08/index\\.html" "${TEMP}/output.txt"
+grep "_build/post/post09/index\\.html" "${TEMP}/output.txt"
+grep "_build/post/post10/index\\.html" "${TEMP}/output.txt"
+grep "_build/post/post11/index\\.html" "${TEMP}/output.txt"
+grep "_build/tag/asd/index\\.html" "${TEMP}/output.txt"
+grep "_build/tag/asd/page/1/index\\.html" "${TEMP}/output.txt"
+grep "_build/tag/asd/page/2/index\\.html" "${TEMP}/output.txt"
+grep "_build/tag/asd/page/3/index\\.html" "${TEMP}/output.txt"
+grep "_build/tag/asd/page/4/index\\.html" "${TEMP}/output.txt"
+grep -v "_build/tag/asd/page/5/index\\.html" "${TEMP}/output.txt"
+grep "_build/tag/qwe/index\\.html" "${TEMP}/output.txt"
+grep "_build/tag/qwe/page/1/index\\.html" "${TEMP}/output.txt"
+grep -v "_build/tag/qwe/page/2/index\\.html" "${TEMP}/output.txt"
+
+rm "${TEMP}/output.txt"
+
+cat > "${TEMP}/expected-tag-asd1.html" <<EOF
+
+Listing: asd - Post 11 - Sep 11, 2016, 12:00 AM GMT
+
+Listing: asd - Post 10 - Sep 10, 2016, 12:00 AM GMT
+
+Listing: asd - Post 09 - Sep 09, 2016, 12:00 AM GMT
+
+
+EOF
+diff -uN "${TEMP}/proj/_build/tag/asd/index.html" "${TEMP}/expected-tag-asd1.html"
+diff -uN "${TEMP}/proj/_build/tag/asd/page/1/index.html" "${TEMP}/expected-tag-asd1.html"
+
+cat > "${TEMP}/expected-tag-asd2.html" <<EOF
+
+Listing: asd - Post 08 - Sep 08, 2016, 12:00 AM GMT
+
+Listing: asd - Post 07 - Sep 07, 2016, 12:00 AM GMT
+
+Listing: asd - Post 06 - Sep 06, 2016, 12:00 AM GMT
+
+
+EOF
+diff -uN "${TEMP}/proj/_build/tag/asd/page/2/index.html" "${TEMP}/expected-tag-asd2.html"
+
+cat > "${TEMP}/expected-tag-asd3.html" <<EOF
+
+Listing: asd - Post 05 - Sep 05, 2016, 12:00 AM GMT
+
+Listing: asd - Post 04 - Sep 04, 2016, 12:00 AM GMT
+
+Listing: asd - Post 03 - Sep 03, 2016, 12:00 AM GMT
+
+
+EOF
+diff -uN "${TEMP}/proj/_build/tag/asd/page/3/index.html" "${TEMP}/expected-tag-asd3.html"
+
+cat > "${TEMP}/expected-tag-asd4.html" <<EOF
+
+Listing: asd - Post 02 - Sep 02, 2016, 12:00 AM GMT
+
+Listing: asd - Post 01 - Sep 01, 2016, 12:00 AM GMT
+
+
+EOF
+diff -uN "${TEMP}/proj/_build/tag/asd/page/4/index.html" "${TEMP}/expected-tag-asd4.html"
+
+cat > "${TEMP}/expected-tag-qwe1.html" <<EOF
+
+Listing: qwe - Bar - Sep 01, 2016, 12:00 AM GMT
+
+Listing: qwe - Foo - Oct 01, 2016, 12:00 AM GMT
+
+
+EOF
+diff -uN "${TEMP}/proj/_build/tag/qwe/index.html" "${TEMP}/expected-tag-qwe1.html"
+diff -uN "${TEMP}/proj/_build/tag/qwe/page/1/index.html" "${TEMP}/expected-tag-qwe1.html"
+
+rm -rf "${TEMP}/proj/_build"
+
+
### default settings with some posts, order asc, posts_sort
cat > "${TEMP}/proj/blogcfile" <<EOF
@@ -779,6 +902,7 @@ ${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc-make -f "${TEMP}/proj/blogcfile" 2
grep "_build/index\\.html" "${TEMP}/output.txt"
grep "_build/atom\\.xml" "${TEMP}/output.txt"
grep "_build/page/1/index\\.html" "${TEMP}/output.txt"
+grep -v "_build/page/2/index\\.html" "${TEMP}/output.txt"
grep "_build/post/foo/index\\.html" "${TEMP}/output.txt"
grep "_build/post/bar/index\\.html" "${TEMP}/output.txt"
@@ -888,6 +1012,7 @@ ${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc-make -f "${TEMP}/proj/blogcfile" 2
grep "_build/index\\.html" "${TEMP}/output.txt"
grep "_build/atom\\.xml" "${TEMP}/output.txt"
grep "_build/page/1/index\\.html" "${TEMP}/output.txt"
+grep -v "_build/page/2/index\\.html" "${TEMP}/output.txt"
grep "_build/post/foo/index\\.html" "${TEMP}/output.txt"
grep "_build/post/bar/index\\.html" "${TEMP}/output.txt"
@@ -1005,6 +1130,7 @@ ${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc-make -f "${TEMP}/proj/blogcfile" 2
grep "_build/index\\.html" "${TEMP}/output.txt"
grep "_build/atom\\.xml" "${TEMP}/output.txt"
grep "_build/page/1/index\\.html" "${TEMP}/output.txt"
+grep -v "_build/page/2/index\\.html" "${TEMP}/output.txt"
grep "_build/post/foo/index\\.html" "${TEMP}/output.txt"
grep "_build/post/bar/index\\.html" "${TEMP}/output.txt"
@@ -1116,11 +1242,16 @@ grep "_build/atom\\.xml" "${TEMP}/output.txt"
grep "_build/atom/tag1\\.xml" "${TEMP}/output.txt"
grep "_build/atom/tag2\\.xml" "${TEMP}/output.txt"
grep "_build/page/1/index\\.html" "${TEMP}/output.txt"
+grep -v "_build/page/2/index\\.html" "${TEMP}/output.txt"
grep "_build/post/foo/index\\.html" "${TEMP}/output.txt"
grep "_build/post/bar/index\\.html" "${TEMP}/output.txt"
grep "_build/post/baz/index\\.html" "${TEMP}/output.txt"
grep "_build/tag/tag1/index\\.html" "${TEMP}/output.txt"
+grep "_build/tag/tag1/page/1/index\\.html" "${TEMP}/output.txt"
+grep -v "_build/tag/tag1/page/2/index\\.html" "${TEMP}/output.txt"
grep "_build/tag/tag2/index\\.html" "${TEMP}/output.txt"
+grep "_build/tag/tag2/page/1/index\\.html" "${TEMP}/output.txt"
+grep -v "_build/tag/tag2/page/2/index\\.html" "${TEMP}/output.txt"
rm "${TEMP}/output.txt"
@@ -1283,6 +1414,7 @@ Listing: tag1 - Baz - Aug 01, 2016, 12:00 AM GMT
EOF
diff -uN "${TEMP}/proj/_build/tag/tag1/index.html" "${TEMP}/expected-tag1.html"
+diff -uN "${TEMP}/proj/_build/tag/tag1/page/1/index.html" "${TEMP}/expected-tag1.html"
cat > "${TEMP}/expected-tag2.html" <<EOF
<p>This is hue.</p>
@@ -1292,6 +1424,7 @@ Listing: tag2 - Baz - Aug 01, 2016, 12:00 AM GMT
EOF
diff -uN "${TEMP}/proj/_build/tag/tag2/index.html" "${TEMP}/expected-tag2.html"
+diff -uN "${TEMP}/proj/_build/tag/tag2/page/1/index.html" "${TEMP}/expected-tag2.html"
rm -rf "${TEMP}/proj/_build"
@@ -1322,11 +1455,16 @@ grep "_build/atom\\.xml" "${TEMP}/output.txt"
grep "_build/atom/tag1\\.xml" "${TEMP}/output.txt"
grep "_build/atom/tag2\\.xml" "${TEMP}/output.txt"
grep "_build/page/1/index\\.html" "${TEMP}/output.txt"
+grep -v "_build/page/2/index\\.html" "${TEMP}/output.txt"
grep "_build/post/foo/index\\.html" "${TEMP}/output.txt"
grep "_build/post/bar/index\\.html" "${TEMP}/output.txt"
grep "_build/post/baz/index\\.html" "${TEMP}/output.txt"
grep "_build/tag/tag1/index\\.html" "${TEMP}/output.txt"
+grep "_build/tag/tag1/page/1/index\\.html" "${TEMP}/output.txt"
+grep -v "_build/tag/tag1/page/2/index\\.html" "${TEMP}/output.txt"
grep "_build/tag/tag2/index\\.html" "${TEMP}/output.txt"
+grep "_build/tag/tag2/page/1/index\\.html" "${TEMP}/output.txt"
+grep -v "_build/tag/tag2/page/2/index\\.html" "${TEMP}/output.txt"
grep "_build/page1/index\\.html" "${TEMP}/output.txt"
grep "_build/page2/index\\.html" "${TEMP}/output.txt"
@@ -1345,7 +1483,9 @@ diff -uN "${TEMP}/proj/_build/post/bar/index.html" "${TEMP}/expected-post-bar.ht
diff -uN "${TEMP}/proj/_build/post/baz/index.html" "${TEMP}/expected-post-baz.html"
diff -uN "${TEMP}/proj/_build/tag/tag1/index.html" "${TEMP}/expected-tag1.html"
+diff -uN "${TEMP}/proj/_build/tag/tag1/page/1/index.html" "${TEMP}/expected-tag1.html"
diff -uN "${TEMP}/proj/_build/tag/tag2/index.html" "${TEMP}/expected-tag2.html"
+diff -uN "${TEMP}/proj/_build/tag/tag2/page/1/index.html" "${TEMP}/expected-tag2.html"
cat > "${TEMP}/expected-page1.html" <<EOF
@@ -1437,6 +1577,7 @@ grep "_build/posts\\.html" "${TEMP}/output.txt"
grep "_build/atoom/index\\.xml" "${TEMP}/output.txt"
grep "_build/pagination/1\\.html" "${TEMP}/output.txt"
grep "_build/pagination/2\\.html" "${TEMP}/output.txt"
+grep -v "_build/pagination/3\\.html" "${TEMP}/output.txt"
grep "_build/poost/foo\\.html" "${TEMP}/output.txt"
grep "_build/poost/bar\\.html" "${TEMP}/output.txt"
@@ -1541,11 +1682,16 @@ grep "_build/atoom/tag2/index\\.xml" "${TEMP}/output.txt"
grep "_build/pagination/1\\.html" "${TEMP}/output.txt"
grep "_build/pagination/2\\.html" "${TEMP}/output.txt"
grep "_build/pagination/3\\.html" "${TEMP}/output.txt"
+grep -v "_build/pagination/4\\.html" "${TEMP}/output.txt"
grep "_build/poost/foo\\.html" "${TEMP}/output.txt"
grep "_build/poost/bar\\.html" "${TEMP}/output.txt"
grep "_build/poost/baz\\.html" "${TEMP}/output.txt"
grep "_build/taag/tag1\\.html" "${TEMP}/output.txt"
+grep "_build/taag/tag1/pagination/1\\.html" "${TEMP}/output.txt"
+grep -v "_build/taag/tag1/pagination/2\\.html" "${TEMP}/output.txt"
grep "_build/taag/tag2\\.html" "${TEMP}/output.txt"
+grep "_build/taag/tag2/pagination/1\\.html" "${TEMP}/output.txt"
+grep -v "_build/taag/tag2/pagination/2\\.html" "${TEMP}/output.txt"
rm "${TEMP}/output.txt"
@@ -1647,6 +1793,7 @@ Listing: tag1 - Baz - Aug 01, 2016
EOF
diff -uN "${TEMP}/proj/_build/taag/tag1.html" "${TEMP}/expected-tag1.html"
+diff -uN "${TEMP}/proj/_build/taag/tag1/pagination/1.html" "${TEMP}/expected-tag1.html"
cat > "${TEMP}/expected-tag2.html" <<EOF
@@ -1655,6 +1802,7 @@ Listing: tag2 - Baz - Aug 01, 2016
EOF
diff -uN "${TEMP}/proj/_build/taag/tag2.html" "${TEMP}/expected-tag2.html"
+diff -uN "${TEMP}/proj/_build/taag/tag2/pagination/1.html" "${TEMP}/expected-tag2.html"
rm -rf "${TEMP}/proj/_build"
@@ -1687,11 +1835,16 @@ grep "_build/atoom/tag2/index\\.xml" "${TEMP}/output.txt"
grep "_build/pagination/1\\.html" "${TEMP}/output.txt"
grep "_build/pagination/2\\.html" "${TEMP}/output.txt"
grep "_build/pagination/3\\.html" "${TEMP}/output.txt"
+grep -v "_build/pagination/4\\.html" "${TEMP}/output.txt"
grep "_build/poost/foo\\.html" "${TEMP}/output.txt"
grep "_build/poost/bar\\.html" "${TEMP}/output.txt"
grep "_build/poost/baz\\.html" "${TEMP}/output.txt"
grep "_build/taag/tag1\\.html" "${TEMP}/output.txt"
+grep "_build/taag/tag1/pagination/1\\.html" "${TEMP}/output.txt"
+grep -v "_build/taag/tag1/pagination/2\\.html" "${TEMP}/output.txt"
grep "_build/taag/tag2\\.html" "${TEMP}/output.txt"
+grep "_build/taag/tag2/pagination/1\\.html" "${TEMP}/output.txt"
+grep -v "_build/taag/tag2/pagination/2\\.html" "${TEMP}/output.txt"
grep "_build/page1\\.html" "${TEMP}/output.txt"
grep "_build/page2\\.html" "${TEMP}/output.txt"
@@ -1711,7 +1864,9 @@ diff -uN "${TEMP}/proj/_build/poost/bar.html" "${TEMP}/expected-post-bar.html"
diff -uN "${TEMP}/proj/_build/poost/baz.html" "${TEMP}/expected-post-baz.html"
diff -uN "${TEMP}/proj/_build/taag/tag1.html" "${TEMP}/expected-tag1.html"
+diff -uN "${TEMP}/proj/_build/taag/tag1/pagination/1.html" "${TEMP}/expected-tag1.html"
diff -uN "${TEMP}/proj/_build/taag/tag2.html" "${TEMP}/expected-tag2.html"
+diff -uN "${TEMP}/proj/_build/taag/tag2/pagination/1.html" "${TEMP}/expected-tag2.html"
cat > "${TEMP}/expected-page1.html" <<EOF
@@ -1764,11 +1919,16 @@ grep "_build/atoom/tag2/index\\.xml" "${TEMP}/output.txt"
grep "_build/pagination/1\\.html" "${TEMP}/output.txt"
grep "_build/pagination/2\\.html" "${TEMP}/output.txt"
grep "_build/pagination/3\\.html" "${TEMP}/output.txt"
+grep -v "_build/pagination/4\\.html" "${TEMP}/output.txt"
grep "_build/poost/foo\\.html" "${TEMP}/output.txt"
grep "_build/poost/bar\\.html" "${TEMP}/output.txt"
grep "_build/poost/baz\\.html" "${TEMP}/output.txt"
grep "_build/taag/tag1\\.html" "${TEMP}/output.txt"
+grep "_build/taag/tag1/pagination/1\\.html" "${TEMP}/output.txt"
+grep -v "_build/taag/tag1/pagination/2\\.html" "${TEMP}/output.txt"
grep "_build/taag/tag2\\.html" "${TEMP}/output.txt"
+grep "_build/taag/tag2/pagination/1\\.html" "${TEMP}/output.txt"
+grep -v "_build/taag/tag2/pagination/2\\.html" "${TEMP}/output.txt"
grep "_build/page1\\.html" "${TEMP}/output.txt"
grep "_build/page2\\.html" "${TEMP}/output.txt"
grep "_build/a/b/c/foo" "${TEMP}/output.txt"
@@ -1798,11 +1958,16 @@ grep "_build/atoom/tag2/index\\.xml" "${TEMP}/output.txt"
grep "_build/pagination/1\\.html" "${TEMP}/output.txt"
grep "_build/pagination/2\\.html" "${TEMP}/output.txt"
grep "_build/pagination/3\\.html" "${TEMP}/output.txt"
+grep -v "_build/pagination/4\\.html" "${TEMP}/output.txt"
grep "_build/poost/foo\\.html" "${TEMP}/output.txt"
grep "_build/poost/bar\\.html" "${TEMP}/output.txt"
grep "_build/poost/baz\\.html" "${TEMP}/output.txt"
grep "_build/taag/tag1\\.html" "${TEMP}/output.txt"
+grep "_build/taag/tag1/pagination/1\\.html" "${TEMP}/output.txt"
+grep -v "_build/taag/tag1/pagination/2\\.html" "${TEMP}/output.txt"
grep "_build/taag/tag2\\.html" "${TEMP}/output.txt"
+grep "_build/taag/tag2/pagination/1\\.html" "${TEMP}/output.txt"
+grep -v "_build/taag/tag2/pagination/2\\.html" "${TEMP}/output.txt"
grep "_build/page1\\.html" "${TEMP}/output.txt"
grep "_build/page2\\.html" "${TEMP}/output.txt"
grep "_build/a/b/c/foo" "${TEMP}/output.txt"
@@ -1826,11 +1991,16 @@ grep "___blogc_build/atoom/tag2/index\\.xml" "${TEMP}/output.txt"
grep "___blogc_build/pagination/1\\.html" "${TEMP}/output.txt"
grep "___blogc_build/pagination/2\\.html" "${TEMP}/output.txt"
grep "___blogc_build/pagination/3\\.html" "${TEMP}/output.txt"
+grep -v "___blogc_build/pagination/4\\.html" "${TEMP}/output.txt"
grep "___blogc_build/poost/foo\\.html" "${TEMP}/output.txt"
grep "___blogc_build/poost/bar\\.html" "${TEMP}/output.txt"
grep "___blogc_build/poost/baz\\.html" "${TEMP}/output.txt"
grep "___blogc_build/taag/tag1\\.html" "${TEMP}/output.txt"
+grep "___blogc_build/taag/tag1/pagination/1\\.html" "${TEMP}/output.txt"
+grep -v "___blogc_build/taag/tag1/pagination/2\\.html" "${TEMP}/output.txt"
grep "___blogc_build/taag/tag2\\.html" "${TEMP}/output.txt"
+grep "___blogc_build/taag/tag2/pagination/1\\.html" "${TEMP}/output.txt"
+grep -v "___blogc_build/taag/tag2/pagination/2\\.html" "${TEMP}/output.txt"
grep "___blogc_build/page1\\.html" "${TEMP}/output.txt"
grep "___blogc_build/page2\\.html" "${TEMP}/output.txt"
grep "___blogc_build/a/b/c/foo" "${TEMP}/output.txt"
@@ -1850,11 +2020,16 @@ grep "___blogc_build/atoom/tag2/index\\.xml" "${TEMP}/output.txt"
grep "___blogc_build/pagination/1\\.html" "${TEMP}/output.txt"
grep "___blogc_build/pagination/2\\.html" "${TEMP}/output.txt"
grep "___blogc_build/pagination/3\\.html" "${TEMP}/output.txt"
+grep -v "___blogc_build/pagination/4\\.html" "${TEMP}/output.txt"
grep "___blogc_build/poost/foo\\.html" "${TEMP}/output.txt"
grep "___blogc_build/poost/bar\\.html" "${TEMP}/output.txt"
grep "___blogc_build/poost/baz\\.html" "${TEMP}/output.txt"
grep "___blogc_build/taag/tag1\\.html" "${TEMP}/output.txt"
+grep "___blogc_build/taag/tag1/pagination/1\\.html" "${TEMP}/output.txt"
+grep -v "___blogc_build/taag/tag1/pagination/2\\.html" "${TEMP}/output.txt"
grep "___blogc_build/taag/tag2\\.html" "${TEMP}/output.txt"
+grep "___blogc_build/taag/tag2/pagination/1\\.html" "${TEMP}/output.txt"
+grep -v "___blogc_build/taag/tag2/pagination/2\\.html" "${TEMP}/output.txt"
grep "___blogc_build/page1\\.html" "${TEMP}/output.txt"
grep "___blogc_build/page2\\.html" "${TEMP}/output.txt"
grep "___blogc_build/a/b/c/foo" "${TEMP}/output.txt"
@@ -1978,6 +2153,7 @@ grep "_build/index\\.html" "${TEMP}/output.txt"
grep "_build/index\\.xml" "${TEMP}/output.txt"
grep "_build/1/index\\.html" "${TEMP}/output.txt"
grep "_build/2/index\\.html" "${TEMP}/output.txt"
+grep -v "_build/3/index\\.html" "${TEMP}/output.txt"
grep "_build/foo/index\\.html" "${TEMP}/output.txt"
grep "_build/bar/index\\.html" "${TEMP}/output.txt"
@@ -2112,11 +2288,16 @@ grep "_build/tag2/index\\.xml" "${TEMP}/output.txt"
grep "_build/1\\.html" "${TEMP}/output.txt"
grep "_build/2\\.html" "${TEMP}/output.txt"
grep "_build/3\\.html" "${TEMP}/output.txt"
+grep -v "_build/4\\.html" "${TEMP}/output.txt"
grep "_build/foo\\.html" "${TEMP}/output.txt"
grep "_build/bar\\.html" "${TEMP}/output.txt"
grep "_build/baz\\.html" "${TEMP}/output.txt"
grep "_build/tag1\\.html" "${TEMP}/output.txt"
+grep "_build/tag1/1\\.html" "${TEMP}/output.txt"
+grep -v "_build/tag1/2\\.html" "${TEMP}/output.txt"
grep "_build/tag2\\.html" "${TEMP}/output.txt"
+grep "_build/tag2/1\\.html" "${TEMP}/output.txt"
+grep -v "_build/tag2/2\\.html" "${TEMP}/output.txt"
rm "${TEMP}/output.txt"
@@ -2288,6 +2469,7 @@ grep "_build/tag2/index\\.xml" "${TEMP}/output.txt"
grep "_build/1\\.html" "${TEMP}/output.txt"
grep "_build/2\\.html" "${TEMP}/output.txt"
grep "_build/3\\.html" "${TEMP}/output.txt"
+grep -v "_build/4\\.html" "${TEMP}/output.txt"
grep "_build/foo\\.html" "${TEMP}/output.txt"
grep "_build/bar\\.html" "${TEMP}/output.txt"
grep "_build/baz\\.html" "${TEMP}/output.txt"
diff --git a/tests/blogc-make/check_utils.c b/tests/blogc-make/check_utils.c
index 410cf3a..5b3614d 100644
--- a/tests/blogc-make/check_utils.c
+++ b/tests/blogc-make/check_utils.c
@@ -55,10 +55,18 @@ test_generate_filename(void **state)
assert_string_equal(rv, "/index.html");
free(rv);
+ rv = bm_generate_filename(NULL, "lol", "index", ".html");
+ assert_string_equal(rv, "/lol/index.html");
+ free(rv);
+
rv = bm_generate_filename(NULL, NULL, "index", "/index.html");
assert_string_equal(rv, "/index.html");
free(rv);
+ rv = bm_generate_filename(NULL, "lol", "index", "/index.html");
+ assert_string_equal(rv, "/lol/index/index.html");
+ free(rv);
+
rv = bm_generate_filename(NULL, "bar", "foo", ".html");
assert_string_equal(rv, "/bar/foo.html");
free(rv);
@@ -95,10 +103,18 @@ test_generate_filename(void **state)
assert_string_equal(rv, "_build/index.html");
free(rv);
+ rv = bm_generate_filename("_build", "lol", "index", ".html");
+ assert_string_equal(rv, "_build/lol/index.html");
+ free(rv);
+
rv = bm_generate_filename("_build", NULL, "index", "/index.html");
assert_string_equal(rv, "_build/index.html");
free(rv);
+ rv = bm_generate_filename("_build", "lol", "index", "/index.html");
+ assert_string_equal(rv, "_build/lol/index/index.html");
+ free(rv);
+
rv = bm_generate_filename("_build", "bar", "foo", ".html");
assert_string_equal(rv, "_build/bar/foo.html");
free(rv);
@@ -109,11 +125,344 @@ test_generate_filename(void **state)
}
+static void
+test_generate_filename2(void **state)
+{
+ char *rv;
+
+ assert_null(bm_generate_filename2(NULL, NULL, NULL, NULL, NULL, NULL));
+ assert_null(bm_generate_filename2(NULL, "", "", "", "", ""));
+ assert_null(bm_generate_filename2("_build", NULL, NULL, NULL, NULL, NULL));
+ assert_null(bm_generate_filename2("_build", "", "", "", "", ""));
+
+ rv = bm_generate_filename2(NULL, NULL, NULL, NULL, NULL, ".html");
+ assert_string_equal(rv, "/index.html");
+ free(rv);
+
+ rv = bm_generate_filename2(NULL, "p", NULL, NULL, NULL, ".html");
+ assert_string_equal(rv, "/p.html");
+ free(rv);
+
+ rv = bm_generate_filename2(NULL, NULL, "q", NULL, NULL, ".html");
+ assert_string_equal(rv, "/q.html");
+ free(rv);
+
+ rv = bm_generate_filename2(NULL, "p", "q", NULL, NULL, ".html");
+ assert_string_equal(rv, "/p/q.html");
+ free(rv);
+
+ rv = bm_generate_filename2(NULL, NULL, NULL, NULL, NULL, "/index.html");
+ assert_string_equal(rv, "/index.html");
+ free(rv);
+
+ rv = bm_generate_filename2(NULL, "p", NULL, NULL, NULL, "/index.html");
+ assert_string_equal(rv, "/p/index.html");
+ free(rv);
+
+ rv = bm_generate_filename2(NULL, NULL, "q", NULL, NULL, "/index.html");
+ assert_string_equal(rv, "/q/index.html");
+ free(rv);
+
+ rv = bm_generate_filename2(NULL, "p", "q", NULL, NULL, "/index.html");
+ assert_string_equal(rv, "/p/q/index.html");
+ free(rv);
+
+ rv = bm_generate_filename2(NULL, NULL, NULL, "lol", NULL, ".html");
+ assert_string_equal(rv, "/lol.html");
+ free(rv);
+
+ rv = bm_generate_filename2(NULL, "p", NULL, "lol", NULL, ".html");
+ assert_string_equal(rv, "/p/lol.html");
+ free(rv);
+
+ rv = bm_generate_filename2(NULL, NULL, "q", "lol", NULL, ".html");
+ assert_string_equal(rv, "/q/lol.html");
+ free(rv);
+
+ rv = bm_generate_filename2(NULL, "p", "q", "lol", NULL, ".html");
+ assert_string_equal(rv, "/p/q/lol.html");
+ free(rv);
+
+ rv = bm_generate_filename2(NULL, NULL, NULL, "lol", NULL, "/index.html");
+ assert_string_equal(rv, "/lol/index.html");
+ free(rv);
+
+ rv = bm_generate_filename2(NULL, "p", NULL, "lol", NULL, "/index.html");
+ assert_string_equal(rv, "/p/lol/index.html");
+ free(rv);
+
+ rv = bm_generate_filename2(NULL, NULL, "q", "lol", NULL, "/index.html");
+ assert_string_equal(rv, "/q/lol/index.html");
+ free(rv);
+
+ rv = bm_generate_filename2(NULL, "p", "q", "lol", NULL, "/index.html");
+ assert_string_equal(rv, "/p/q/lol/index.html");
+ free(rv);
+
+ rv = bm_generate_filename2(NULL, NULL, NULL, NULL, "foo", ".html");
+ assert_string_equal(rv, "/foo.html");
+ free(rv);
+
+ rv = bm_generate_filename2(NULL, "p", NULL, NULL, "foo", ".html");
+ assert_string_equal(rv, "/p/foo.html");
+ free(rv);
+
+ rv = bm_generate_filename2(NULL, NULL, "q", NULL, "foo", ".html");
+ assert_string_equal(rv, "/q/foo.html");
+ free(rv);
+
+ rv = bm_generate_filename2(NULL, "p", "q", NULL, "foo", ".html");
+ assert_string_equal(rv, "/p/q/foo.html");
+ free(rv);
+
+ rv = bm_generate_filename2(NULL, NULL, NULL, NULL, "foo", "/index.html");
+ assert_string_equal(rv, "/foo/index.html");
+ free(rv);
+
+ rv = bm_generate_filename2(NULL, "p", NULL, NULL, "foo", "/index.html");
+ assert_string_equal(rv, "/p/foo/index.html");
+ free(rv);
+
+ rv = bm_generate_filename2(NULL, NULL, "q", NULL, "foo", "/index.html");
+ assert_string_equal(rv, "/q/foo/index.html");
+ free(rv);
+
+ rv = bm_generate_filename2(NULL, "p", "q", NULL, "foo", "/index.html");
+ assert_string_equal(rv, "/p/q/foo/index.html");
+ free(rv);
+
+ rv = bm_generate_filename2(NULL, NULL, NULL, NULL, "index", ".html");
+ assert_string_equal(rv, "/index.html");
+ free(rv);
+
+ rv = bm_generate_filename2(NULL, "p", NULL, NULL, "index", ".html");
+ assert_string_equal(rv, "/p/index.html");
+ free(rv);
+
+ rv = bm_generate_filename2(NULL, NULL, "q", NULL, "index", ".html");
+ assert_string_equal(rv, "/q/index.html");
+ free(rv);
+
+ rv = bm_generate_filename2(NULL, "p", "q", NULL, "index", ".html");
+ assert_string_equal(rv, "/p/q/index.html");
+ free(rv);
+
+ rv = bm_generate_filename2(NULL, NULL, NULL, NULL, "index", "/index.html");
+ assert_string_equal(rv, "/index.html");
+ free(rv);
+
+ rv = bm_generate_filename2(NULL, "p", NULL, NULL, "index", "/index.html");
+ assert_string_equal(rv, "/p/index/index.html");
+ free(rv);
+
+ rv = bm_generate_filename2(NULL, NULL, "q", NULL, "index", "/index.html");
+ assert_string_equal(rv, "/q/index/index.html");
+ free(rv);
+
+ rv = bm_generate_filename2(NULL, "p", "q", NULL, "index", "/index.html");
+ assert_string_equal(rv, "/p/q/index/index.html");
+ free(rv);
+
+ rv = bm_generate_filename2(NULL, NULL, NULL, "bar", "foo", ".html");
+ assert_string_equal(rv, "/bar/foo.html");
+ free(rv);
+
+ rv = bm_generate_filename2(NULL, "p", NULL, "bar", "foo", ".html");
+ assert_string_equal(rv, "/p/bar/foo.html");
+ free(rv);
+
+ rv = bm_generate_filename2(NULL, NULL, "q", "bar", "foo", ".html");
+ assert_string_equal(rv, "/q/bar/foo.html");
+ free(rv);
+
+ rv = bm_generate_filename2(NULL, "p", "q", "bar", "foo", ".html");
+ assert_string_equal(rv, "/p/q/bar/foo.html");
+ free(rv);
+
+ rv = bm_generate_filename2(NULL, NULL, NULL, "bar", "foo", "/index.html");
+ assert_string_equal(rv, "/bar/foo/index.html");
+ free(rv);
+
+ rv = bm_generate_filename2(NULL, "p", NULL, "bar", "foo", "/index.html");
+ assert_string_equal(rv, "/p/bar/foo/index.html");
+ free(rv);
+
+ rv = bm_generate_filename2(NULL, NULL, "q", "bar", "foo", "/index.html");
+ assert_string_equal(rv, "/q/bar/foo/index.html");
+ free(rv);
+
+ rv = bm_generate_filename2(NULL, "p", "q", "bar", "foo", "/index.html");
+ assert_string_equal(rv, "/p/q/bar/foo/index.html");
+ free(rv);
+
+ rv = bm_generate_filename2("_build", NULL, NULL, NULL, NULL, ".html");
+ assert_string_equal(rv, "_build/index.html");
+ free(rv);
+
+ rv = bm_generate_filename2("_build", "p", NULL, NULL, NULL, ".html");
+ assert_string_equal(rv, "_build/p.html");
+ free(rv);
+
+ rv = bm_generate_filename2("_build", NULL, "q", NULL, NULL, ".html");
+ assert_string_equal(rv, "_build/q.html");
+ free(rv);
+
+ rv = bm_generate_filename2("_build", "p", "q", NULL, NULL, ".html");
+ assert_string_equal(rv, "_build/p/q.html");
+ free(rv);
+
+ rv = bm_generate_filename2("_build", NULL, NULL, NULL, NULL, "/index.html");
+ assert_string_equal(rv, "_build/index.html");
+ free(rv);
+
+ rv = bm_generate_filename2("_build", "p", NULL, NULL, NULL, "/index.html");
+ assert_string_equal(rv, "_build/p/index.html");
+ free(rv);
+
+ rv = bm_generate_filename2("_build", NULL, "q", NULL, NULL, "/index.html");
+ assert_string_equal(rv, "_build/q/index.html");
+ free(rv);
+
+ rv = bm_generate_filename2("_build", "p", "q", NULL, NULL, "/index.html");
+ assert_string_equal(rv, "_build/p/q/index.html");
+ free(rv);
+
+ rv = bm_generate_filename2("_build", NULL, NULL, "lol", NULL, ".html");
+ assert_string_equal(rv, "_build/lol.html");
+ free(rv);
+
+ rv = bm_generate_filename2("_build", "p", NULL, "lol", NULL, ".html");
+ assert_string_equal(rv, "_build/p/lol.html");
+ free(rv);
+
+ rv = bm_generate_filename2("_build", NULL, "q", "lol", NULL, ".html");
+ assert_string_equal(rv, "_build/q/lol.html");
+ free(rv);
+
+ rv = bm_generate_filename2("_build", "p", "q", "lol", NULL, ".html");
+ assert_string_equal(rv, "_build/p/q/lol.html");
+ free(rv);
+
+ rv = bm_generate_filename2("_build", NULL, NULL, "lol", NULL, "/index.html");
+ assert_string_equal(rv, "_build/lol/index.html");
+ free(rv);
+
+ rv = bm_generate_filename2("_build", "p", NULL, "lol", NULL, "/index.html");
+ assert_string_equal(rv, "_build/p/lol/index.html");
+ free(rv);
+
+ rv = bm_generate_filename2("_build", NULL, "q", "lol", NULL, "/index.html");
+ assert_string_equal(rv, "_build/q/lol/index.html");
+ free(rv);
+
+ rv = bm_generate_filename2("_build", "p", "q", "lol", NULL, "/index.html");
+ assert_string_equal(rv, "_build/p/q/lol/index.html");
+ free(rv);
+
+ rv = bm_generate_filename2("_build", NULL, NULL, NULL, "foo", ".html");
+ assert_string_equal(rv, "_build/foo.html");
+ free(rv);
+
+ rv = bm_generate_filename2("_build", "p", NULL, NULL, "foo", ".html");
+ assert_string_equal(rv, "_build/p/foo.html");
+ free(rv);
+
+ rv = bm_generate_filename2("_build", NULL, "q", NULL, "foo", ".html");
+ assert_string_equal(rv, "_build/q/foo.html");
+ free(rv);
+
+ rv = bm_generate_filename2("_build", "p", "q", NULL, "foo", ".html");
+ assert_string_equal(rv, "_build/p/q/foo.html");
+ free(rv);
+
+ rv = bm_generate_filename2("_build", NULL, NULL, NULL, "foo", "/index.html");
+ assert_string_equal(rv, "_build/foo/index.html");
+ free(rv);
+
+ rv = bm_generate_filename2("_build", "p", NULL, NULL, "foo", "/index.html");
+ assert_string_equal(rv, "_build/p/foo/index.html");
+ free(rv);
+
+ rv = bm_generate_filename2("_build", NULL, "q", NULL, "foo", "/index.html");
+ assert_string_equal(rv, "_build/q/foo/index.html");
+ free(rv);
+
+ rv = bm_generate_filename2("_build", "p", "q", NULL, "foo", "/index.html");
+ assert_string_equal(rv, "_build/p/q/foo/index.html");
+ free(rv);
+
+ rv = bm_generate_filename2("_build", NULL, NULL, NULL, "index", ".html");
+ assert_string_equal(rv, "_build/index.html");
+ free(rv);
+
+ rv = bm_generate_filename2("_build", "p", NULL, NULL, "index", ".html");
+ assert_string_equal(rv, "_build/p/index.html");
+ free(rv);
+
+ rv = bm_generate_filename2("_build", NULL, "q", NULL, "index", ".html");
+ assert_string_equal(rv, "_build/q/index.html");
+ free(rv);
+
+ rv = bm_generate_filename2("_build", "p", "q", NULL, "index", ".html");
+ assert_string_equal(rv, "_build/p/q/index.html");
+ free(rv);
+
+ rv = bm_generate_filename2("_build", NULL, NULL, NULL, "index", "/index.html");
+ assert_string_equal(rv, "_build/index.html");
+ free(rv);
+
+ rv = bm_generate_filename2("_build", "p", NULL, NULL, "index", "/index.html");
+ assert_string_equal(rv, "_build/p/index/index.html");
+ free(rv);
+
+ rv = bm_generate_filename2("_build", NULL, "q", NULL, "index", "/index.html");
+ assert_string_equal(rv, "_build/q/index/index.html");
+ free(rv);
+
+ rv = bm_generate_filename2("_build", "p", "q", NULL, "index", "/index.html");
+ assert_string_equal(rv, "_build/p/q/index/index.html");
+ free(rv);
+
+ rv = bm_generate_filename2("_build", NULL, NULL, "bar", "foo", ".html");
+ assert_string_equal(rv, "_build/bar/foo.html");
+ free(rv);
+
+ rv = bm_generate_filename2("_build", "p", NULL, "bar", "foo", ".html");
+ assert_string_equal(rv, "_build/p/bar/foo.html");
+ free(rv);
+
+ rv = bm_generate_filename2("_build", NULL, "q", "bar", "foo", ".html");
+ assert_string_equal(rv, "_build/q/bar/foo.html");
+ free(rv);
+
+ rv = bm_generate_filename2("_build", "p", "q", "bar", "foo", ".html");
+ assert_string_equal(rv, "_build/p/q/bar/foo.html");
+ free(rv);
+
+ rv = bm_generate_filename2("_build", NULL, NULL, "bar", "foo", "/index.html");
+ assert_string_equal(rv, "_build/bar/foo/index.html");
+ free(rv);
+
+ rv = bm_generate_filename2("_build", "p", NULL, "bar", "foo", "/index.html");
+ assert_string_equal(rv, "_build/p/bar/foo/index.html");
+ free(rv);
+
+ rv = bm_generate_filename2("_build", NULL, "q", "bar", "foo", "/index.html");
+ assert_string_equal(rv, "_build/q/bar/foo/index.html");
+ free(rv);
+
+ rv = bm_generate_filename2("_build", "p", "q", "bar", "foo", "/index.html");
+ assert_string_equal(rv, "_build/p/q/bar/foo/index.html");
+ free(rv);
+}
+
+
int
main(void)
{
const UnitTest tests[] = {
unit_test(test_generate_filename),
+ unit_test(test_generate_filename2),
};
return run_tests(tests);
}