home · contact · privacy
5a0284d79f18a453e464b319bbb1bd6a2e9ad107
[redo-blog] / test.sh
1 #!/bin/sh
2
3 uuid_test()
4 {
5 uuid_file="$1"
6 printf "== %s UUID pattern match test ==\n" "$uuid_file"
7 if cat "$uuid_file" | grep -Eq "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"; then
8   echo "== test SUCCESS =="
9 else
10   echo "== test FAILURE =="
11 fi
12 }
13
14 rm -rf test/test_dir
15 ./add_dir.sh test/test_dir
16 cp test/test_files/test.md test/test_dir/
17 cp test/test_files/foo.rst test/test_dir/
18 cp test/test_files/bar\ baz.md test/test_dir/
19 cd test/test_dir
20 redo
21 cd ../..
22 uuid_regex="^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
23 for file in test/test_files/*.html test/test_files/*.meta; do
24   cmp_file=`echo "$file" | sed 's/test_files/test_dir/'`
25   if [ ! "$file" = "test/test_files/index.html" ] && \
26       echo "$file" | grep -q "\.html$"; then
27     uuid_test "${cmp_file%.html}.uuid"
28   fi
29   printf "== %s diff test ==\n" "$cmp_file"
30   diff "$file" "$cmp_file"
31   if [ "$?" = "0" ]; then
32     echo "== test SUCCESS =="
33   else
34     echo "== test FAILURE =="
35   fi
36 done
37 uuid_test "test/test_dir/uuid.meta"