LEFT | RIGHT |
1 // Copyright 2011 The Go Authors. All rights reserved. | 1 // Copyright 2011 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 package main | 5 package main |
6 | 6 |
7 import ( | 7 import ( |
8 "fmt" | 8 "fmt" |
9 "os" | 9 "os" |
10 "strconv" | 10 "strconv" |
11 "strings" | 11 "strings" |
12 ) | 12 ) |
13 | 13 |
14 // The flag handling part of go test is large and distracting. | 14 // The flag handling part of go test is large and distracting. |
15 // We can't use the flag package because some of the flags from | 15 // We can't use the flag package because some of the flags from |
16 // our command line are for us, and some are for 6.out, and | 16 // our command line are for us, and some are for 6.out, and |
17 // some are for both. | 17 // some are for both. |
18 | 18 |
19 var usageMessage = `Usage of go test: | 19 var usageMessage = `Usage of go test: |
20 -c=false: compile but do not run the test binary | 20 -c=false: compile but do not run the test binary |
21 -file=file_test.go: specify file to use for tests; | 21 -file=file_test.go: specify file to use for tests; |
22 use multiple times for multiple files | 22 use multiple times for multiple files |
23 -p=n: build and test up to n packages in parallel | 23 -p=n: build and test up to n packages in parallel |
24 -x=false: print command lines as they are executed | 24 -x=false: print command lines as they are executed |
25 | 25 |
26 // These flags can be passed with or without a "test." prefix: -v or -test.v. | 26 // These flags can be passed with or without a "test." prefix: -v or -test.v. |
27 -bench="": passes -test.bench to test | 27 -bench="": passes -test.bench to test |
| 28 -benchmem=false: print memory allocation statistics for benchmarks |
28 -benchtime=1: passes -test.benchtime to test | 29 -benchtime=1: passes -test.benchtime to test |
29 -cpu="": passes -test.cpu to test | 30 -cpu="": passes -test.cpu to test |
30 -cpuprofile="": passes -test.cpuprofile to test | 31 -cpuprofile="": passes -test.cpuprofile to test |
31 -memprofile="": passes -test.memprofile to test | 32 -memprofile="": passes -test.memprofile to test |
32 -memprofilerate=0: passes -test.memprofilerate to test | 33 -memprofilerate=0: passes -test.memprofilerate to test |
33 -blockprofile="": pases -test.blockprofile to test | 34 -blockprofile="": pases -test.blockprofile to test |
34 -blockprofilerate=0: passes -test.blockprofilerate to test | 35 -blockprofilerate=0: passes -test.blockprofilerate to test |
35 -parallel=0: passes -test.parallel to test | 36 -parallel=0: passes -test.parallel to test |
36 -run="": passes -test.run to test | 37 -run="": passes -test.run to test |
37 -short=false: passes -test.short to test | 38 -short=false: passes -test.short to test |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 {name: "work", boolVar: &buildWork}, | 71 {name: "work", boolVar: &buildWork}, |
71 {name: "gcflags"}, | 72 {name: "gcflags"}, |
72 {name: "ldflags"}, | 73 {name: "ldflags"}, |
73 {name: "gccgoflags"}, | 74 {name: "gccgoflags"}, |
74 {name: "tags"}, | 75 {name: "tags"}, |
75 {name: "compiler"}, | 76 {name: "compiler"}, |
76 {name: "race", boolVar: &buildRace}, | 77 {name: "race", boolVar: &buildRace}, |
77 | 78 |
78 // passed to 6.out, adding a "test." prefix to the name if necessary: -v
becomes -test.v. | 79 // passed to 6.out, adding a "test." prefix to the name if necessary: -v
becomes -test.v. |
79 {name: "bench", passToTest: true}, | 80 {name: "bench", passToTest: true}, |
| 81 {name: "benchmem", boolVar: new(bool), passToTest: true}, |
80 {name: "benchtime", passToTest: true}, | 82 {name: "benchtime", passToTest: true}, |
81 {name: "cpu", passToTest: true}, | 83 {name: "cpu", passToTest: true}, |
82 {name: "cpuprofile", passToTest: true}, | 84 {name: "cpuprofile", passToTest: true}, |
83 {name: "memprofile", passToTest: true}, | 85 {name: "memprofile", passToTest: true}, |
84 {name: "memprofilerate", passToTest: true}, | 86 {name: "memprofilerate", passToTest: true}, |
85 {name: "blockprofile", passToTest: true}, | 87 {name: "blockprofile", passToTest: true}, |
86 {name: "blockprofilerate", passToTest: true}, | 88 {name: "blockprofilerate", passToTest: true}, |
87 {name: "parallel", passToTest: true}, | 89 {name: "parallel", passToTest: true}, |
88 {name: "run", passToTest: true}, | 90 {name: "run", passToTest: true}, |
89 {name: "short", boolVar: new(bool), passToTest: true}, | 91 {name: "short", boolVar: new(bool), passToTest: true}, |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 | 233 |
232 // setIntFlag sets the addressed integer to the value. | 234 // setIntFlag sets the addressed integer to the value. |
233 func setIntFlag(flag *int, value string) { | 235 func setIntFlag(flag *int, value string) { |
234 x, err := strconv.Atoi(value) | 236 x, err := strconv.Atoi(value) |
235 if err != nil { | 237 if err != nil { |
236 fmt.Fprintf(os.Stderr, "go test: illegal int flag value %s\n", v
alue) | 238 fmt.Fprintf(os.Stderr, "go test: illegal int flag value %s\n", v
alue) |
237 usage() | 239 usage() |
238 } | 240 } |
239 *flag = x | 241 *flag = x |
240 } | 242 } |
LEFT | RIGHT |