X-Git-Url: https://plomlompom.com/repos/?a=blobdiff_plain;ds=sidebyside;f=test.sh;h=5a0284d79f18a453e464b319bbb1bd6a2e9ad107;hb=99280c154c1bb2a73c1396213506e74f5804bad2;hp=00194ba7f644bebf3e245292be75b20e11ba5e70;hpb=58272f437f554daa14ac1dfdf9902d48c17841bf;p=redo-blog diff --git a/test.sh b/test.sh index 00194ba..5a0284d 100755 --- a/test.sh +++ b/test.sh @@ -1,5 +1,16 @@ #!/bin/sh +uuid_test() +{ +uuid_file="$1" +printf "== %s UUID pattern match test ==\n" "$uuid_file" +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 + echo "== test SUCCESS ==" +else + echo "== test FAILURE ==" +fi +} + rm -rf test/test_dir ./add_dir.sh test/test_dir cp test/test_files/test.md test/test_dir/ @@ -8,10 +19,19 @@ cp test/test_files/bar\ baz.md test/test_dir/ cd test/test_dir redo cd ../.. -echo "== index.html diff test ==" -diff test/test_files/index.html test/test_dir/index.html -if [ "$?" = "0" ]; then - echo "== test SUCCESS ==" -else - echo "== test FAILURE ==" -fi +uuid_regex="^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$" +for file in test/test_files/*.html test/test_files/*.meta; do + cmp_file=`echo "$file" | sed 's/test_files/test_dir/'` + if [ ! "$file" = "test/test_files/index.html" ] && \ + echo "$file" | grep -q "\.html$"; then + uuid_test "${cmp_file%.html}.uuid" + fi + printf "== %s diff test ==\n" "$cmp_file" + diff "$file" "$cmp_file" + if [ "$?" = "0" ]; then + echo "== test SUCCESS ==" + else + echo "== test FAILURE ==" + fi +done +uuid_test "test/test_dir/uuid.meta"