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

Unified Diff: base/test/test_launcher.cc

Issue 23506031: Fix a test launcher hang when no tests are run. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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
« no previous file with comments | « base/test/parallel_test_launcher.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/test/test_launcher.cc
diff --git a/base/test/test_launcher.cc b/base/test/test_launcher.cc
index d0808942ae83e4b8559313467bfa3c4ed5ae9e77..b131506b026bc658b02edeaba95bec4388a31df6 100644
--- a/base/test/test_launcher.cc
+++ b/base/test/test_launcher.cc
@@ -121,6 +121,10 @@ class ResultsPrinter {
// Called when test named |name| is scheduled to be started.
void OnTestStarted(const std::string& name);
+ // Called when all tests that were to be started have been scheduled
+ // to be started.
+ void OnAllTestsStarted();
+
// Adds |result| to the stored test results.
void AddTestResult(const TestResult& result);
@@ -228,6 +232,18 @@ void ResultsPrinter::OnTestStarted(const std::string& name) {
++test_started_count_;
}
+void ResultsPrinter::OnAllTestsStarted() {
+ if (test_started_count_ == 0) {
+ fprintf(stdout, "0 tests run\n");
Ken Russell (switch to Gerrit) 2013/09/04 18:00:30 Did you mean to leave this printf in here?
Paweł Hajdan Jr. 2013/09/04 18:02:30 Yes - it corresponds to "x tests run" below and ex
+ fflush(stdout);
+
+ // No tests have actually been started, so fire the callback
+ // to avoid a hang.
+ callback_.Run(true);
+ delete this;
+ }
+}
+
void ResultsPrinter::AddTestResult(const TestResult& result) {
DCHECK(thread_checker_.CalledOnValidThread());
@@ -405,6 +421,10 @@ void RunTests(TestLauncherDelegate* launcher_delegate,
FROM_HERE,
Bind(&TestLauncherDelegate::RunRemainingTests,
Unretained(launcher_delegate)));
+
+ MessageLoop::current()->PostTask(
+ FROM_HERE,
+ Bind(&ResultsPrinter::OnAllTestsStarted, Unretained(printer)));
}
void RunTestIteration(TestLauncherDelegate* launcher_delegate,
« no previous file with comments | « base/test/parallel_test_launcher.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698