home · contact · privacy
Test .uuid files.
authorChristian Heller <c.heller@plomlompom.de>
Sat, 19 Nov 2016 21:29:46 +0000 (22:29 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Sat, 19 Nov 2016 21:29:46 +0000 (22:29 +0100)
test.sh

diff --git a/test.sh b/test.sh
index c64c2e935f5281bb134b518f7d0df9f743841756..5a0284d79f18a453e464b319bbb1bd6a2e9ad107 100755 (executable)
--- 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"