diff options
author | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2019-07-24 18:04:28 +0200 |
---|---|---|
committer | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2019-07-24 18:04:28 +0200 |
commit | 8a4e6248052ff32e02dcec3dd6850d4582836fb5 (patch) | |
tree | 6cec5c6839bceac42c3a3006fccae619c842c850 /tests | |
parent | 3b27b61e5409f58531e4aa8ce899b2d9c96fb433 (diff) | |
download | blogc-8a4e6248052ff32e02dcec3dd6850d4582836fb5.tar.gz blogc-8a4e6248052ff32e02dcec3dd6850d4582836fb5.tar.bz2 blogc-8a4e6248052ff32e02dcec3dd6850d4582836fb5.zip |
make: fixed filename generation for pagination_tags
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/blogc-make/check_blogc_make.sh.in | 182 | ||||
-rw-r--r-- | tests/blogc-make/check_utils.c | 349 |
2 files changed, 531 insertions, 0 deletions
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); } |