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

Side by Side Diff: base/test/launcher/unit_test_launcher.cc

Issue 895853003: Update from https://crrev.com/314320 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 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 unified diff | Download patch
« no previous file with comments | « base/test/launcher/unit_test_launcher.h ('k') | base/test/multiprocess_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/test/launcher/unit_test_launcher.h" 5 #include "base/test/launcher/unit_test_launcher.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 JoinString(test_names, ":")); 114 JoinString(test_names, ":"));
115 new_cmd_line.AppendSwitch(kSingleProcessTestsFlag); 115 new_cmd_line.AppendSwitch(kSingleProcessTestsFlag);
116 116
117 return new_cmd_line; 117 return new_cmd_line;
118 } 118 }
119 119
120 std::string GetWrapperForChildGTestProcess() override { 120 std::string GetWrapperForChildGTestProcess() override {
121 return std::string(); 121 return std::string();
122 } 122 }
123 123
124 void RelaunchTests(TestLauncher* test_launcher,
125 const std::vector<std::string>& test_names,
126 int launch_flags) override {
127 // Relaunch requested tests in parallel, but only use single
128 // test per batch for more precise results (crashes, etc).
129 for (const std::string& test_name : test_names) {
130 std::vector<std::string> batch;
131 batch.push_back(test_name);
132 RunUnitTestsBatch(test_launcher, this, batch, launch_flags);
133 }
134 }
135
124 DISALLOW_COPY_AND_ASSIGN(DefaultUnitTestPlatformDelegate); 136 DISALLOW_COPY_AND_ASSIGN(DefaultUnitTestPlatformDelegate);
125 }; 137 };
126 138
127 bool GetSwitchValueAsInt(const std::string& switch_name, int* result) { 139 bool GetSwitchValueAsInt(const std::string& switch_name, int* result) {
128 if (!CommandLine::ForCurrentProcess()->HasSwitch(switch_name)) 140 if (!CommandLine::ForCurrentProcess()->HasSwitch(switch_name))
129 return true; 141 return true;
130 142
131 std::string switch_value = 143 std::string switch_value =
132 CommandLine::ForCurrentProcess()->GetSwitchValueASCII(switch_name); 144 CommandLine::ForCurrentProcess()->GetSwitchValueASCII(switch_name);
133 if (!StringToInt(switch_value, result) || *result < 1) { 145 if (!StringToInt(switch_value, result) || *result < 1) {
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 void InitGoogleTestChar(int* argc, char** argv) { 221 void InitGoogleTestChar(int* argc, char** argv) {
210 testing::InitGoogleTest(argc, argv); 222 testing::InitGoogleTest(argc, argv);
211 } 223 }
212 224
213 #if defined(OS_WIN) 225 #if defined(OS_WIN)
214 void InitGoogleTestWChar(int* argc, wchar_t** argv) { 226 void InitGoogleTestWChar(int* argc, wchar_t** argv) {
215 testing::InitGoogleTest(argc, argv); 227 testing::InitGoogleTest(argc, argv);
216 } 228 }
217 #endif // defined(OS_WIN) 229 #endif // defined(OS_WIN)
218 230
219 } // namespace 231 // Interprets test results and reports to the test launcher. Returns true
220 232 // on success.
221 int LaunchUnitTests(int argc, 233 bool ProcessTestResults(
222 char** argv,
223 const RunTestSuiteCallback& run_test_suite) {
224 CommandLine::Init(argc, argv);
225 return LaunchUnitTestsInternal(run_test_suite, SysInfo::NumberOfProcessors(),
226 true, Bind(&InitGoogleTestChar, &argc, argv));
227 }
228
229 int LaunchUnitTestsSerially(int argc,
230 char** argv,
231 const RunTestSuiteCallback& run_test_suite) {
232 CommandLine::Init(argc, argv);
233 return LaunchUnitTestsInternal(run_test_suite, 1, true,
234 Bind(&InitGoogleTestChar, &argc, argv));
235 }
236
237 #if defined(OS_WIN)
238 int LaunchUnitTests(int argc,
239 wchar_t** argv,
240 bool use_job_objects,
241 const RunTestSuiteCallback& run_test_suite) {
242 // Windows CommandLine::Init ignores argv anyway.
243 CommandLine::Init(argc, NULL);
244 return LaunchUnitTestsInternal(run_test_suite, SysInfo::NumberOfProcessors(),
245 use_job_objects,
246 Bind(&InitGoogleTestWChar, &argc, argv));
247 }
248 #endif // defined(OS_WIN)
249
250 UnitTestLauncherDelegate::UnitTestLauncherDelegate(
251 UnitTestPlatformDelegate* platform_delegate,
252 size_t batch_limit,
253 bool use_job_objects)
254 : platform_delegate_(platform_delegate),
255 batch_limit_(batch_limit),
256 use_job_objects_(use_job_objects) {
257 }
258
259 UnitTestLauncherDelegate::~UnitTestLauncherDelegate() {
260 DCHECK(thread_checker_.CalledOnValidThread());
261 }
262
263 UnitTestLauncherDelegate::GTestCallbackState::GTestCallbackState() {
264 }
265
266 UnitTestLauncherDelegate::GTestCallbackState::~GTestCallbackState() {
267 }
268
269 bool UnitTestLauncherDelegate::GetTests(std::vector<SplitTestName>* output) {
270 DCHECK(thread_checker_.CalledOnValidThread());
271 return platform_delegate_->GetTests(output);
272 }
273
274 bool UnitTestLauncherDelegate::ShouldRunTest(const std::string& test_case_name,
275 const std::string& test_name) {
276 DCHECK(thread_checker_.CalledOnValidThread());
277
278 // There is no additional logic to disable specific tests.
279 return true;
280 }
281
282 size_t UnitTestLauncherDelegate::RunTests(
283 TestLauncher* test_launcher,
284 const std::vector<std::string>& test_names) {
285 DCHECK(thread_checker_.CalledOnValidThread());
286
287 std::vector<std::string> batch;
288 for (size_t i = 0; i < test_names.size(); i++) {
289 batch.push_back(test_names[i]);
290
291 // Use 0 to indicate unlimited batch size.
292 if (batch.size() >= batch_limit_ && batch_limit_ != 0) {
293 RunBatch(test_launcher, batch);
294 batch.clear();
295 }
296 }
297
298 RunBatch(test_launcher, batch);
299
300 return test_names.size();
301 }
302
303 size_t UnitTestLauncherDelegate::RetryTests(
304 TestLauncher* test_launcher,
305 const std::vector<std::string>& test_names) {
306 MessageLoop::current()->PostTask(
307 FROM_HERE, Bind(&UnitTestLauncherDelegate::RunSerially, Unretained(this),
308 test_launcher, test_names));
309 return test_names.size();
310 }
311
312 void UnitTestLauncherDelegate::RunSerially(
313 TestLauncher* test_launcher,
314 const std::vector<std::string>& test_names) {
315 if (test_names.empty())
316 return;
317
318 std::vector<std::string> new_test_names(test_names);
319 std::string test_name(new_test_names.back());
320 new_test_names.pop_back();
321
322 // Create a dedicated temporary directory to store the xml result data
323 // per run to ensure clean state and make it possible to launch multiple
324 // processes in parallel.
325 base::FilePath output_file;
326 CHECK(platform_delegate_->CreateTemporaryFile(&output_file));
327
328 std::vector<std::string> current_test_names;
329 current_test_names.push_back(test_name);
330 CommandLine cmd_line(platform_delegate_->GetCommandLineForChildGTestProcess(
331 current_test_names, output_file));
332
333 GTestCallbackState callback_state;
334 callback_state.test_launcher = test_launcher;
335 callback_state.test_names = current_test_names;
336 callback_state.output_file = output_file;
337
338 test_launcher->LaunchChildGTestProcess(
339 cmd_line,
340 platform_delegate_->GetWrapperForChildGTestProcess(),
341 TestTimeouts::test_launcher_timeout(),
342 use_job_objects_ ? TestLauncher::USE_JOB_OBJECTS : 0,
343 Bind(&UnitTestLauncherDelegate::SerialGTestCallback, Unretained(this),
344 callback_state, new_test_names));
345 }
346
347 void UnitTestLauncherDelegate::RunBatch(
348 TestLauncher* test_launcher,
349 const std::vector<std::string>& test_names) {
350 DCHECK(thread_checker_.CalledOnValidThread());
351
352 if (test_names.empty())
353 return;
354
355 // Create a dedicated temporary directory to store the xml result data
356 // per run to ensure clean state and make it possible to launch multiple
357 // processes in parallel.
358 base::FilePath output_file;
359 CHECK(platform_delegate_->CreateTemporaryFile(&output_file));
360
361 CommandLine cmd_line(platform_delegate_->GetCommandLineForChildGTestProcess(
362 test_names, output_file));
363
364 // Adjust the timeout depending on how many tests we're running
365 // (note that e.g. the last batch of tests will be smaller).
366 // TODO(phajdan.jr): Consider an adaptive timeout, which can change
367 // depending on how many tests ran and how many remain.
368 // Note: do NOT parse child's stdout to do that, it's known to be
369 // unreliable (e.g. buffering issues can mix up the output).
370 base::TimeDelta timeout =
371 test_names.size() * TestTimeouts::test_launcher_timeout();
372
373 GTestCallbackState callback_state;
374 callback_state.test_launcher = test_launcher;
375 callback_state.test_names = test_names;
376 callback_state.output_file = output_file;
377
378 test_launcher->LaunchChildGTestProcess(
379 cmd_line,
380 platform_delegate_->GetWrapperForChildGTestProcess(),
381 timeout,
382 use_job_objects_ ? TestLauncher::USE_JOB_OBJECTS : 0,
383 Bind(&UnitTestLauncherDelegate::GTestCallback, Unretained(this),
384 callback_state));
385 }
386
387 void UnitTestLauncherDelegate::GTestCallback(
388 const GTestCallbackState& callback_state,
389 int exit_code,
390 const TimeDelta& elapsed_time,
391 bool was_timeout,
392 const std::string& output) {
393 DCHECK(thread_checker_.CalledOnValidThread());
394 std::vector<std::string> tests_to_relaunch;
395 ProcessTestResults(callback_state.test_launcher, callback_state.test_names,
396 callback_state.output_file, output, exit_code, was_timeout,
397 &tests_to_relaunch);
398
399 // Relaunch requested tests in parallel, but only use single
400 // test per batch for more precise results (crashes, test passes
401 // but non-zero exit codes etc).
402 for (size_t i = 0; i < tests_to_relaunch.size(); i++) {
403 std::vector<std::string> batch;
404 batch.push_back(tests_to_relaunch[i]);
405 RunBatch(callback_state.test_launcher, batch);
406 }
407
408 // The temporary file's directory is also temporary.
409 DeleteFile(callback_state.output_file.DirName(), true);
410 }
411
412 void UnitTestLauncherDelegate::SerialGTestCallback(
413 const GTestCallbackState& callback_state,
414 const std::vector<std::string>& test_names,
415 int exit_code,
416 const TimeDelta& elapsed_time,
417 bool was_timeout,
418 const std::string& output) {
419 DCHECK(thread_checker_.CalledOnValidThread());
420 std::vector<std::string> tests_to_relaunch;
421 bool called_any_callbacks =
422 ProcessTestResults(callback_state.test_launcher,
423 callback_state.test_names, callback_state.output_file,
424 output, exit_code, was_timeout, &tests_to_relaunch);
425
426 // There is only one test, there cannot be other tests to relaunch
427 // due to a crash.
428 DCHECK(tests_to_relaunch.empty());
429
430 // There is only one test, we should have called back with its result.
431 DCHECK(called_any_callbacks);
432
433 // The temporary file's directory is also temporary.
434 DeleteFile(callback_state.output_file.DirName(), true);
435
436 MessageLoop::current()->PostTask(
437 FROM_HERE, Bind(&UnitTestLauncherDelegate::RunSerially, Unretained(this),
438 callback_state.test_launcher, test_names));
439 }
440
441 // static
442 bool UnitTestLauncherDelegate::ProcessTestResults(
443 TestLauncher* test_launcher, 234 TestLauncher* test_launcher,
444 const std::vector<std::string>& test_names, 235 const std::vector<std::string>& test_names,
445 const base::FilePath& output_file, 236 const base::FilePath& output_file,
446 const std::string& output, 237 const std::string& output,
447 int exit_code, 238 int exit_code,
448 bool was_timeout, 239 bool was_timeout,
449 std::vector<std::string>* tests_to_relaunch) { 240 std::vector<std::string>* tests_to_relaunch) {
450 std::vector<TestResult> test_results; 241 std::vector<TestResult> test_results;
451 bool crashed = false; 242 bool crashed = false;
452 bool have_test_results = 243 bool have_test_results =
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 for (size_t i = 0; i < final_results.size(); i++) { 307 for (size_t i = 0; i < final_results.size(); i++) {
517 if (final_results[i].status != TestResult::TEST_SUCCESS) { 308 if (final_results[i].status != TestResult::TEST_SUCCESS) {
518 has_non_success_test = true; 309 has_non_success_test = true;
519 break; 310 break;
520 } 311 }
521 } 312 }
522 313
523 if (!has_non_success_test && exit_code != 0) { 314 if (!has_non_success_test && exit_code != 0) {
524 // This is a bit surprising case: all tests are marked as successful, 315 // This is a bit surprising case: all tests are marked as successful,
525 // but the exit code was not zero. This can happen e.g. under memory 316 // but the exit code was not zero. This can happen e.g. under memory
526 // tools that report leaks this way. 317 // tools that report leaks this way. Mark all tests as a failure on exit,
527 318 // and for more precise info they'd need to be retried serially.
528 if (final_results.size() == 1) { 319 for (size_t i = 0; i < final_results.size(); i++)
529 // Easy case. One test only so we know the non-zero exit code 320 final_results[i].status = TestResult::TEST_FAILURE_ON_EXIT;
530 // was caused by that one test.
531 final_results[0].status = TestResult::TEST_FAILURE_ON_EXIT;
532 } else {
533 // Harder case. Discard the results and request relaunching all
534 // tests without batching. This will trigger above branch on
535 // relaunch leading to more precise results.
536 LOG(WARNING) << "Not sure which test caused non-zero exit code, "
537 << "relaunching all of them without batching.";
538
539 for (size_t i = 0; i < final_results.size(); i++)
540 tests_to_relaunch->push_back(final_results[i].full_name);
541
542 return false;
543 }
544 } 321 }
545 322
546 for (size_t i = 0; i < final_results.size(); i++) { 323 for (size_t i = 0; i < final_results.size(); i++) {
547 // Fix the output snippet after possible changes to the test result. 324 // Fix the output snippet after possible changes to the test result.
548 final_results[i].output_snippet = 325 final_results[i].output_snippet =
549 GetTestOutputSnippet(final_results[i], output); 326 GetTestOutputSnippet(final_results[i], output);
550 test_launcher->OnTestFinished(final_results[i]); 327 test_launcher->OnTestFinished(final_results[i]);
551 called_any_callback = true; 328 called_any_callback = true;
552 } 329 }
553 } else { 330 } else {
(...skipping 13 matching lines...) Expand all
567 test_result.full_name = test_names[i]; 344 test_result.full_name = test_names[i];
568 test_result.status = TestResult::TEST_UNKNOWN; 345 test_result.status = TestResult::TEST_UNKNOWN;
569 test_launcher->OnTestFinished(test_result); 346 test_launcher->OnTestFinished(test_result);
570 called_any_callback = true; 347 called_any_callback = true;
571 } 348 }
572 } 349 }
573 350
574 return called_any_callback; 351 return called_any_callback;
575 } 352 }
576 353
354 // TODO(phajdan.jr): Pass parameters directly with C++11 variadic templates.
355 struct GTestCallbackState {
356 TestLauncher* test_launcher;
357 UnitTestPlatformDelegate* platform_delegate;
358 std::vector<std::string> test_names;
359 int launch_flags;
360 FilePath output_file;
361 };
362
363 void GTestCallback(
364 const GTestCallbackState& callback_state,
365 int exit_code,
366 const TimeDelta& elapsed_time,
367 bool was_timeout,
368 const std::string& output) {
369 std::vector<std::string> tests_to_relaunch;
370 ProcessTestResults(callback_state.test_launcher, callback_state.test_names,
371 callback_state.output_file, output, exit_code, was_timeout,
372 &tests_to_relaunch);
373
374 if (!tests_to_relaunch.empty()) {
375 callback_state.platform_delegate->RelaunchTests(
376 callback_state.test_launcher,
377 tests_to_relaunch,
378 callback_state.launch_flags);
379 }
380
381 // The temporary file's directory is also temporary.
382 DeleteFile(callback_state.output_file.DirName(), true);
383 }
384
385 void SerialGTestCallback(
386 const GTestCallbackState& callback_state,
387 const std::vector<std::string>& test_names,
388 int exit_code,
389 const TimeDelta& elapsed_time,
390 bool was_timeout,
391 const std::string& output) {
392 std::vector<std::string> tests_to_relaunch;
393 bool called_any_callbacks =
394 ProcessTestResults(callback_state.test_launcher,
395 callback_state.test_names, callback_state.output_file,
396 output, exit_code, was_timeout, &tests_to_relaunch);
397
398 // There is only one test, there cannot be other tests to relaunch
399 // due to a crash.
400 DCHECK(tests_to_relaunch.empty());
401
402 // There is only one test, we should have called back with its result.
403 DCHECK(called_any_callbacks);
404
405 // The temporary file's directory is also temporary.
406 DeleteFile(callback_state.output_file.DirName(), true);
407
408 MessageLoop::current()->PostTask(
409 FROM_HERE,
410 Bind(&RunUnitTestsSerially,
411 callback_state.test_launcher,
412 callback_state.platform_delegate,
413 test_names,
414 callback_state.launch_flags));
415 }
416
417 } // namespace
418
419 int LaunchUnitTests(int argc,
420 char** argv,
421 const RunTestSuiteCallback& run_test_suite) {
422 CommandLine::Init(argc, argv);
423 return LaunchUnitTestsInternal(run_test_suite, SysInfo::NumberOfProcessors(),
424 true, Bind(&InitGoogleTestChar, &argc, argv));
425 }
426
427 int LaunchUnitTestsSerially(int argc,
428 char** argv,
429 const RunTestSuiteCallback& run_test_suite) {
430 CommandLine::Init(argc, argv);
431 return LaunchUnitTestsInternal(run_test_suite, 1, true,
432 Bind(&InitGoogleTestChar, &argc, argv));
433 }
434
435 #if defined(OS_WIN)
436 int LaunchUnitTests(int argc,
437 wchar_t** argv,
438 bool use_job_objects,
439 const RunTestSuiteCallback& run_test_suite) {
440 // Windows CommandLine::Init ignores argv anyway.
441 CommandLine::Init(argc, NULL);
442 return LaunchUnitTestsInternal(run_test_suite, SysInfo::NumberOfProcessors(),
443 use_job_objects,
444 Bind(&InitGoogleTestWChar, &argc, argv));
445 }
446 #endif // defined(OS_WIN)
447
448 void RunUnitTestsSerially(
449 TestLauncher* test_launcher,
450 UnitTestPlatformDelegate* platform_delegate,
451 const std::vector<std::string>& test_names,
452 int launch_flags) {
453 if (test_names.empty())
454 return;
455
456 std::vector<std::string> new_test_names(test_names);
457 std::string test_name(new_test_names.back());
458 new_test_names.pop_back();
459
460 // Create a dedicated temporary directory to store the xml result data
461 // per run to ensure clean state and make it possible to launch multiple
462 // processes in parallel.
463 base::FilePath output_file;
464 CHECK(platform_delegate->CreateTemporaryFile(&output_file));
465
466 std::vector<std::string> current_test_names;
467 current_test_names.push_back(test_name);
468 CommandLine cmd_line(platform_delegate->GetCommandLineForChildGTestProcess(
469 current_test_names, output_file));
470
471 GTestCallbackState callback_state;
472 callback_state.test_launcher = test_launcher;
473 callback_state.platform_delegate = platform_delegate;
474 callback_state.test_names = current_test_names;
475 callback_state.launch_flags = launch_flags;
476 callback_state.output_file = output_file;
477
478 test_launcher->LaunchChildGTestProcess(
479 cmd_line,
480 platform_delegate->GetWrapperForChildGTestProcess(),
481 TestTimeouts::test_launcher_timeout(),
482 launch_flags,
483 Bind(&SerialGTestCallback, callback_state, new_test_names));
484 }
485
486 void RunUnitTestsBatch(
487 TestLauncher* test_launcher,
488 UnitTestPlatformDelegate* platform_delegate,
489 const std::vector<std::string>& test_names,
490 int launch_flags) {
491 if (test_names.empty())
492 return;
493
494 // Create a dedicated temporary directory to store the xml result data
495 // per run to ensure clean state and make it possible to launch multiple
496 // processes in parallel.
497 base::FilePath output_file;
498 CHECK(platform_delegate->CreateTemporaryFile(&output_file));
499
500 CommandLine cmd_line(platform_delegate->GetCommandLineForChildGTestProcess(
501 test_names, output_file));
502
503 // Adjust the timeout depending on how many tests we're running
504 // (note that e.g. the last batch of tests will be smaller).
505 // TODO(phajdan.jr): Consider an adaptive timeout, which can change
506 // depending on how many tests ran and how many remain.
507 // Note: do NOT parse child's stdout to do that, it's known to be
508 // unreliable (e.g. buffering issues can mix up the output).
509 base::TimeDelta timeout =
510 test_names.size() * TestTimeouts::test_launcher_timeout();
511
512 GTestCallbackState callback_state;
513 callback_state.test_launcher = test_launcher;
514 callback_state.platform_delegate = platform_delegate;
515 callback_state.test_names = test_names;
516 callback_state.launch_flags = launch_flags;
517 callback_state.output_file = output_file;
518
519 test_launcher->LaunchChildGTestProcess(
520 cmd_line,
521 platform_delegate->GetWrapperForChildGTestProcess(),
522 timeout,
523 launch_flags,
524 Bind(&GTestCallback, callback_state));
525 }
526
527 UnitTestLauncherDelegate::UnitTestLauncherDelegate(
528 UnitTestPlatformDelegate* platform_delegate,
529 size_t batch_limit,
530 bool use_job_objects)
531 : platform_delegate_(platform_delegate),
532 batch_limit_(batch_limit),
533 use_job_objects_(use_job_objects) {
534 }
535
536 UnitTestLauncherDelegate::~UnitTestLauncherDelegate() {
537 DCHECK(thread_checker_.CalledOnValidThread());
538 }
539
540 bool UnitTestLauncherDelegate::GetTests(std::vector<SplitTestName>* output) {
541 DCHECK(thread_checker_.CalledOnValidThread());
542 return platform_delegate_->GetTests(output);
543 }
544
545 bool UnitTestLauncherDelegate::ShouldRunTest(const std::string& test_case_name,
546 const std::string& test_name) {
547 DCHECK(thread_checker_.CalledOnValidThread());
548
549 // There is no additional logic to disable specific tests.
550 return true;
551 }
552
553 size_t UnitTestLauncherDelegate::RunTests(
554 TestLauncher* test_launcher,
555 const std::vector<std::string>& test_names) {
556 DCHECK(thread_checker_.CalledOnValidThread());
557
558 int launch_flags = use_job_objects_ ? TestLauncher::USE_JOB_OBJECTS : 0;
559
560 std::vector<std::string> batch;
561 for (size_t i = 0; i < test_names.size(); i++) {
562 batch.push_back(test_names[i]);
563
564 // Use 0 to indicate unlimited batch size.
565 if (batch.size() >= batch_limit_ && batch_limit_ != 0) {
566 RunUnitTestsBatch(test_launcher, platform_delegate_, batch, launch_flags);
567 batch.clear();
568 }
569 }
570
571 RunUnitTestsBatch(test_launcher, platform_delegate_, batch, launch_flags);
572
573 return test_names.size();
574 }
575
576 size_t UnitTestLauncherDelegate::RetryTests(
577 TestLauncher* test_launcher,
578 const std::vector<std::string>& test_names) {
579 MessageLoop::current()->PostTask(
580 FROM_HERE,
581 Bind(&RunUnitTestsSerially,
582 test_launcher,
583 platform_delegate_,
584 test_names,
585 use_job_objects_ ? TestLauncher::USE_JOB_OBJECTS : 0));
586 return test_names.size();
587 }
588
577 } // namespace base 589 } // namespace base
OLDNEW
« no previous file with comments | « base/test/launcher/unit_test_launcher.h ('k') | base/test/multiprocess_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698