From e79b89f07fbe2053c5ded679ada527e6a27b3b0a Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Thu, 17 Sep 2009 10:27:04 -0700 Subject: unused imports R=r OCL=34731 CL=34731 --- src/cmd/gotest/gotest | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) (limited to 'src/cmd/gotest') diff --git a/src/cmd/gotest/gotest b/src/cmd/gotest/gotest index e07932b52..5ee3eb0a8 100755 --- a/src/cmd/gotest/gotest +++ b/src/cmd/gotest/gotest @@ -86,11 +86,23 @@ MAKELEVEL= importpath=$(make -s importpath) { + # 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 _test/$importpath.a $xofile | egrep ' T .*·'$pattern'$' | grep -v '·.*[.·]' | sed 's/.* //; s/·/./') + if [ "x$tests" = x ]; then + echo 'gotest: error: no tests matching '$pattern in _test/$importpath.a $xofile 1>&2 + exit 2 + fi + # package spec echo 'package main' echo # imports - echo 'import "'$importpath'"' + if echo "$tests" | egrep -v '_test\.' >/dev/null; then + echo 'import "'$importpath'"' + fi if $havex; then echo 'import "./_xtest_"' fi @@ -98,20 +110,10 @@ importpath=$(make -s importpath) # 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. - pattern='Test([^a-z].*)?' - tests=$(6nm -s _test/$importpath.a $xofile | egrep ' T .*·'$pattern'$' | grep -v '·.*[.·]' | sed 's/.* //; s/·/./') - if [ "x$tests" = x ]; then - echo 'gotest: warning: no tests matching '$pattern in _test/$importpath.a $xofile 1>&2 - else - for i in $tests - do - echo ' testing.Test{ "'$i'", '$i' },' - done - fi + for i in $tests + do + echo ' testing.Test{ "'$i'", '$i' },' + done echo '}' # body echo -- cgit v1.2.3