From: Rob Pike Date: Mon, 1 Nov 2010 21:23:07 +0000 (-0700) Subject: gotest: if the benchmark list is empty, print it in a way that X-Git-Tag: weekly.2010-11-02~14 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=e8436689aded1c620fdbe76e7ad4d65c2f4e49fc;p=gostls13.git 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 --- 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() {'