Commit Diff


commit - c927fdffe1941bd89d2faa9aa5439dd27a7b4eed
commit + 0cbb500d5465f28a383fa7f778ca9daca3f7cebd
blob - 23086b0af7acfbf15c671d065c5a935d5aae1111
blob + 75de0f328efa70906b9f140a69ae7dec8ed158b2
--- support/adapt-tst
+++ support/adapt-tst
@@ -3,18 +3,30 @@
 # This script adapts a test suite that exposes the simple report protocol of
 # test.h for use with exercise.
 #
-# Usage: adapt-tst cmd [arg ...]
+# Usage: adapt-tst cmd [-v] [arg ...]
 #
 # Example: Given a test suite in 'foo.tst.c' that is built into an executable
 # 'foo.tst', create the script 'foo.ts' containing the following:
 #
 #    #!/bin/sh
-#    exec ./adapt-tst ./foo.tst
+#    exec ./adapt-tst ./foo.tst "$@"
 #
 
 cmd="$1"
 shift
 
+# handle command line flags
+vflag=0
+while getopts v ch
+do
+	case $ch in
+	v)	vflag=$(($vflag + 1)) ;;
+	?)	echo "usage: adapt-tst cmd [-v] [arg ...]"
+	esac
+done
+shift $(($OPTIND - 1))
+
+# create temp. file for communicating with the test
 tmp=/tmp/adapt-tst.$$
 trap "rm -f $tmp" EXIT
 
@@ -23,6 +35,7 @@ run=0 ok=0 fail=0 error=0
 
 # clear the flag variables for the test executable
 unset D V K X
+[ $vflag -ge 2 ] && export V=1
 
 # determine the total number of tests by performing a dry run
 D=1 "$cmd" "$@" >$tmp || exit 127
@@ -31,14 +44,28 @@ run=$(echo $(wc -l <$tmp))
 # perform the tests, counting and reporting results
 echo "run $run  ok $ok  fail $fail  error $error"
 "$cmd" "$@" >$tmp
-IFS='	'
-while read name result
+IFS=			# disable field splitting to read the whole line
+while read -r line
 do
+	case "$line" in
+	'	'*)	[ $vflag -ge 2 ] && echo "> >$line"
+			continue ;;
+	esac
+	IFS='	' read -r name result <<-EOF
+		$line
+	EOF
+
 	case "$result" in
+	OK | FAIL)	[ $vflag -ge 1 ] && echo "> $name" ;;
+	-)		[ $vflag -ge 2 ] && echo "> $name	skipped" ;;
+	esac
+
+	case "$result" in
 	OK)	ok=$((ok + 1)) ;;
 	FAIL)	fail=$((fail + 1))
-		echo "$name	$result" >&2 ;;
-	*)	error=$((error + 1)) ;;
+		echo "$line" >&2 ;;
+	-)	;;
+	#*)	error=$((error + 1)) ;;
 	esac
 
 	echo "run $run  ok $ok  fail $fail  error $error"
blob - d3b706d3660e25df4360ca058d55d973797cad77
blob + ea341fe95ef8a87f05c21a948248710270c5d57f
--- tests/support/adapt-tst.t
+++ tests/support/adapt-tst.t
@@ -10,7 +10,9 @@ cat >$tmp <<-"EOF"
 	    echo "test_2()"
 	    echo "test_3()"
 	else
+	    [ -n "$V" ] && echo "foo()	-"
 	    echo "test_1()	OK"
+	    [ -n "$V" ] && echo "	bemerke auch"
 	    echo "test_2()	OK"
 	    echo "something something unexpected" >&2
 	    echo "test_3()	FAIL"
@@ -20,10 +22,31 @@ EOF
 chmod +x $tmp
 
 export tst=$0.ts
+
 ./assert-exercise $0 \
 	"run 3  ok 2  fail 1  error 0\n" \
 	"something something unexpected\ntest_3()\tFAIL\nfail $tst\n\n" \
 	<<-EOF
 		#!/bin/sh
-		exec ../../support/adapt-tst $tmp
+		exec ../../support/adapt-tst $tmp "\$@"
 	EOF
+
+./assert-exercise $0 \
+	"> $tst\n> > test_1()\n> > test_2()\n> > test_3()\n\
+run 3  ok 2  fail 1  error 0\n" \
+	"something something unexpected\ntest_3()\tFAIL\nfail $tst\n\n" \
+	-v \
+	<<-EOF
+		#!/bin/sh
+		exec ../../support/adapt-tst $tmp "\$@"
+	EOF
+
+./assert-exercise $0 \
+	"> $tst\n> > foo()\tskipped\n> > test_1()\n> > >\tbemerke auch\n\
+> > test_2()\n> > test_3()\nrun 3  ok 2  fail 1  error 0\n" \
+	"something something unexpected\ntest_3()\tFAIL\nfail $tst\n\n" \
+	-vv \
+	<<-EOF
+		#!/bin/sh
+		exec ../../support/adapt-tst $tmp "\$@"
+	EOF