From: Christian Heller Date: Sat, 19 Nov 2016 21:29:46 +0000 (+0100) Subject: Test .uuid files. X-Git-Url: https://plomlompom.com/repos/%7B%7Btodo.date%7D%7D?a=commitdiff_plain;h=99280c154c1bb2a73c1396213506e74f5804bad2;p=redo-blog Test .uuid files. --- diff --git a/test.sh b/test.sh index c64c2e9..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,8 +19,13 @@ cp test/test_files/bar\ baz.md test/test_dir/ cd test/test_dir redo cd ../.. +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 @@ -18,10 +34,4 @@ for file in test/test_files/*.html test/test_files/*.meta; do echo "== test FAILURE ==" fi done -uuid_file=test/test_dir/uuid.meta -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 +uuid_test "test/test_dir/uuid.meta"