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

Swap to go-junit-report for parsing go test output #982

Merged
merged 4 commits into from
Jun 4, 2020
Merged

Swap to go-junit-report for parsing go test output #982

merged 4 commits into from
Jun 4, 2020

Conversation

bli-0
Copy link
Contributor

@bli-0 bli-0 commented Jun 4, 2020

Swap to using a 3rd party library for parsing Go test output.

This should cover more edge cases than our previous simple parser.

An additional note - by reading various PRs in go-junit-report around the different edge cases in Go test output. I've found that go test has a json output which should be used for parsing tasks like we're doing. However there's discussions on the go-junit-report repo which suggest that there aren't much gains to be had just yet by using the go test json output.

Also the json option only exists for Go 1.10+. I think the best thing to do going forwards is to revisit this if we officially stop support Go versions < 1.10, to see if we hit any more edge cases that would be solved by using a json format parser.

@@ -169,11 +169,6 @@ func TestGoIgnoreUnknownOutput(t *testing.T) {
assert.Equal(t, 0, results.Skips())
}

func TestGoFailIfUnknownTestPasses(t *testing.T) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how often we expect this particular case to come up. Go Junit report doesn't error out in this scenario - but it does 'misattribute' a failure to a Test case, so I'm not sure it's 100% correct in that regard.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That dates back to literally before the dawn of time (initial commit). I don't think I've ever seen it actually happen though; not terribly bothered about losing this one case if everything else is still passing.

Copy link
Collaborator

@peterebden peterebden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks good! Always nice to have less code to maintain ourselves :)

testPackage, err := parser.Parse(bytes.NewReader(data), "")

if err != nil {
return core.TestSuite{}, fmt.Errorf("Failed to parser go test output: %w", err)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Failed to parser -> Failed to parse

@peterebden peterebden merged commit 13adc19 into thought-machine:master Jun 4, 2020
@peterebden
Copy link
Collaborator

Also the json option only exists for Go 1.10+. I think the best thing to do going forwards is to revisit this if we officially stop support Go versions < 1.10, to see if we hit any more edge cases that would be solved by using a json format parser.

I doubt anyone deeply cares about the older versions; we support I think 1.8+ (https://golang.org/pkg/testing/#MainStart is probably the most critical thing there) but I don't imagine lots of people deeply care about building 1.8 or 1.9 with the latest version of plz.

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

Successfully merging this pull request may close these issues.

2 participants