mirror of
https://github.com/google/googletest.git
synced 2026-06-15 08:26:11 +08:00
Merge 1a4b486758335cd1f367125e3005ff23c366d748 into 7140cd416cecd7462a8aae488024abeee55598e4
This commit is contained in:
commit
dd91550a93
@ -4,7 +4,7 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
project(googletest-distribution)
|
||||
set(GOOGLETEST_VERSION 1.16.0)
|
||||
set(GOOGLETEST_VERSION 1.17.0)
|
||||
|
||||
if(NOT CYGWIN AND NOT MSYS AND NOT ${CMAKE_SYSTEM_NAME} STREQUAL QNX)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
|
||||
@ -822,6 +822,10 @@ class GTEST_API_ UnitTestImpl {
|
||||
// UnitTest::Run() starts.
|
||||
bool catch_exceptions() const { return catch_exceptions_; }
|
||||
|
||||
const std::vector<TestPartResult>& global_env_failures() const {
|
||||
return global_env_failures_;
|
||||
}
|
||||
|
||||
private:
|
||||
// Returns true if a warning should be issued if no tests match the test
|
||||
// filter flag.
|
||||
@ -966,6 +970,9 @@ class GTEST_API_ UnitTestImpl {
|
||||
// A per-thread stack of traces created by the SCOPED_TRACE() macro.
|
||||
internal::ThreadLocal<std::vector<TraceInfo> > gtest_trace_stack_;
|
||||
|
||||
// Stores failures that occur in global environment setup/teardown.
|
||||
std::vector<TestPartResult> global_env_failures_;
|
||||
|
||||
// The value of GTEST_FLAG(catch_exceptions) at the moment RunAllTests()
|
||||
// starts.
|
||||
bool catch_exceptions_;
|
||||
|
||||
@ -1096,8 +1096,11 @@ DefaultGlobalTestPartResultReporter::DefaultGlobalTestPartResultReporter(
|
||||
|
||||
void DefaultGlobalTestPartResultReporter::ReportTestPartResult(
|
||||
const TestPartResult& result) {
|
||||
if (unit_test_->current_test_info() == nullptr) {
|
||||
unit_test_->global_env_failures_.push_back(result);
|
||||
return;
|
||||
}
|
||||
unit_test_->current_test_result()->AddTestPartResult(result);
|
||||
unit_test_->listeners()->repeater()->OnTestPartResult(result);
|
||||
}
|
||||
|
||||
DefaultPerThreadTestPartResultReporter::DefaultPerThreadTestPartResultReporter(
|
||||
@ -1106,7 +1109,11 @@ DefaultPerThreadTestPartResultReporter::DefaultPerThreadTestPartResultReporter(
|
||||
|
||||
void DefaultPerThreadTestPartResultReporter::ReportTestPartResult(
|
||||
const TestPartResult& result) {
|
||||
unit_test_->GetGlobalTestPartResultReporter()->ReportTestPartResult(result);
|
||||
if (unit_test_->current_test_info() == nullptr) {
|
||||
unit_test_->global_env_failures_.push_back(result);
|
||||
return;
|
||||
}
|
||||
unit_test_->current_test_result()->AddTestPartResult(result);
|
||||
}
|
||||
|
||||
// Returns the global test part result reporter.
|
||||
@ -4505,6 +4512,17 @@ void XmlUnitTestResultPrinter::PrintXmlTestsList(
|
||||
for (auto test_suite : test_suites) {
|
||||
PrintXmlTestSuite(stream, *test_suite);
|
||||
}
|
||||
if (!GetUnitTestImpl()->global_env_failures().empty()) {
|
||||
*stream << " <global_environment_errors>\n";
|
||||
for (const auto& failure : GetUnitTestImpl()->global_env_failures()) {
|
||||
*stream << " <failure message=\""
|
||||
<< EscapeXmlAttribute(failure.message())
|
||||
<< "\"><![CDATA["
|
||||
<< failure.message()
|
||||
<< "]]></failure>\n";
|
||||
}
|
||||
*stream << " </global_environment_errors>\n";
|
||||
}
|
||||
*stream << "</" << kTestsuites << ">\n";
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user