diff options
author | Russ Cox <rsc@golang.org> | 2009-09-17 10:27:04 -0700 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2009-09-17 10:27:04 -0700 |
commit | e79b89f07fbe2053c5ded679ada527e6a27b3b0a (patch) | |
tree | 96bb437a1d051ac0f6b76d09ac22aad882fa6d60 /src/cmd/gotest | |
parent | 3f4f89ac9bb7300c41b6c66e0d4fd0c9fabce9e8 (diff) | |
download | golang-e79b89f07fbe2053c5ded679ada527e6a27b3b0a.tar.gz |
unused imports
R=r
OCL=34731
CL=34731
Diffstat (limited to 'src/cmd/gotest')
-rwxr-xr-x | src/cmd/gotest/gotest | 32 |
1 files changed, 17 insertions, 15 deletions
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 |