3 uuid_pattern='[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'
8 printf "== %s meta file pattern match test ==\n" "$meta_file"
9 if cat "$meta_file" | sed -n '1p' | grep -Eq '^'"$uuid_pattern"'$' \
10 && cat "$meta_file" | sed -n '2p' | grep -Eq "^[0-9]+$"; then
11 echo "== test SUCCESS =="
13 echo "== test FAILURE =="
17 article_meta_file_test()
20 printf "== %s meta file pattern match test ==\n" "$meta_file"
21 if cat "$meta_file" | sed -n '1p' | grep -Eq '^'"$uuid_pattern"'$' \
22 && cat "$meta_file" | sed -n '2p' | grep -Eq "^[0-9]+_[0-9]+$" \
23 && cat "$meta_file" | sed -n '3p' | grep -Eq "^[0-9a-f]{32}$" \
24 && cat "$meta_file" | sed -n '2p' | grep -Eq "^[0-9]+_[0-9]+$"; then
25 echo "== test SUCCESS =="
27 echo "== test FAILURE =="
35 printf "== %s diff test ==\n" "$generated_file"
36 diff "$expected_file" "$generated_file"
37 if [ "$?" = "0" ]; then
38 echo "== test SUCCESS =="
40 echo "== test FAILURE =="
44 # Set up test directory, run file creations.
45 expected_files_dir="test/test_files"
46 generated_files_dir="test/test_dir"
47 rm -rf "$generated_files_dir"
48 ./add_dir.sh "$generated_files_dir"
50 cd "$generated_files_dir"
52 cp "$working_dir/$expected_files_dir"/te\"\;st.md .
54 cp "$working_dir/$expected_files_dir"/bar\ baz.md .
56 cp "$working_dir/$expected_files_dir"/foo.rst .
57 cp "$working_dir/$expected_files_dir"/foo.links .
60 # Test file modification tracking.
61 update_datetime_start=$(cat "metadata/bar baz.feed_snippet" | grep '<updated>')
63 sed -i '2d' bar\ baz.md
65 update_datetime_after_invisible_change=$(cat "metadata/bar baz.feed_snippet" | grep '<updated>')
66 printf "== testing \"bar baz\"' update tag remaining unchanged with invisible source file change ==\n"
67 if [ "$update_datetime_start" = "$update_datetime_after_invisible_change" ]; then
68 echo "== test SUCCESS =="
70 echo "== test FAILURE =="
73 sed -i '2d' bar\ baz.md
75 update_datetime_after_visible_change=$(cat "metadata/bar baz.feed_snippet" | grep '<updated>')
76 printf "== testing \"bar baz\"' update tag changing with visible source file change ==\n"
77 if [ "$update_datetime_start" = "$update_datetime_after_visible_change" ]; then
78 echo "== test FAILURE =="
80 echo "== test SUCCESS =="
82 cp "$working_dir/$expected_files_dir"/bar\ baz.md .
85 # Compare metadata files.
87 blog_meta_file_test "$generated_files_dir""/metadata/automatic_metadata"
88 for file in "$expected_files_dir"/metadata/*; do
89 basename=$(basename "$file")
90 cmp_file="$generated_files_dir/metadata/$basename"
91 diff_test "$file" "$cmp_file"
94 # Compare .links files.
96 for file in "$expected_files_dir"/*.links; do
97 basename=$(basename "$file")
98 cmp_file="$generated_files_dir/$basename"
99 diff_test "$file" "$cmp_file"
102 # Compare captcha files.
104 for file in "$expected_files_dir"/captchas/*; do
105 basename=$(basename "$file")
106 cmp_file="$generated_files_dir/captchas/$basename"
107 diff_test "$file" "$cmp_file"
110 # Compare generated HTML files. Ignore variable dates.
111 for file in "$expected_files_dir"/*.html.ignoring; do
112 basename=$(basename "$file")
113 cmp_file="$generated_files_dir/${basename%.ignoring}"
114 if [ ! "$file" = "$expected_files_dir""/index.html.ignoring" ]; then
115 article_meta_file_test "${generated_files_dir}/metadata/${basename%.html.ignoring}.automatic_metadata"
117 generated_file="$cmp_file".ignoring
119 sed 's/[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}/IGNORE/g' \
121 diff_test "$file" "$generated_file"
124 # Compare feed files. Ignore variable dates and UUIDs.
125 original_file="$generated_files_dir""/feed.xml"
126 generated_file="$original_file".ignoring
127 expected_file="$expected_files_dir""/feed.xml.ignoring"
128 cat "$original_file" | \
129 sed 's/[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}T[0-9]\{2\}:[0-9]\{2\}:[0-9]\{2\}Z/IGNORE/g' | \
130 sed 's/urn:uuid:[0-9a-f]\{8\}-[0-9a-f]\{4\}-[0-9a-f]\{4\}-[0-9a-f]\{4\}-[0-9a-f]\{12\}/urn:uuid:IGNORE/g' \
132 diff_test "$expected_file" "$generated_file"
135 # Check symbolic links.
136 for file in "$generated_files_dir"/feed.xml "$generated_files_dir"/*.html; do
137 basename=$(basename "$file")
138 linkname=$(readlink "$generated_files_dir/public/$basename")
139 printf "== public/%s symbolic link test ==\n" "$basename"
140 if [ "$working_dir/$generated_files_dir/$basename" = "$linkname" ]; then
141 echo "== test SUCCESS =="
143 echo "== test FAILURE =="