From 921620e3df696442b688024c499541862bcd03eb Mon Sep 17 00:00:00 2001 From: "Rafael G. Martins" Date: Sat, 15 Oct 2016 17:44:39 +0200 Subject: blogc: added some "integration" tests --- tests/blogc/check_blogc.sh.in | 379 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 379 insertions(+) create mode 100755 tests/blogc/check_blogc.sh.in (limited to 'tests') diff --git a/tests/blogc/check_blogc.sh.in b/tests/blogc/check_blogc.sh.in new file mode 100755 index 0000000..7ea0c96 --- /dev/null +++ b/tests/blogc/check_blogc.sh.in @@ -0,0 +1,379 @@ +#!@BASH@ + +set -xe -o pipefail + +export LC_ALL=C + +TEMP="$(mktemp -d)" +[[ -n "${TEMP}" ]] + +trap_func() { + [[ -n "${TEMP}" ]] && rm -rf "${TEMP}" +} + +trap trap_func EXIT + +${TESTS_ENVIRONMENT} ./blogc -v | grep blogc + +cat > "${TEMP}/post1.txt" < "${TEMP}/post2.txt" < "${TEMP}/atom.tmpl" < + + {{ SITE_TITLE }} + {{ BASE_URL }}/atom.xml + {{ DATE_FIRST_FORMATTED }} + + + + {{ AUTHOR_NAME }} + {{ AUTHOR_EMAIL }} + + {{ SITE_TAGLINE }} + {% block listing %} + + {{ TITLE }} + {{ BASE_URL }}/post/{{ FILENAME }}/ + {{ DATE_FORMATTED }} + {{ DATE_FORMATTED }} + + + {{ AUTHOR_NAME }} + {{ AUTHOR_EMAIL }} + + + + {% endblock %} + +EOF + +cat > "${TEMP}/expected-output.xml" < + + Chunda's website + /atom.xml + 2010-01-01T11:11:11Z + + + + Chunda + chunda@bola.com + + + + + foo + /post/post1/ + 2010-01-01T11:11:11Z + 2010-01-01T11:11:11Z + + + Chunda + chunda@bola.com + + f]]> + + + + bar + /post/post2/ + 2010-01-01T22:22:22Z + 2010-01-01T22:22:22Z + + + Chunda + chunda@bola.com + + b]]> + + + +EOF + +${TESTS_ENVIRONMENT} ./blogc \ + -D BASE_DOMAIN=http://bola.com/ \ + -D BASE_URL= \ + -D AUTHOR_NAME=Chunda \ + -D AUTHOR_EMAIL=chunda@bola.com \ + -D SITE_TITLE="Chunda's website" \ + -D DATE_FORMAT="%Y-%m-%dT%H:%M:%SZ" \ + -t "${TEMP}/atom.tmpl" \ + -o "${TEMP}/output.xml" \ + -l \ + "${TEMP}/post1.txt" "${TEMP}/post2.txt" + +diff -uN "${TEMP}/output.xml" "${TEMP}/expected-output.xml" + +echo -e "${TEMP}/post1.txt\n${TEMP}/post2.txt" | ${TESTS_ENVIRONMENT} ./blogc \ + -D BASE_DOMAIN=http://bola.com/ \ + -D BASE_URL= \ + -D AUTHOR_NAME=Chunda \ + -D AUTHOR_EMAIL=chunda@bola.com \ + -D SITE_TITLE="Chunda's website" \ + -D DATE_FORMAT="%Y-%m-%dT%H:%M:%SZ" \ + -t "${TEMP}/atom.tmpl" \ + -o "${TEMP}/output2.xml" \ + -l \ + -i + +diff -uN "${TEMP}/output2.xml" "${TEMP}/expected-output.xml" + +${TESTS_ENVIRONMENT} ./blogc \ + -D BASE_DOMAIN=http://bola.com/ \ + -D BASE_URL= \ + -D AUTHOR_NAME=Chunda \ + -D AUTHOR_EMAIL=chunda@bola.com \ + -D SITE_TITLE="Chunda's website" \ + -D DATE_FORMAT="%Y-%m-%dT%H:%M:%SZ" \ + -t "${TEMP}/atom.tmpl" \ + -l \ + "${TEMP}/post1.txt" "${TEMP}/post2.txt" > "${TEMP}/output3.xml" + +diff -uN "${TEMP}/output3.xml" "${TEMP}/expected-output.xml" + +echo -e "${TEMP}/post1.txt\n${TEMP}/post2.txt" | ${TESTS_ENVIRONMENT} ./blogc \ + -D BASE_DOMAIN=http://bola.com/ \ + -D BASE_URL= \ + -D AUTHOR_NAME=Chunda \ + -D AUTHOR_EMAIL=chunda@bola.com \ + -D SITE_TITLE="Chunda's website" \ + -D DATE_FORMAT="%Y-%m-%dT%H:%M:%SZ" \ + -t "${TEMP}/atom.tmpl" \ + -l \ + -i > "${TEMP}/output4.xml" + +diff -uN "${TEMP}/output4.xml" "${TEMP}/expected-output.xml" + +cat > "${TEMP}/main.tmpl" < + + + {% block entry %}{{ TITLE }}{% endblock %}{% block listing_once %}{{ SITE_TITLE }}{% endblock %} + + +
{{ SITE_TITLE }}
+ {% block listing_once %} +
+
+
+
Blog
+
    + {% endblock %} + {% block listing %} +
  • +
    {{ DATE_FORMATTED }}
    +
    {{ TITLE }}
    +
  • + {% endblock %} + {% block listing_once %} +
+
+
+
+ {% endblock %} + {% block entry %} +
+
+
+ {% ifdef IS_POST %}
{% endif %} +
+
{{ TITLE }}
+
+ {% ifdef IS_POST %} +
+
{{ DATE_FORMATTED }}
+
+
+ {% endif %} +
+ {{ CONTENT }} + {% ifdef IS_POST %} +
+

Back to posts

+ {% endif %} +
+
+
+
+ {% endblock %} + + +EOF + +cat > "${TEMP}/expected-output.html" < + + + Chunda's website + + +
Chunda's website
+ +
+
+
+
Blog
+
    + + +
  • +
    Jan 01, 2010, 11:11 AM GMT
    +
    foo
    +
  • + +
  • +
    Jan 01, 2010, 10:22 PM GMT
    +
    bar
    +
  • + + +
+
+
+
+ + + + +EOF + +${TESTS_ENVIRONMENT} ./blogc \ + -D BASE_DOMAIN=http://bola.com/ \ + -D BASE_URL= \ + -D SITE_TITLE="Chunda's website" \ + -D DATE_FORMAT="%b %d, %Y, %I:%M %p GMT" \ + -t "${TEMP}/main.tmpl" \ + -o "${TEMP}/output.html" \ + -l \ + "${TEMP}/post1.txt" "${TEMP}/post2.txt" + +diff -uN "${TEMP}/output.html" "${TEMP}/expected-output.html" + +echo -e "${TEMP}/post1.txt\n${TEMP}/post2.txt" | ${TESTS_ENVIRONMENT} ./blogc \ + -D BASE_DOMAIN=http://bola.com/ \ + -D BASE_URL= \ + -D SITE_TITLE="Chunda's website" \ + -D DATE_FORMAT="%b %d, %Y, %I:%M %p GMT" \ + -t "${TEMP}/main.tmpl" \ + -o "${TEMP}/output2.html" \ + -l \ + -i + +diff -uN "${TEMP}/output2.html" "${TEMP}/expected-output.html" + +${TESTS_ENVIRONMENT} ./blogc \ + -D BASE_DOMAIN=http://bola.com/ \ + -D BASE_URL= \ + -D SITE_TITLE="Chunda's website" \ + -D DATE_FORMAT="%b %d, %Y, %I:%M %p GMT" \ + -t "${TEMP}/main.tmpl" \ + -l \ + "${TEMP}/post1.txt" "${TEMP}/post2.txt" > "${TEMP}/output3.html" + +diff -uN "${TEMP}/output3.html" "${TEMP}/expected-output.html" + +echo -e "${TEMP}/post1.txt\n${TEMP}/post2.txt" | ${TESTS_ENVIRONMENT} ./blogc \ + -D BASE_DOMAIN=http://bola.com/ \ + -D BASE_URL= \ + -D SITE_TITLE="Chunda's website" \ + -D DATE_FORMAT="%b %d, %Y, %I:%M %p GMT" \ + -t "${TEMP}/main.tmpl" \ + -l \ + -i > "${TEMP}/output4.html" + +diff -uN "${TEMP}/output4.html" "${TEMP}/expected-output.html" + +cat > "${TEMP}/expected-output2.html" < + + + foo + + +
Chunda's website
+ + + + +
+
+
+ +
+
foo
+
+ +
+

foo?

+ + +
+
+
+
+ + + +EOF + +${TESTS_ENVIRONMENT} ./blogc \ + -D BASE_DOMAIN=http://bola.com/ \ + -D BASE_URL= \ + -D SITE_TITLE="Chunda's website" \ + -D DATE_FORMAT="%b %d, %Y, %I:%M %p GMT" \ + -t "${TEMP}/main.tmpl" \ + -o "${TEMP}/output5.html" \ + "${TEMP}/post1.txt" + +diff -uN "${TEMP}/output5.html" "${TEMP}/expected-output2.html" + +echo -e "${TEMP}/post1.txt" | ${TESTS_ENVIRONMENT} ./blogc \ + -D BASE_DOMAIN=http://bola.com/ \ + -D BASE_URL= \ + -D SITE_TITLE="Chunda's website" \ + -D DATE_FORMAT="%b %d, %Y, %I:%M %p GMT" \ + -t "${TEMP}/main.tmpl" \ + -o "${TEMP}/output6.html" \ + -i + +diff -uN "${TEMP}/output6.html" "${TEMP}/expected-output2.html" + +${TESTS_ENVIRONMENT} ./blogc \ + -D BASE_DOMAIN=http://bola.com/ \ + -D BASE_URL= \ + -D SITE_TITLE="Chunda's website" \ + -D DATE_FORMAT="%b %d, %Y, %I:%M %p GMT" \ + -t "${TEMP}/main.tmpl" \ + "${TEMP}/post1.txt" > "${TEMP}/output7.html" + +diff -uN "${TEMP}/output7.html" "${TEMP}/expected-output2.html" + +echo -e "${TEMP}/post1.txt" | ${TESTS_ENVIRONMENT} ./blogc \ + -D BASE_DOMAIN=http://bola.com/ \ + -D BASE_URL= \ + -D SITE_TITLE="Chunda's website" \ + -D DATE_FORMAT="%b %d, %Y, %I:%M %p GMT" \ + -t "${TEMP}/main.tmpl" \ + -i > "${TEMP}/output8.html" + +diff -uN "${TEMP}/output8.html" "${TEMP}/expected-output2.html" + +echo "{% block listig %}foo{% endblock %}\n" > "${TEMP}/error.tmpl" + +${TESTS_ENVIRONMENT} ./blogc \ + -t "${TEMP}/error.tmpl" \ + "${TEMP}/post1.txt" 2>&1 | tee "${TEMP}/output.txt" || true + +grep "blogc: error: template: Invalid block type" "${TEMP}/output.txt" -- cgit v1.2.3-18-g5258