Testing: an exception that escapes a test fails it
execute_test and execute_test_parallel set Failed when the body threw, then recomputed the state from the recorded assertions alone, so a test whose body threw before any failed assertion was reported as passed. The state now stays Failed when an unhandled exception was recorded. Found by a Void Engine test that threw on its first line and passed; it hid two failing engine tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
cd237207d4
commit
5464e9fa35
1 file changed
+10
-2
+10
-2
@@ -221,7 +221,11 @@ namespace Void::Testing
|
||||
bool any = std::any_of(
|
||||
result.assertions.begin(), result.assertions.end(),
|
||||
[](const auto& a) { return !a.passed; });
|
||||
result.state = any ? TestState::Failed : TestState::Passed;
|
||||
// An exception that escaped the body fails it too, with no failed
|
||||
// assertion recorded.
|
||||
const bool unhandled = !result.crash_info.empty();
|
||||
result.state =
|
||||
any || unhandled ? TestState::Failed : TestState::Passed;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -268,7 +272,11 @@ namespace Void::Testing
|
||||
bool any = std::any_of(
|
||||
result.assertions.begin(), result.assertions.end(),
|
||||
[](const auto& a) { return !a.passed; });
|
||||
result.state = any ? TestState::Failed : TestState::Passed;
|
||||
// An exception that escaped the body fails it too, with no failed
|
||||
// assertion recorded.
|
||||
const bool unhandled = !result.crash_info.empty();
|
||||
result.state =
|
||||
any || unhandled ? TestState::Failed : TestState::Passed;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user