t: ensure failure if field gets fed an invalid regexp value
[barcat.git] / t / regress.t
index 8f92ee7958524d98054349813aaad47c0791cd2a..e149b36dad00e3e263f27f8529830da468eb1c39 100755 (executable)
@@ -26,18 +26,26 @@ do
        esac
 done
 
-for candidate in ${@:-t*.in}
+for candidate in ${@:-t*.out}
 do
        test_count=$((test_count+1))
-       file="${candidate%.in}"
-       test -r "$file.in" || continue
-
+       file="${candidate%.out}"
+       input="${file%%_-*}.in"
        name="$(echo ${file#*-} | tr _ \ )"
-       set -- barcat "$file.in"
-       case "$name" in *\ -*) set -- "$@" -"${name#* -}";; esac
+
+       set -- barcat
+       [ -r "$input" ] && set -- "$@" "$input"
        case "$name" in
-               *' |'*) set -- sh -c "\$0 \$1 $3" "$@";;
-               *)      set -- "$1" "$2" $3
+               *\ -*)
+                       args="${name#* -}"
+                       set -- "$@" -"${args% [?|]*}"
+                       ;;
+       esac
+       case "$name" in
+               *' ?' ) set -- sh -c "\$0 \$@ 2>/dev/null" "$@";;
+               *' ?'*) set -- sh -c "\$0 \$@ | test \$\? = ${name#* \?}" "$@";;
+               *' |'*) set -- sh -c "\$0 \$@ | ${name#* |}" "$@";;
+               *)      eval set -- "$1" $2 $3
        esac
 
        if test -n "$regenerate"
@@ -60,8 +68,15 @@ do
 
        if test 0 != $?
        then
-               fail_count=$((fail_count+1))
-               color 1\;31
+               case "$name" in
+               *' #TODO')
+                       color 33
+                       ;;
+               *)
+                       fail_count=$((fail_count+1))
+                       color 1\;31
+               esac
+
                printf 'not '
        fi
        echo "ok $test_count - $name"