diff options
author | Rob Pike <r@golang.org> | 2010-11-01 14:23:07 -0700 |
---|---|---|
committer | Rob Pike <r@golang.org> | 2010-11-01 14:23:07 -0700 |
commit | e8436689aded1c620fdbe76e7ad4d65c2f4e49fc (patch) | |
tree | 69ea813b78f30215474ddf002cf4d936e738b1d1 | |
parent | 6442f38a9198c8a4e9fc9655cc96533405c507fc (diff) | |
download | go-e8436689aded1c620fdbe76e7ad4d65c2f4e49fc.tar.gz go-e8436689aded1c620fdbe76e7ad4d65c2f4e49fc.zip |
gotest: if the benchmark list is empty, print it in a way that
gofmt will leave alone.
R=rsc, bradfitz, bradfitzpatrick
CC=golang-dev
https://golang.org/cl/2816041
-rwxr-xr-x | src/cmd/gotest/gotest | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/cmd/gotest/gotest b/src/cmd/gotest/gotest index 112192ecdc..7c2c5fbaaf 100755 --- a/src/cmd/gotest/gotest +++ b/src/cmd/gotest/gotest @@ -153,17 +153,23 @@ importpath=$(gomake -s importpath) echo 'var tests = []testing.Test{' for i in $tests do - echo ' testing.Test{"'$i'", '$i'},' + echo ' {"'$i'", '$i'},' done echo '}' # benchmark array - echo 'var benchmarks = []testing.InternalBenchmark{' - for i in $benchmarks - do - echo ' testing.InternalBenchmark{"'$i'", '$i'},' - done - echo '}' - + if [ "$benchmarks" = "" ] + then + # keep the empty array gofmt-safe. + # (not an issue for the test array, which is never empty.) + echo 'var benchmarks = []testing.InternalBenchmark{}' + else + echo 'var benchmarks = []testing.InternalBenchmark{' + for i in $benchmarks + do + echo ' {"'$i'", '$i'},' + done + echo '}' + fi # body echo echo 'func main() {' |