From b832feb3894d95a82e88da05bb9fa29c6da26211 Mon Sep 17 00:00:00 2001 From: "Rafael G. Martins" Date: Sun, 1 Jan 2017 18:14:22 +0100 Subject: make: added a bunch of tests --- tests/blogc-make/check_blogc_make.sh.in | 796 ++++++++++++++++++++++++++++++++ 1 file changed, 796 insertions(+) create mode 100755 tests/blogc-make/check_blogc_make.sh.in (limited to 'tests/blogc-make/check_blogc_make.sh.in') diff --git a/tests/blogc-make/check_blogc_make.sh.in b/tests/blogc-make/check_blogc_make.sh.in new file mode 100755 index 0000000..2139664 --- /dev/null +++ b/tests/blogc-make/check_blogc_make.sh.in @@ -0,0 +1,796 @@ +#!@BASH@ + +set -xe -o pipefail + +export LC_ALL=C + +TEMP="$(mktemp -d)" +[[ -n "${TEMP}" ]] + +trap_func() { + [[ -e "${TEMP}/output.txt" ]] && cat "${TEMP}/output.txt" + [[ -n "${TEMP}" ]] && rm -rf "${TEMP}" +} + +trap trap_func EXIT + +mkdir -p "${TEMP}"/proj{,/templates,/content/post} + + +### minimal settings, will produce no file + +cat > "${TEMP}/proj/settings.ini" <&1 + + +### default settings with some posts + +cat > "${TEMP}/proj/content/post/foo.txt" < "${TEMP}/proj/content/post/bar.txt" < "${TEMP}/proj/templates/main.tmpl" <> "${TEMP}/proj/settings.ini" <&1 | tee "${TEMP}/output.txt" +grep "_build/index\\.html" "${TEMP}/output.txt" +grep "_build/atom\\.xml" "${TEMP}/output.txt" +grep "_build/page/1/index\\.html" "${TEMP}/output.txt" +grep "_build/post/foo/index\\.html" "${TEMP}/output.txt" +grep "_build/post/bar/index\\.html" "${TEMP}/output.txt" + +rm "${TEMP}/output.txt" + +cat > "${TEMP}/expected-index.html" < "${TEMP}/expected-atom.xml" < + + Lol's Website + /atom.xml + 2016-10-01T00:00:00Z + + + + Lol + author@example.com + + WAT?! + + + Foo + /post/foo/ + 2016-10-01T00:00:00Z + 2016-10-01T00:00:00Z + + + Lol + author@example.com + + This is foo.

+]]>
+
+ + + Bar + /post/bar/ + 2016-09-01T00:00:00Z + 2016-09-01T00:00:00Z + + + Lol + author@example.com + + This is bar.

+]]>
+
+ +
+EOF +diff -uN "${TEMP}/proj/_build/atom.xml" "${TEMP}/expected-atom.xml" + +cat > "${TEMP}/expected-post-foo.html" <This is foo.

+ + +EOF +diff -uN "${TEMP}/proj/_build/post/foo/index.html" "${TEMP}/expected-post-foo.html" + +cat > "${TEMP}/expected-post-bar.html" <This is bar.

+ + +EOF +diff -uN "${TEMP}/proj/_build/post/bar/index.html" "${TEMP}/expected-post-bar.html" + +rm -rf "${TEMP}/proj/_build" + + +### default settings with some posts and tags + +cat > "${TEMP}/proj/content/post/baz.txt" <> "${TEMP}/proj/settings.ini" <&1 | tee "${TEMP}/output.txt" +grep "_build/index\\.html" "${TEMP}/output.txt" +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 "_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/tag2/index\\.html" "${TEMP}/output.txt" + +rm "${TEMP}/output.txt" + +cat > "${TEMP}/expected-index.html" < "${TEMP}/expected-atom.xml" < + + Lol's Website + /atom.xml + 2016-10-01T00:00:00Z + + + + Lol + author@example.com + + WAT?! + + + Foo + /post/foo/ + 2016-10-01T00:00:00Z + 2016-10-01T00:00:00Z + + + Lol + author@example.com + + This is foo.

+]]>
+
+ + + Bar + /post/bar/ + 2016-09-01T00:00:00Z + 2016-09-01T00:00:00Z + + + Lol + author@example.com + + This is bar.

+]]>
+
+ + + Baz + /post/baz/ + 2016-08-01T00:00:00Z + 2016-08-01T00:00:00Z + + + Lol + author@example.com + + This is baz.

+]]>
+
+ +
+EOF +diff -uN "${TEMP}/proj/_build/atom.xml" "${TEMP}/expected-atom.xml" + +cat > "${TEMP}/expected-atom-tag1.xml" < + + Lol's Website - tag1 + /atom/tag1.xml + 2016-08-01T00:00:00Z + + + + Lol + author@example.com + + WAT?! + + + Baz + /post/baz/ + 2016-08-01T00:00:00Z + 2016-08-01T00:00:00Z + + + Lol + author@example.com + + This is baz.

+]]>
+
+ +
+EOF +diff -uN "${TEMP}/proj/_build/atom/tag1.xml" "${TEMP}/expected-atom-tag1.xml" + +cat > "${TEMP}/expected-atom-tag2.xml" < + + Lol's Website - tag2 + /atom/tag2.xml + 2016-08-01T00:00:00Z + + + + Lol + author@example.com + + WAT?! + + + Baz + /post/baz/ + 2016-08-01T00:00:00Z + 2016-08-01T00:00:00Z + + + Lol + author@example.com + + This is baz.

+]]>
+
+ +
+EOF +diff -uN "${TEMP}/proj/_build/atom/tag2.xml" "${TEMP}/expected-atom-tag2.xml" + +cat > "${TEMP}/expected-post-baz.html" <This is baz.

+ + +EOF +diff -uN "${TEMP}/proj/_build/post/foo/index.html" "${TEMP}/expected-post-foo.html" +diff -uN "${TEMP}/proj/_build/post/bar/index.html" "${TEMP}/expected-post-bar.html" +diff -uN "${TEMP}/proj/_build/post/baz/index.html" "${TEMP}/expected-post-baz.html" + +cat > "${TEMP}/expected-tag1.html" < "${TEMP}/expected-tag2.html" < "${TEMP}/proj/content/page1.txt" < "${TEMP}/proj/content/page2.txt" <> "${TEMP}/proj/settings.ini" <&1 | tee "${TEMP}/output.txt" +grep "_build/index\\.html" "${TEMP}/output.txt" +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 "_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/tag2/index\\.html" "${TEMP}/output.txt" +grep "_build/page1/index\\.html" "${TEMP}/output.txt" +grep "_build/page2/index\\.html" "${TEMP}/output.txt" + +rm "${TEMP}/output.txt" + +diff -uN "${TEMP}/proj/_build/index.html" "${TEMP}/expected-index.html" +diff -uN "${TEMP}/proj/_build/page/1/index.html" "${TEMP}/expected-index.html" + +diff -uN "${TEMP}/proj/_build/atom.xml" "${TEMP}/expected-atom.xml" + +diff -uN "${TEMP}/proj/_build/atom/tag1.xml" "${TEMP}/expected-atom-tag1.xml" +diff -uN "${TEMP}/proj/_build/atom/tag2.xml" "${TEMP}/expected-atom-tag2.xml" + +diff -uN "${TEMP}/proj/_build/post/foo/index.html" "${TEMP}/expected-post-foo.html" +diff -uN "${TEMP}/proj/_build/post/bar/index.html" "${TEMP}/expected-post-bar.html" +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/tag2/index.html" "${TEMP}/expected-tag2.html" + +cat > "${TEMP}/expected-page1.html" <This is page 1.

+ + +EOF +diff -uN "${TEMP}/proj/_build/page1/index.html" "${TEMP}/expected-page1.html" + +cat > "${TEMP}/expected-page2.html" <This is page 2.

+ + +EOF +diff -uN "${TEMP}/proj/_build/page2/index.html" "${TEMP}/expected-page2.html" + +rm -rf "${TEMP}/proj" +mkdir -p "${TEMP}"/proj{,/temp,/contents/poost} + + +### custom settings with some posts + +cat > "${TEMP}/proj/contents/poost/foo.blogc" < "${TEMP}/proj/contents/poost/bar.blogc" < "${TEMP}/proj/temp/main.html" < "${TEMP}/proj/settings.ini" <&1 | tee "${TEMP}/output.txt" +grep "_blogc_build/posts\\.html" "${TEMP}/output.txt" +grep "_blogc_build/atoom/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/poost/foo\\.html" "${TEMP}/output.txt" +grep "_blogc_build/poost/bar\\.html" "${TEMP}/output.txt" + +rm "${TEMP}/output.txt" + +cat > "${TEMP}/expected-index.html" < "${TEMP}/expected-page-2.html" < "${TEMP}/expected-atom.xml" < + + Lol's Website + /atoom/index.xml + 2016-10-01T00:00:00Z + + + + Lol + author@example.com + + WAT?! + + + Foo + /poost/foo/ + 2016-10-01T00:00:00Z + 2016-10-01T00:00:00Z + + + Lol + author@example.com + + This is foo.

+]]>
+
+ +
+EOF +diff -uN "${TEMP}/proj/_blogc_build/atoom/index.xml" "${TEMP}/expected-atom.xml" + +cat > "${TEMP}/expected-post-foo.html" <This is foo.

+ + +EOF +diff -uN "${TEMP}/proj/_blogc_build/poost/foo.html" "${TEMP}/expected-post-foo.html" + +cat > "${TEMP}/expected-post-bar.html" <This is bar.

+ + +EOF +diff -uN "${TEMP}/proj/_blogc_build/poost/bar.html" "${TEMP}/expected-post-bar.html" + +rm -rf "${TEMP}/proj/_build" + + +### default settings with some posts and tags + +cat > "${TEMP}/proj/contents/poost/baz.blogc" <> "${TEMP}/proj/settings.ini" <&1 | tee "${TEMP}/output.txt" +grep "_blogc_build/posts\\.html" "${TEMP}/output.txt" +grep "_blogc_build/atoom/index\\.xml" "${TEMP}/output.txt" +grep "_blogc_build/atoom/tag1/index\\.xml" "${TEMP}/output.txt" +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 "_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/tag2\\.html" "${TEMP}/output.txt" + +rm "${TEMP}/output.txt" + +diff -uN "${TEMP}/proj/_blogc_build/posts.html" "${TEMP}/expected-index.html" +diff -uN "${TEMP}/proj/_blogc_build/pagination/1.html" "${TEMP}/expected-index.html" +diff -uN "${TEMP}/proj/_blogc_build/pagination/2.html" "${TEMP}/expected-page-2.html" + +cat > "${TEMP}/expected-page-3.html" < "${TEMP}/expected-atom-tag1.xml" < + + Lol's Website - tag1 + /atoom/tag1/index.xml + 2016-08-01T00:00:00Z + + + + Lol + author@example.com + + WAT?! + + + Baz + /poost/baz/ + 2016-08-01T00:00:00Z + 2016-08-01T00:00:00Z + + + Lol + author@example.com + + This is baz.

+]]>
+
+ +
+EOF +diff -uN "${TEMP}/proj/_blogc_build/atoom/tag1/index.xml" "${TEMP}/expected-atom-tag1.xml" + +cat > "${TEMP}/expected-atom-tag2.xml" < + + Lol's Website - tag2 + /atoom/tag2/index.xml + 2016-08-01T00:00:00Z + + + + Lol + author@example.com + + WAT?! + + + Baz + /poost/baz/ + 2016-08-01T00:00:00Z + 2016-08-01T00:00:00Z + + + Lol + author@example.com + + This is baz.

+]]>
+
+ +
+EOF +diff -uN "${TEMP}/proj/_blogc_build/atoom/tag2/index.xml" "${TEMP}/expected-atom-tag2.xml" + +cat > "${TEMP}/expected-post-baz.html" <This is baz.

+ + +EOF +diff -uN "${TEMP}/proj/_blogc_build/poost/foo.html" "${TEMP}/expected-post-foo.html" +diff -uN "${TEMP}/proj/_blogc_build/poost/bar.html" "${TEMP}/expected-post-bar.html" +diff -uN "${TEMP}/proj/_blogc_build/poost/baz.html" "${TEMP}/expected-post-baz.html" + +cat > "${TEMP}/expected-tag1.html" < "${TEMP}/expected-tag2.html" < "${TEMP}/proj/contents/page1.blogc" < "${TEMP}/proj/contents/page2.blogc" <> "${TEMP}/proj/settings.ini" <&1 | tee "${TEMP}/output.txt" +grep "_blogc_build/posts\\.html" "${TEMP}/output.txt" +grep "_blogc_build/atoom/index\\.xml" "${TEMP}/output.txt" +grep "_blogc_build/atoom/tag1/index\\.xml" "${TEMP}/output.txt" +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 "_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/tag2\\.html" "${TEMP}/output.txt" +grep "_blogc_build/page1\\.html" "${TEMP}/output.txt" +grep "_blogc_build/page2\\.html" "${TEMP}/output.txt" + +rm "${TEMP}/output.txt" + +diff -uN "${TEMP}/proj/_blogc_build/posts.html" "${TEMP}/expected-index.html" +diff -uN "${TEMP}/proj/_blogc_build/pagination/1.html" "${TEMP}/expected-index.html" +diff -uN "${TEMP}/proj/_blogc_build/pagination/2.html" "${TEMP}/expected-page-2.html" +diff -uN "${TEMP}/proj/_blogc_build/pagination/3.html" "${TEMP}/expected-page-3.html" + +diff -uN "${TEMP}/proj/_blogc_build/atoom/index.xml" "${TEMP}/expected-atom.xml" +diff -uN "${TEMP}/proj/_blogc_build/atoom/tag1/index.xml" "${TEMP}/expected-atom-tag1.xml" +diff -uN "${TEMP}/proj/_blogc_build/atoom/tag2/index.xml" "${TEMP}/expected-atom-tag2.xml" + +diff -uN "${TEMP}/proj/_blogc_build/poost/foo.html" "${TEMP}/expected-post-foo.html" +diff -uN "${TEMP}/proj/_blogc_build/poost/bar.html" "${TEMP}/expected-post-bar.html" +diff -uN "${TEMP}/proj/_blogc_build/poost/baz.html" "${TEMP}/expected-post-baz.html" + +diff -uN "${TEMP}/proj/_blogc_build/taag/tag1.html" "${TEMP}/expected-tag1.html" +diff -uN "${TEMP}/proj/_blogc_build/taag/tag2.html" "${TEMP}/expected-tag2.html" + +cat > "${TEMP}/expected-page1.html" <This is page 1.

+ + +EOF +diff -uN "${TEMP}/proj/_blogc_build/page1.html" "${TEMP}/expected-page1.html" + +cat > "${TEMP}/expected-page2.html" <This is page 2.

+ + +EOF +diff -uN "${TEMP}/proj/_blogc_build/page2.html" "${TEMP}/expected-page2.html" + +rm -rf "${TEMP}/proj/_blogc_build" -- cgit v1.2.3-18-g5258