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

cmd/test2json: bad parsing of subtest names with quotes leads to bad "run" events #27582

Closed
andreimatei opened this issue Sep 9, 2018 · 4 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@andreimatei
Copy link
Contributor

With this test:

func TestXXX(t *testing.T) {
	for _, name := range []string{`"a"`, `"b"`} {
		t.Run(fmt.Sprintf("foo:%s", name), func(t *testing.T) {
		})
	}
}

If the output is piped to go tool test2json, the output starts with:

{"Action":"run","Test":"TestXXX"}
{"Action":"output","Test":"TestXXX","Output":"=== RUN   TestXXX\n"}
{"Action":"run   testxxx/foo","Test":"\"a\""}
{"Action":"output","Test":"\"a\"","Output":"=== RUN   TestXXX/foo:\"a\"\n"}
{"Action":"run   testxxx/foo","Test":"\"b\""}

Notice the bad action (run testxxx/foo) and test name.

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

go version go1.10 darwin/amd64

Does this issue reproduce with the latest release?

Have not tried.

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

OSX.

@ALTree ALTree added this to the Go1.12 milestone Sep 9, 2018
@ALTree ALTree added the NeedsFix The path to resolution is known, but the work has not been done. label Sep 9, 2018
@ALTree
Copy link
Member

ALTree commented Sep 9, 2018

Actually on tip I get:

{"Action":"run","Test":"TestXXX"}
{"Action":"output","Test":"TestXXX","Output":"=== RUN   TestXXX\n"}
{"Action":"run","Test":"TestXXX/foo:\"a\""}
{"Action":"output","Test":"TestXXX/foo:\"a\"","Output":"=== RUN   TestXXX/foo:\"a\"\n"}
{"Action":"run","Test":"TestXXX/foo:\"b\""}
{"Action":"output","Test":"TestXXX/foo:\"b\"","Output":"=== RUN   TestXXX/foo:\"b\"\n"}
{"Action":"output","Test":"TestXXX","Output":"--- PASS: TestXXX (0.00s)\n"}
{"Action":"output","Test":"TestXXX/foo:\"a\"","Output":"    --- PASS: TestXXX/foo:\"a\" (0.00s)\n"}
{"Action":"pass","Test":"TestXXX/foo:\"a\""}
{"Action":"output","Test":"TestXXX/foo:\"b\"","Output":"    --- PASS: TestXXX/foo:\"b\" (0.00s)\n"}
{"Action":"pass","Test":"TestXXX/foo:\"b\""}
{"Action":"pass","Test":"TestXXX"}
{"Action":"output","Output":"PASS\n"}
{"Action":"output","Output":"ok  \tcommand-line-arguments\t(cached)\n"}
{"Action":"pass"}

@mvdan
Copy link
Member

mvdan commented Sep 9, 2018

@andreimatei have you tried using Go 1.11?

@andreimatei
Copy link
Contributor Author

I had not tried it. I tried go1.11 now and indeed it seems to work (@ALTree you originally said 1.11 didn't work for you and now you say tip does, but it seems to you too that 1.11 work too, right? As in, I'm not fooling myself).
I should have tried go1.11 before, sorry about that
Feel free to close as far as I'm concerned if there's nothing to backport.

@ALTree
Copy link
Member

ALTree commented Sep 10, 2018

(@ALTree you originally said 1.11 didn't work for you and now you say tip does, but it seems to you too that 1.11 work too, right? As in, I'm not fooling myself

Yes, sorry. The first time I actually used the wrong toolchain and I mistakenly concluded the bug was in 1.11 too.

Feel free to close as far as I'm concerned if there's nothing to backport.

Closing here, then.

@ALTree ALTree closed this as completed Sep 10, 2018
@golang golang locked and limited conversation to collaborators Sep 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

4 participants