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: introduce continuation flag for splited output events #36059

Open
zolotov opened this issue Dec 9, 2019 · 1 comment
Open

cmd/test2json: introduce continuation flag for splited output events #36059

zolotov opened this issue Dec 9, 2019 · 1 comment
Milestone

Comments

@zolotov
Copy link
Contributor

@zolotov zolotov commented Dec 9, 2019

test2json tool splits long lines into several with src/cmd/internal/test2json/test2json.go#outBuffer limit.

E.g. the output for the following program

package main

import (
	"testing"
)

func Test1(t *testing.T) {
	const expected = "{\\n  \"data\": [\\n    {\\n      \"data\": [\\n        \\n      ],\\n      \"event\": \"sign_up\",\\n      \"search\":{}\\n    },\\n    {\\n      \"data\": [\\n\\n      \\n      ],\\n      \"event\": \"subscribe\",\\n      \"search\": {}\\n    },\\n    {\\n      \"data\": [\\n        {\\n          \"ads_stats\": [],\\n          \"count\": 1,\\n          \"group_value\": \"\",\\n          \"rate\": 0.2,\\n          \"total\": 5\\n        },\\n        {\\n          \"ads_stats\": [],\\n          \"count\": 1,\\n          \"group_value\": \"green\",\\n          \"rate\": 0.2,\\n          \"total\": 5\\n        },\\n        {\\n          \"ads_stats\": [],\\n          \"count\": 1,\\n          \"group_value\": \"orange\",\\n          \"rate\": 0.2,\\n          \"total\": 5\\n        },\\n        {\\n          \"ads_stats\": [],\\n          \"count\": 2,\\n          \"group_value\": \"red\",\\n          \"rate\": 0.4,\\n          \"total\": 5\\n        }\\n      ],\\n      \"event\": \"pageview\",\\n      \"search\": {}\\n    }\\n  ],\\n  \"meta\": {\\n    \"shortlist\": true,\\n    \"source\": \"visitor_data\",\\n    \"total\": 4\\n  },\\n  \"search\": {}\\n}"
	t.Log(expected)
}

contains two Output events:

{"Time":"2019-12-09T19:27:08.985242+01:00","Action":"run","Test":"Test1"}
{"Time":"2019-12-09T19:27:08.986919+01:00","Action":"output","Test":"Test1","Output":"=== RUN   Test1\n"}
{"Time":"2019-12-09T19:27:08.987393+01:00","Action":"output","Test":"Test1","Output":"--- PASS: Test1 (0.00s)\n"}
{"Time":"2019-12-09T19:27:08.987414+01:00","Action":"output","Test":"Test1","Output":"    stepper_test.go:9: {\\n  \"data\": [\\n    {\\n      \"data\": [\\n        \\n      ],\\n      \"event\": \"sign_up\",\\n      \"search\":{}\\n    },\\n    {\\n      \"data\": [\\n\\n      \\n      ],\\n      \"event\": \"subscribe\",\\n      \"search\": {}\\n    },\\n    {\\n      \"data\": [\\n        {\\n          \"ads_stats\": [],\\n          \"count\": 1,\\n          \"group_value\": \"\",\\n          \"rate\": 0.2,\\n          \"total\": 5\\n        },\\n        {\\n          \"ads_stats\": [],\\n          \"count\": 1,\\n          \"group_value\": \"green\",\\n          \"rate\": 0.2,\\n          \"total\": 5\\n        },\\n        {\\n          \"ads_stats\": [],\\n          \"count\": 1,\\n          \"group_value\": \"orange\",\\n          \"rate\": 0.2,\\n          \"total\": 5\\n        },\\n        {\\n          \"ads_stats\": [],\\n          \"count\": 2,\\n          \"group_value\": \"red\",\\n          \"rate\": 0.4,\\n          \"total\": 5\\n        }\\n      ],\\n      \"event\": \"pageview\",\\n      \"search\": {}\\n    }\\n  ],\\n  \"meta\": {\\n    \"shortlist\": true,\\n    \"source\": \"visitor_data\",\\n    \"total"}
{"Time":"2019-12-09T19:27:08.987484+01:00","Action":"output","Test":"Test1","Output":"\": 4\\n  },\\n  \"search\": {}\\n}\n"}
{"Time":"2019-12-09T19:27:08.987494+01:00","Action":"pass","Test":"Test1","Elapsed":0}
{"Time":"2019-12-09T19:27:08.987562+01:00","Action":"output","Output":"PASS\n"}
{"Time":"2019-12-09T19:27:08.98759+01:00","Action":"pass","Elapsed":0.341}

If an external tool wants to parse the output somehow, it has no chance to know that the second event is a continuation of the first one.
It would be nice to have a special event flag that could tell an external tool about it. The same Time or another identification flag for split events also could help.

The real usecase: https://youtrack.jetbrains.com/issue/GO-8141

@toothrot toothrot added this to the Backlog milestone Dec 9, 2019
@toothrot
Copy link
Contributor

@toothrot toothrot commented Dec 9, 2019

/cc @rsc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.