slsa-github-generator icon indicating copy to clipboard operation
slsa-github-generator copied to clipboard

[bug] Tests exit successfully even if unit tests fail

Open ianlewis opened this issue 3 years ago • 4 comments
trafficstars

Describe the bug The golang builder makes an Exec syscall directly. This causes tests that call GoBuild.Run to cause the test runner to exit prematurely as the original test runner's process context is overwritten.

Currently, even if tests fail the process executed Exec syscall returns successfully so no error code is returned and go test exits successfully. This masks unit test errors and is highly unintuitive.

To Reproduce Create a failing test and run go test -v ./...

ianlewis avatar Aug 29 '22 07:08 ianlewis

great catch! Do you know if there's a way to force running the tests each in their own process?

laurentsimon avatar Aug 29 '22 16:08 laurentsimon

I don't know if there is really unless we start our own separate processes. I think the real thing we should do is refactor the Go builder to fork/exec instead as that is generally much more intuitive.

ianlewis avatar Aug 30 '22 02:08 ianlewis

SG. You have a PR about this, let me know when you need review. Fyi, your PR will also be very useful for the npm builder because it requires running multiple commands. So I'm happy to help getting this PR through :)

laurentsimon avatar Aug 30 '22 02:08 laurentsimon

Ah, yes #632 is related. Perhaps I'll take that off the back burner soon as that would be the proper solution.

#772 disables the offending test and will at least allow us to catch failing tests in the meantime.

ianlewis avatar Aug 30 '22 02:08 ianlewis