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: colon in test name breaks JSON #24974

Closed
zolotov opened this issue Apr 20, 2018 · 1 comment
Closed

cmd/test2json: colon in test name breaks JSON #24974

zolotov opened this issue Apr 20, 2018 · 1 comment
Labels
FrozenDueToAge help wanted NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@zolotov
Copy link
Contributor

zolotov commented Apr 20, 2018

go version go1.10 linux/amd64

Initial bug report: https://youtrack.jetbrains.com/issue/GO-5589

Given a test file:

package my_test

import (
	"testing"
	"fmt"
)

func TestHello(t *testing.T) {
	testCases := []struct {
		tType string
	}{

		{
			tType: "1",
		},

		{
			tType: "2",
		},
	}

	for _, tc := range testCases {
		t.Run(fmt.Sprintf("Test running: %s\n", tc.tType), func(t *testing.T) {
			fmt.Println("Test")
		})
	}
}

Run it with -json parameter.

Expected output:

{"Time":"2018-04-20T20:16:22.638761309+03:00","Action":"run","Package":"command-line-arguments","Test":"TestHello"}
{"Time":"2018-04-20T20:16:22.638873428+03:00","Action":"output","Package":"command-line-arguments","Test":"TestHello","Output":"=== RUN   TestHello\n"}
{"Time":"2018-04-20T20:16:22.638882163+03:00","Action":"run","Package":"command-line-arguments","Test":"TestHello/Test_running:_1_"}
{"Time":"2018-04-20T20:16:22.638886907+03:00","Action":"output","Package":"command-line-arguments","Test":"TestHello/Test_running:_1_","Output":"=== RUN   TestHello/Test_running:_1_\n"}
{"Time":"2018-04-20T20:16:22.638892041+03:00","Action":"output","Package":"command-line-arguments","Test":"TestHello/Test_running:_1_","Output":"Test\n"}
{"Time":"2018-04-20T20:16:22.638896226+03:00","Action":"run","Package":"command-line-arguments","Test":"TestHello/Test_running:_2_"}
{"Time":"2018-04-20T20:16:22.63889915+03:00","Action":"output","Package":"command-line-arguments","Test":"TestHello/Test_running:_2_","Output":"=== RUN   TestHello/Test_running:_2_\n"}
{"Time":"2018-04-20T20:16:22.638902623+03:00","Action":"output","Package":"command-line-arguments","Test":"TestHello/Test_running:_2_","Output":"Test\n"}
{"Time":"2018-04-20T20:16:22.638908441+03:00","Action":"output","Package":"command-line-arguments","Test":"TestHello","Output":"--- PASS: TestHello (0.00s)\n"}
{"Time":"2018-04-20T20:16:22.638912874+03:00","Action":"output","Package":"command-line-arguments","Test":"TestHello/Test_running:_1_","Output":"    --- PASS: TestHello/Test_running:_1_ (0.00s)\n"}
{"Time":"2018-04-20T20:16:22.63891675+03:00","Action":"pass","Package":"command-line-arguments","Test":"TestHello/Test_running:_1_","Elapsed":0}
{"Time":"2018-04-20T20:16:22.63892361+03:00","Action":"output","Package":"command-line-arguments","Test":"TestHello/Test_running:_2_","Output":"    --- PASS: TestHello/Test_running:_2_ (0.00s)\n"}
{"Time":"2018-04-20T20:16:22.638930025+03:00","Action":"pass","Package":"command-line-arguments","Test":"TestHello/Test_running:_2_","Elapsed":0}
{"Time":"2018-04-20T20:16:22.638934151+03:00","Action":"pass","Package":"command-line-arguments","Test":"TestHello","Elapsed":0}
{"Time":"2018-04-20T20:16:22.638937701+03:00","Action":"output","Package":"command-line-arguments","Output":"PASS\n"}
{"Time":"2018-04-20T20:16:22.638957862+03:00","Action":"output","Package":"command-line-arguments","Output":"ok  \tcommand-line-arguments\t0.001s\n"}
{"Time":"2018-04-20T20:16:22.639187148+03:00","Action":"pass","Package":"command-line-arguments","Elapsed":0.001}

Actual output:

{"Time":"2018-04-20T20:16:01.004893526+03:00","Action":"run","Package":"command-line-arguments","Test":"TestHello"}
{"Time":"2018-04-20T20:16:01.004995034+03:00","Action":"output","Package":"command-line-arguments","Test":"TestHello","Output":"=== RUN   TestHello\n"}
{"Time":"2018-04-20T20:16:01.005003725+03:00","Action":"run   testhello/test_running","Package":"command-line-arguments","Test":"_1_"}
{"Time":"2018-04-20T20:16:01.005009167+03:00","Action":"output","Package":"command-line-arguments","Test":"_1_","Output":"=== RUN   TestHello/Test_running:_1_\n"}
{"Time":"2018-04-20T20:16:01.005016144+03:00","Action":"output","Package":"command-line-arguments","Test":"_1_","Output":"Test\n"}
{"Time":"2018-04-20T20:16:01.005021323+03:00","Action":"run   testhello/test_running","Package":"command-line-arguments","Test":"_2_"}
{"Time":"2018-04-20T20:16:01.005025563+03:00","Action":"output","Package":"command-line-arguments","Test":"_2_","Output":"=== RUN   TestHello/Test_running:_2_\n"}
{"Time":"2018-04-20T20:16:01.005030331+03:00","Action":"output","Package":"command-line-arguments","Test":"_2_","Output":"Test\n"}
{"Time":"2018-04-20T20:16:01.005036985+03:00","Action":"output","Package":"command-line-arguments","Test":"TestHello","Output":"--- PASS: TestHello (0.00s)\n"}
{"Time":"2018-04-20T20:16:01.005042738+03:00","Action":"output","Package":"command-line-arguments","Test":"TestHello/Test_running:_1_","Output":"    --- PASS: TestHello/Test_running:_1_ (0.00s)\n"}
{"Time":"2018-04-20T20:16:01.005047803+03:00","Action":"pass","Package":"command-line-arguments","Test":"TestHello/Test_running:_1_","Elapsed":0}
{"Time":"2018-04-20T20:16:01.005054281+03:00","Action":"output","Package":"command-line-arguments","Test":"TestHello/Test_running:_2_","Output":"    --- PASS: TestHello/Test_running:_2_ (0.00s)\n"}
{"Time":"2018-04-20T20:16:01.005058741+03:00","Action":"pass","Package":"command-line-arguments","Test":"TestHello/Test_running:_2_","Elapsed":0}
{"Time":"2018-04-20T20:16:01.005062809+03:00","Action":"pass","Package":"command-line-arguments","Test":"TestHello","Elapsed":0}
{"Time":"2018-04-20T20:16:01.005067007+03:00","Action":"output","Package":"command-line-arguments","Output":"PASS\n"}
{"Time":"2018-04-20T20:16:01.005071381+03:00","Action":"output","Package":"command-line-arguments","Output":"ok  \tcommand-line-arguments\t(cached)\n"}
{"Time":"2018-04-20T20:16:01.005079909+03:00","Action":"pass","Package":"command-line-arguments","Elapsed":0}
@bradfitz bradfitz added the NeedsFix The path to resolution is known, but the work has not been done. label Apr 20, 2018
@bradfitz bradfitz added this to the Go1.11 milestone Apr 20, 2018
@ALTree
Copy link
Member

ALTree commented Apr 20, 2018

This is #23920 and it's fixed on tip (to be Go1.11).

@ALTree ALTree closed this as completed Apr 20, 2018
@golang golang locked and limited conversation to collaborators Apr 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge help wanted 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