test: optionally print subtest number
authorDavid Bremner <bremner@debian.org>
Tue, 13 Dec 2011 19:56:47 +0000 (15:56 -0400)
committerDavid Bremner <bremner@debian.org>
Sun, 18 Dec 2011 10:33:27 +0000 (06:33 -0400)
The idea is that $test_count could be used in tests to label
intermediate files. The output enabled by this patch (and --debug)
helps figure out which OUTPUT.nn file belongs to which test in case
several subtests write to OUTPUT.$test_count

test/test-lib.sh

index 6be93fe35d876ff72761bd095166a90c50fa9e48..b5e346c0c544abdfdfe7700b7b14385123d72719 100644 (file)
@@ -116,6 +116,16 @@ do
        esac
 done
 
+if test -n "$debug"; then
+    print_subtest () {
+       printf " %-4s" "[$((test_count - 1))]"
+    }
+else
+    print_subtest () {
+       true
+    }
+fi
+
 if test -n "$color"; then
        say_color () {
                (
@@ -132,6 +142,7 @@ if test -n "$color"; then
                printf " "
                 printf "$@"
                tput sgr0
+               print_subtest
                )
        }
 else
@@ -140,6 +151,7 @@ else
                shift
                printf " "
                 printf "$@"
+               print_subtest
        }
 fi