Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2825)

Unified Diff: base/test/test_suite.cc

Issue 2638763004: Report CHECK/DCHECK to test launcher summary output. (Closed)
Patch Set: Fix formatting & function signature. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/test/test_suite.cc
diff --git a/base/test/test_suite.cc b/base/test/test_suite.cc
index 6f4cc372cb86ad73f9388740e5a9f0c05652cc88..47713b4f84d2735e6a51370fc1b9a933202303a0 100644
--- a/base/test/test_suite.cc
+++ b/base/test/test_suite.cc
@@ -238,11 +238,11 @@ void TestSuite::AddTestLauncherResultPrinter() {
return;
}
- XmlUnitTestResultPrinter* printer = new XmlUnitTestResultPrinter;
- CHECK(printer->Initialize(output_path));
+ printer_ = new XmlUnitTestResultPrinter;
+ CHECK(printer_->Initialize(output_path));
testing::TestEventListeners& listeners =
testing::UnitTest::GetInstance()->listeners();
- listeners.Append(printer);
+ listeners.Append(printer_);
}
// Don't add additional code to this method. Instead add it to
@@ -283,7 +283,10 @@ int TestSuite::Run() {
}
// static
-void TestSuite::UnitTestAssertHandler(const std::string& str) {
+void TestSuite::UnitTestAssertHandler(const char* file,
+ int line,
+ const std::string& summary,
+ const std::string& stack_trace) {
#if defined(OS_ANDROID)
// Correlating test stdio with logcat can be difficult, so we emit this
// helpful little hint about what was running. Only do this for Android
@@ -298,6 +301,8 @@ void TestSuite::UnitTestAssertHandler(const std::string& str) {
}
#endif // defined(OS_ANDROID)
+ printer_->OnAssert(file, line, summary, summary + stack_trace);
+
// The logging system actually prints the message before calling the assert
// handler. Just exit now to avoid printing too many stack traces.
_exit(1);
@@ -359,7 +364,8 @@ void TestSuite::Initialize() {
!CommandLine::ForCurrentProcess()->HasSwitch("show-error-dialogs")) {
SuppressErrorDialogs();
debug::SetSuppressDebugUI(true);
- logging::SetLogAssertHandler(UnitTestAssertHandler);
+ assert_handler_ = logging::ScopedLogAssertHandler(
+ base::Bind(&TestSuite::UnitTestAssertHandler, base::Unretained(this)));
}
base::test::InitializeICUForTesting();
« base/logging.cc ('K') | « base/test/test_suite.h ('k') | chrome/common/logging_chrome.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698