Skip to content
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

proposal: cmd/go: change go test to FAIL if -run is specified but no tests match #64500

Open
hyangah opened this issue Dec 1, 2023 · 2 comments
Labels
GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Proposal
Milestone

Comments

@hyangah
Copy link
Contributor

hyangah commented Dec 1, 2023

Proposal Details

If -run is provided but there is no test matching the pattern, go test currently considers the test run PASS and exits with 0.

$ go test -run=Test_sum/1_+_1
testing: warning: no tests to run
PASS
ok      example/test    0.133s

Even though there is a warning like "testing: warning: no tests to run", this is easy to miss or dropped when the test binary runs by other runners (ide plugins, dlv, ..). I think when users set -run and if there is no matching test, that's likely not what users wanted, and treating it like misuse of command is more appropriate.

@dmitshur dmitshur added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. GoCommand cmd/go labels Dec 1, 2023
@dmitshur dmitshur added this to the Backlog milestone Dec 1, 2023
@dmitshur
Copy link
Contributor

dmitshur commented Dec 1, 2023

CC @bcmills, @matloob.

Slightly related, but in the opposite direction: go test and go vet currently print a warning and also exit with a fatal error when an import path pattern matches 0 packages (#31271, #52287), which can create overhead for a CI system wishing to permit modules that are empty or have packages for a subset of Go's ports, since they have no choice but need to convert such false-positive failures to successes on their own.

@bcmills bcmills changed the title cmd/go: change go test to FAIL if -run is specified but no tests match proposal: cmd/go: change go test to FAIL if -run is specified but no tests match Dec 1, 2023
@bcmills bcmills modified the milestones: Backlog, Proposal Dec 1, 2023
@bcmills
Copy link
Member

bcmills commented Dec 1, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Proposal
Projects
Status: Incoming
Development

No branches or pull requests

3 participants