From e8436689aded1c620fdbe76e7ad4d65c2f4e49fc Mon Sep 17 00:00:00 2001 From: Rob Pike Date: Mon, 1 Nov 2010 14:23:07 -0700 Subject: [PATCH] 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 --- src/cmd/gotest/gotest | 22 ++++++++++++++-------- 1 file 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() {' -- 2.50.0