Skip to content

cmd/go: refer to testflag help in go test -help output #30420

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/cmd/go/internal/base/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 7 additions & 1 deletion src/cmd/go/internal/test/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/cmd/go/testdata/script/help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down