]> Cypherpunks repositories - gostls13.git/commitdiff
gotest: change pattern to Test([^a-z].*)?
authorRuss Cox <rsc@golang.org>
Tue, 25 Nov 2008 20:49:17 +0000 (12:49 -0800)
committerRuss Cox <rsc@golang.org>
Tue, 25 Nov 2008 20:49:17 +0000 (12:49 -0800)
warn about files with no tests
be clear about where testing warnings come from

R=r
DELTA=18  (12 added, 3 deleted, 3 changed)
OCL=19988
CL=19993

src/cmd/gotest/gotest
src/lib/testing.go

index 55d22e729995521e5a7b2a2474f79def3f267ec4..744a7f3c871bd30c0b13cd9ba397b19a205d63fb 100755 (executable)
@@ -55,12 +55,21 @@ trap "rm -f _testmain.go _testmain.6" 0 1 2 3 14 15
        # test array
        echo
        echo 'var tests = &[]testing.Test {'
-       # test functions are named TestFoo
-       # the grep -v eliminates methods and other special names
-       # that have multiple dots.
-       for i in $(6nm -s $ofiles | grep ' T .*·Test[A-Z]' | grep -v '·.*[.·]' | sed 's/.* //; s/·/./')
+       for ofile in $ofiles
        do
-               echo '  testing.Test{ "'$i'", &'$i' },'
+               # test functions are named TestFoo
+               # the grep -v eliminates methods and other special names
+               # that have multiple dots.
+               pattern='Test([^a-z].*)?'
+               tests=$(6nm -s $ofile | egrep ' T .*·'$pattern'$' | grep -v '·.*[.·]' | sed 's/.* //; s/·/./')
+               if [ "x$tests" = x ]; then
+                       echo 'gotest: warning: no tests matching '$pattern' in '$ofile 1>&2
+               else
+                       for i in $tests
+                       do
+                               echo '  testing.Test{ "'$i'", &'$i' },'
+                       done
+               fi
        done
        echo '}'
        # body
index 37dcc39411da629163edb89669266144ded212fb..afb24855badb6e8fd833f14c2f852fe24a8ee06a 100644 (file)
@@ -86,7 +86,7 @@ export func Main(tests *[]Test) {
        flag.Parse();
        ok := true;
        if len(tests) == 0 {
-               println("gotest: warning: no tests to run");
+               println("testing: warning: no tests to run");
        }
        for i := 0; i < len(tests); i++ {
                if chatty {