Return error when rspec exits with non-zero but no failure#436
Return error when rspec exits with non-zero but no failure#436
rspec exits with non-zero but no failure#436Conversation
c066961 to
9fd6566
Compare
9fd6566 to
d572914
Compare
internal/runner/rspec.go
Outdated
| } | ||
|
|
||
| if exitError := new(exec.ExitError); errors.As(err, &exitError) { | ||
| if report.Summary.FailureCount == 0 && report.Summary.ErrorsOutsideOfExamplesCount == 0 { |
There was a problem hiding this comment.
Is there a way we can invert the logic here? We have if ExitError and some inclusion condition and I think this would be a lot better as if ExitError and not some exclusion condition. I.e. change this to "any failure status from the runner is considered an error except for when we explicitly allow it".
This change is good but it leaves us in a similar situation to where we are now, where any unexpected failure state is a pass by default.
There was a problem hiding this comment.
Fair point. But it's more complicated than that. We don't return error from this function when RSpec succesfully run and finished because we want to print the result at the end of the run. Instead, we build a RunResult from the test runner json output, that decided whether bktec will exit with 0 or 1.
I can revert the logic, but we can't simply make "any unexpected failure state is a failed by default", unless we are okay with skipping report printing by default.
There was a problem hiding this comment.
I've updated the logic, let me know what you think.
Description
There’s a scenario where
rspecexits with a non-zero code but no test failures or errors are reported. This can occur if there’s an explicitexitcall in the source code that isn’t caught within the specs (as shown in the example below). Since no failures are reported,bktectreats it as a “pass”. In this case we should return an error frombktec.