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

testing: unexpected top level test output belonging to a subtest #29755

Open
mfridman opened this Issue Jan 15, 2019 · 1 comment

Comments

Projects
None yet
2 participants
@mfridman
Copy link

mfridman commented Jan 15, 2019

What version of Go are you using (go version)?

go version devel +76e8ca4 Tue Jan 15 18:14:54 2019 +0000 darwin/amd64

Does this issue reproduce with the latest release?

N/A, working with master.

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOOS="darwin"

What did you do?

Run code from this playground example

go test debug/golang/subtest -run ^TestThis$ -v -race

What did you expect to see?

Expected to see the test output

some_test.go:14: woah, something went wrong

belong to the top level test and not the inner subtest. E.g., when running the above with -json I'd expect this output:

{"Time":"2019-01-15T13:40:03.616451-05:00","Action":"output","Package":"debug/golang/subtest","Test":"TestThis/topLevelTest","Output":"        some_test.go:14: woah, something went wrong\n"}

note the test name in the json output is expected to beTestThis/topLevelTest

What did you see instead?

Instead the output and -json output makes it seem as if it belongs to the inner subtest, i.e., test name TestThis/topLevelTest/subA

This may be a misuse of the API, but I couldn't find any docs that mention there shouldn't be anything in between subtests.

=== RUN   TestThis
=== RUN   TestThis/topLevelTest
=== RUN   TestThis/topLevelTest/subA
--- FAIL: TestThis (0.00s)
    --- FAIL: TestThis/topLevelTest (0.00s)
        --- PASS: TestThis/topLevelTest/subA (0.00s)
            some_test.go:11: subA passing
        some_test.go:14: woah, something went wrong
FAIL
FAIL	debug/go-trun	0.026s

The -json output was:

{"Time":"2019-01-15T13:40:03.616451-05:00","Action":"output","Package":"debug/golang/subtest","Test":"TestThis/topLevelTest/subA","Output":"        some_test.go:14: woah, something went wrong\n"}

This might be an issue with test2json.

@mfridman mfridman changed the title testing: unexpected outer test output belonging to a subtest testing: unexpected top level test output belonging to a subtest Jan 15, 2019

@bcmills

This comment has been minimized.

Copy link
Member

bcmills commented Jan 29, 2019

CC @mpvl @josharian

As far as I can tell the intentation looks right. I suspect a test2json bug.

@bcmills bcmills added this to the Go1.13 milestone Jan 29, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment