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

go test is reporting [no tests to run] despite having many tests #15

Closed
mfridman opened this issue Oct 29, 2018 · 2 comments
Closed

go test is reporting [no tests to run] despite having many tests #15

mfridman opened this issue Oct 29, 2018 · 2 comments

Comments

@mfridman
Copy link
Owner

mfridman commented Oct 29, 2018

This may be an issue with go test itself (nothing to do with testify, as originally described).

This will require digging into how go test is flags a package as [no tests to run].

https://github.com/golang/go/blob/8fc99d20f3377c7c5c1dba51b1be865ff61483b0/src/cmd/go/internal/test/test.go#L1197-L1204

@mfridman mfridman added the bug Something isn't working label Oct 29, 2018
@mfridman
Copy link
Owner Author

This appears to be by design. Going to think about it some more, but I think we'll be reverting a recent commit that checks for this line explicitly and then marks the entire package as "no tests to run".

This will have breaking changes on the output mechanism, but it's the right thing to do. We cannot be suppressing an entire package as a result of this behaviour.

https://github.com/golang/go/blob/8fc99d20f3377c7c5c1dba51b1be865ff61483b0/src/cmd/go/internal/test/test.go#L1197-L1215

if err == nil {
	norun := ""
	if !testShowPass && !testJSON {
		buf.Reset()
	}
	if bytes.HasPrefix(out, noTestsToRun[1:]) || bytes.Contains(out, noTestsToRun) {
		norun = " [no tests to run]"
	}
	fmt.Fprintf(cmd.Stdout, "ok  \t%s\t%s%s%s\n", a.Package.ImportPath, t, coveragePercentage(out), norun)
	c.saveOutput(a)
} else {
	base.SetExitStatus(1)
	// If there was test output, assume we don't need to print the exit status.
	// Buf there's no test output, do print the exit status.
	if len(out) == 0 {
		fmt.Fprintf(cmd.Stdout, "%s\n", err)
	}
	fmt.Fprintf(cmd.Stdout, "FAIL\t%s\t%s\n", a.Package.ImportPath, t)
}

@mfridman mfridman removed the bug Something isn't working label Oct 29, 2018
@mfridman
Copy link
Owner Author

mfridman commented Oct 30, 2018

I'm not bothered enough by the go test behaviour to file a bug.

So, if we come across a [no tests to run] we're going to record it at the package level. If any tests within the package contain testing: warning: no tests to run then we record it as well.

By default, this information won't be displayed.

screen shot 2018-10-29 at 9 06 14 pm

To get at that information use -notests, example:

screen shot 2018-10-29 at 9 29 09 pm

mfridman added a commit that referenced this issue Oct 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant