tests.sh: use `todo` files to store magic strings
authorJean Privat <jean@pryen.org>
Fri, 7 Aug 2015 21:18:34 +0000 (17:18 -0400)
committerJean Privat <jean@pryen.org>
Mon, 10 Aug 2015 14:21:06 +0000 (10:21 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

tests/README.md
tests/tests.sh
tests/todo [new file with mode: 0644]

index 5a6f51c..f0883e3 100644 (file)
@@ -154,11 +154,14 @@ It is a failure, and analogous to the standard `fail`.
 
 `[todo] out/zzz_test_todo.res -> not yet implemented`
 
-The produced result file contains the magic string "NOT YET IMPLEMENTED".
+The produced result file contains a magic string, like `NOT YET IMPLEMENTED`.
 Those are considered the same as expected errors (like a fixme)
 It is a success.
 
-Some engines, libraries or program just print this to simplify the management of tests.
+The magic strings are listed in `todo` files in the root and `sav` directories.
+They are used by engines, libraries or program just print this to simplify the management of tests.
+
+Magic strings are used with `grep -f`, so each line is a pattern that is searched within the res files.
 
 ### Skipped
 
index 6330517..768b698 100755 (executable)
@@ -260,7 +260,7 @@ function process_result()
                esac
        done
        OLD=`echo "$OLD" | sed -e 's/   */ /g' -e 's/^ //' -e 's/ $//'`
-       grep 'NOT YET IMPLEMENTED' "$outdir/$pattern.res" >/dev/null
+       istodo  "$outdir/$pattern.res"
        NYI="$?"
        if [ -n "$SAV" ]; then
                if [ -n "$OLD" ]; then
@@ -404,6 +404,20 @@ skip_cc()
        return 1
 }
 
+# Check that the resfile ($1) matches some magic strings in `todo` files.
+istodo()
+{
+       test "$no" = true && return 1
+       for savdir in $savdirs .; do
+               local f="$savdir/todo"
+               test -f "$f" || continue
+               if grep -f "$f" "$1" >/dev/null 2>&1; then
+                       return 0
+               fi
+       done
+       return 1
+}
+
 find_nitc()
 {
        local name="$enginebinname"
diff --git a/tests/todo b/tests/todo
new file mode 100644 (file)
index 0000000..78d51cc
--- /dev/null
@@ -0,0 +1 @@
+NOT YET IMPLEMENTED