Makes gtest report failures in ad hoc test assertions executed before RUN_ALL_TESTS().

This commit is contained in:
zhanyong.wan
2010-06-16 22:47:13 +00:00
parent 985a30360c
commit 682c89f755
4 changed files with 21 additions and 7 deletions

View File

@@ -754,9 +754,13 @@ class GTEST_API_ UnitTestImpl {
// doesn't apply there.)
int RunAllTests();
// Clears the results of all tests, including the ad hoc test.
void ClearResult() {
// Clears the results of all tests, except the ad hoc tests.
void ClearNonAdHocTestResult() {
ForEach(test_cases_, TestCase::ClearTestCaseResult);
}
// Clears the results of ad-hoc test assertions.
void ClearAdHocTestResult() {
ad_hoc_test_result_.Clear();
}

View File

@@ -3999,7 +3999,9 @@ int UnitTestImpl::RunAllTests() {
// Repeats forever if the repeat count is negative.
const bool forever = repeat < 0;
for (int i = 0; forever || i != repeat; i++) {
ClearResult();
// We want to preserve failures generated by ad-hoc test
// assertions executed before RUN_ALL_TESTS().
ClearNonAdHocTestResult();
const TimeInMillis start = GetTimeInMillis();