Compile the test binary to the named file.
The test still runs (unless -c or -i is specified).
-
The test binary also accepts flags that control execution of the test; these
-flags are also accessible by 'go test'. See 'go help testflag' for details.
+flags are also accessible by 'go test'. See 'go help testflag' for details.
If the test binary needs any other flags, they should be presented after the
package names. The go tool treats as a flag the first argument that begins with
cmdTest.Run = runTest
}
+const testUsage = "test [-c] [-i] [build and test flags] [packages] [flags for test binary]"
+
var cmdTest = &Command{
CustomFlags: true,
- UsageLine: "test [-c] [-i] [build and test flags] [packages] [flags for test binary]",
+ UsageLine: testUsage,
Short: "test packages",
Long: `
'Go test' automates testing the packages named by the import paths.
The package is built in a temporary directory so it does not interfere with the
non-test installation.
+` + strings.TrimSpace(testFlag1) + ` See 'go help testflag' for details.
+
+If the test binary needs any other flags, they should be presented after the
+package names. The go tool treats as a flag the first argument that begins with
+a minus sign that it does not recognize itself; that argument and all subsequent
+arguments are passed as arguments to the test binary.
+
+For more about build flags, see 'go help build'.
+For more about specifying packages, see 'go help packages'.
+
+See also: go build, go vet.
+`,
+}
+
+const testFlag1 = `
In addition to the build flags, the flags handled by 'go test' itself are:
-c
Compile the test binary to the named file.
The test still runs (unless -c or -i is specified).
-
The test binary also accepts flags that control execution of the test; these
-flags are also accessible by 'go test'. See 'go help testflag' for details.
-
-If the test binary needs any other flags, they should be presented after the
-package names. The go tool treats as a flag the first argument that begins with
-a minus sign that it does not recognize itself; that argument and all subsequent
-arguments are passed as arguments to the test binary.
-
-For more about build flags, see 'go help build'.
-For more about specifying packages, see 'go help packages'.
-
-See also: go build, go vet.
-`,
-}
+flags are also accessible by 'go test'.
+`
var helpTestflag = &Command{
UsageLine: "testflag",
The following flags are recognized by the 'go test' command and
control the execution of any test:
+ ` + strings.TrimSpace(testFlag2) + `
+`,
+}
+
+const testFlag2 = `
-bench regexp
Run benchmarks matching the regular expression.
By default, no benchmarks run. To run all benchmarks,
leave the test binary in pkg.test for use when analyzing the profiles.
Flags not recognized by 'go test' must be placed after any specified packages.
-`,
-}
+`
var helpTestfunc = &Command{
UsageLine: "testfunc",