]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: refer to testflag help in go test -help output
authorVladimir Varankin <vladimir@varank.in>
Tue, 26 Feb 2019 23:21:59 +0000 (23:21 +0000)
committerBryan C. Mills <bcmills@google.com>
Fri, 1 Mar 2019 23:14:39 +0000 (23:14 +0000)
The change makes it easier for a user to get to the page where
she can check supported test flags, by adding 'go test testflag'
reference to the 'go test -help' output.

Fix #30365

Change-Id: I5b3db7853021ef68d096dcb467d7957d7e1bf623
GitHub-Last-Rev: ce3dec59fcae0cca232372f01cdda98773c290c0
GitHub-Pull-Request: golang/go#30420
Reviewed-on: https://go-review.googlesource.com/c/163858
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/cmd/go/internal/base/base.go
src/cmd/go/internal/test/test.go
src/cmd/go/testdata/script/help.txt

index bf810ff7622ac7ba7bcfaf1f9ed9bdaddcb48606..028f9b6aeff1f1354130fad8a8a3ef6681b9c183 100644 (file)
@@ -30,7 +30,7 @@ type Command struct {
        Run func(cmd *Command, args []string)
 
        // UsageLine is the one-line usage message.
-       // The first word in the line is taken to be the command name.
+       // The words between "go" and the first flag or argument in the line are taken to be the command name.
        UsageLine string
 
        // Short is the short description shown in the 'go help' output.
index 8dfb3df22d3b9ed4ba93d0b22d16b1550dbdac1a..fe90af3be51f51c487afc58c1340f12f3fbee3b1 100644 (file)
@@ -514,10 +514,16 @@ var testVetFlags = []string{
        // "-unusedresult",
 }
 
+func testCmdUsage() {
+       fmt.Fprintf(os.Stderr, "usage: %s\n", CmdTest.UsageLine)
+       fmt.Fprintf(os.Stderr, "Run 'go help %s' and 'go help %s' for details.\n", CmdTest.LongName(), HelpTestflag.LongName())
+       os.Exit(2)
+}
+
 func runTest(cmd *base.Command, args []string) {
        modload.LoadTests = true
 
-       pkgArgs, testArgs = testFlags(cmd.Usage, args)
+       pkgArgs, testArgs = testFlags(testCmdUsage, args)
 
        work.FindExecCmd() // initialize cached result
 
index e6cbc829281cbdb227a55e1e218ccbc27742a356..9752ede2e372830eabca429fdbc1ae67fa16d0d9 100644 (file)
@@ -42,7 +42,7 @@ stderr 'Run ''go tool vet -help'' for the vet tool''s flags'
 # lines.
 ! go test -h
 stderr 'usage: go test'
-stderr 'Run ''go help test'' for details'
+stderr 'Run ''go help test'' and ''go help testflag'' for details.'
 
 # go help get shows usage for get
 go help get