exercism / go-test-runner

GNU Affero General Public License v3.0
15 stars 17 forks source link

Update test runner to Go 1.22 #113

Closed andrerfcsantos closed 1 month ago

andrerfcsantos commented 1 month ago

Summary

This PR updates the test runner to use Go 1.22.

Go 1.22 introduces some changes to the test output, and the changes in the code of this PR accommodate for that.

Details

The main difference in the test output is that previously when a test would fail due to an error in compilation of the test, the go test command would produce a textual output without any json lines, despite the tests being run with the --json flag. Now the go test command respects the --json flag, even when the test doesn't compile, and some lines of the output are json lines.

Go 1.22 vs Go 1.21 go test --json output differences
$ go1.22.5 test -v --json
# gigasecond [gigasecond.test]
./missing_func_test.go:39:11: undefined: AddGigasecond
./missing_func_test.go:72:11: undefined: AddGigasecond
{"Time":"2024-07-22T10:30:50.345109+01:00","Action":"start","Package":"gigasecond"}
{"Time":"2024-07-22T10:30:50.34516+01:00","Action":"output","Package":"gigasecond","Output":"FAIL\tgigasecond [build failed]\n"}
{"Time":"2024-07-22T10:30:50.345165+01:00","Action":"fail","Package":"gigasecond","Elapsed":0}
$ go1.21.12 test -v --json
# gigasecond [gigasecond.test]
./missing_func_test.go:39:11: undefined: AddGigasecond
./missing_func_test.go:72:11: undefined: AddGigasecond
FAIL    gigasecond [build failed]

Previously, the test runner was ignoring any json lines in the test output when the tests failed to compile. Now it doesn't ignore them, and includes some information of them in the test report.

Complete list of changes