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

Side by Side Diff: content/test/test_launcher.cc

Issue 10834010: Revert 144488 - For unit tests, track additions to AtExitManager and warn. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « content/public/test/test_launcher.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/public/test/test_launcher.h" 5 #include "content/public/test/test_launcher.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/environment.h" 11 #include "base/environment.h"
12 #include "base/file_util.h" 12 #include "base/file_util.h"
13 #include "base/hash_tables.h" 13 #include "base/hash_tables.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/memory/linked_ptr.h" 15 #include "base/memory/linked_ptr.h"
16 #include "base/memory/scoped_ptr.h" 16 #include "base/memory/scoped_ptr.h"
17 #include "base/process_util.h" 17 #include "base/process_util.h"
18 #include "base/scoped_temp_dir.h" 18 #include "base/scoped_temp_dir.h"
19 #include "base/string_number_conversions.h" 19 #include "base/string_number_conversions.h"
20 #include "base/string_util.h" 20 #include "base/string_util.h"
21 #include "base/test/test_suite.h" 21 #include "base/test/test_suite.h"
22 #include "base/test/test_switches.h"
23 #include "base/test/test_timeouts.h" 22 #include "base/test/test_timeouts.h"
24 #include "base/time.h" 23 #include "base/time.h"
25 #include "base/utf_string_conversions.h" 24 #include "base/utf_string_conversions.h"
26 #include "content/public/app/startup_helper_win.h" 25 #include "content/public/app/startup_helper_win.h"
27 #include "content/public/common/sandbox_init.h" 26 #include "content/public/common/sandbox_init.h"
28 #include "content/public/test/browser_test.h" 27 #include "content/public/test/browser_test.h"
29 #include "net/base/escape.h" 28 #include "net/base/escape.h"
30 #include "testing/gtest/include/gtest/gtest.h" 29 #include "testing/gtest/include/gtest/gtest.h"
31 30
32 #if defined(OS_WIN) 31 #if defined(OS_WIN)
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 330
332 for (CommandLine::SwitchMap::const_iterator iter = switches.begin(); 331 for (CommandLine::SwitchMap::const_iterator iter = switches.begin();
333 iter != switches.end(); ++iter) { 332 iter != switches.end(); ++iter) {
334 new_cmd_line.AppendSwitchNative((*iter).first, (*iter).second); 333 new_cmd_line.AppendSwitchNative((*iter).first, (*iter).second);
335 } 334 }
336 335
337 // Always enable disabled tests. This method is not called with disabled 336 // Always enable disabled tests. This method is not called with disabled
338 // tests unless this flag was specified to the browser test executable. 337 // tests unless this flag was specified to the browser test executable.
339 new_cmd_line.AppendSwitch("gtest_also_run_disabled_tests"); 338 new_cmd_line.AppendSwitch("gtest_also_run_disabled_tests");
340 new_cmd_line.AppendSwitchASCII("gtest_filter", test_name); 339 new_cmd_line.AppendSwitchASCII("gtest_filter", test_name);
341 new_cmd_line.AppendSwitch(switches::kSingleProcessTestsFlag); 340 new_cmd_line.AppendSwitch(kSingleProcessTestsFlag);
342 341
343 // Do not let the child ignore failures. We need to propagate the 342 // Do not let the child ignore failures. We need to propagate the
344 // failure status back to the parent. 343 // failure status back to the parent.
345 new_cmd_line.AppendSwitch(base::TestSuite::kStrictFailureHandling); 344 new_cmd_line.AppendSwitch(base::TestSuite::kStrictFailureHandling);
346 345
347 if (!launcher_delegate->AdjustChildProcessCommandLine(&new_cmd_line)) 346 if (!launcher_delegate->AdjustChildProcessCommandLine(&new_cmd_line))
348 return -1; 347 return -1;
349 348
350 const char* browser_wrapper = getenv("BROWSER_WRAPPER"); 349 const char* browser_wrapper = getenv("BROWSER_WRAPPER");
351 if (browser_wrapper) { 350 if (browser_wrapper) {
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 553
555 } // namespace 554 } // namespace
556 555
557 const char kGTestFilterFlag[] = "gtest_filter"; 556 const char kGTestFilterFlag[] = "gtest_filter";
558 const char kGTestHelpFlag[] = "gtest_help"; 557 const char kGTestHelpFlag[] = "gtest_help";
559 const char kGTestListTestsFlag[] = "gtest_list_tests"; 558 const char kGTestListTestsFlag[] = "gtest_list_tests";
560 const char kGTestRepeatFlag[] = "gtest_repeat"; 559 const char kGTestRepeatFlag[] = "gtest_repeat";
561 const char kGTestRunDisabledTestsFlag[] = "gtest_also_run_disabled_tests"; 560 const char kGTestRunDisabledTestsFlag[] = "gtest_also_run_disabled_tests";
562 const char kGTestOutputFlag[] = "gtest_output"; 561 const char kGTestOutputFlag[] = "gtest_output";
563 562
563 const char kSingleProcessTestsFlag[] = "single_process";
564 const char kSingleProcessTestsAndChromeFlag[] = "single-process";
564 // The following is kept for historical reasons (so people that are used to 565 // The following is kept for historical reasons (so people that are used to
565 // using it don't get surprised). 566 // using it don't get surprised).
566 const char kChildProcessFlag[] = "child"; 567 const char kChildProcessFlag[] = "child";
567 568
568 const char kHelpFlag[] = "help"; 569 const char kHelpFlag[] = "help";
569 570
570 const char kWarmupFlag[] = "warmup"; 571 const char kWarmupFlag[] = "warmup";
571 572
572 TestLauncherDelegate::~TestLauncherDelegate() { 573 TestLauncherDelegate::~TestLauncherDelegate() {
573 } 574 }
574 575
575 int LaunchTests(TestLauncherDelegate* launcher_delegate, 576 int LaunchTests(TestLauncherDelegate* launcher_delegate,
576 int argc, 577 int argc,
577 char** argv) { 578 char** argv) {
578 DCHECK(!g_launcher_delegate); 579 DCHECK(!g_launcher_delegate);
579 g_launcher_delegate = launcher_delegate; 580 g_launcher_delegate = launcher_delegate;
580 581
581 CommandLine::Init(argc, argv); 582 CommandLine::Init(argc, argv);
582 const CommandLine* command_line = CommandLine::ForCurrentProcess(); 583 const CommandLine* command_line = CommandLine::ForCurrentProcess();
583 584
584 if (command_line->HasSwitch(kHelpFlag)) { 585 if (command_line->HasSwitch(kHelpFlag)) {
585 PrintUsage(); 586 PrintUsage();
586 return 0; 587 return 0;
587 } 588 }
588 589
589 // TODO(pkasting): This "single_process vs. single-process" design is 590 // TODO(pkasting): This "single_process vs. single-process" design is
590 // terrible UI. Instead, there should be some sort of signal flag on the 591 // terrible UI. Instead, there should be some sort of signal flag on the
591 // command line, with all subsequent arguments passed through to the 592 // command line, with all subsequent arguments passed through to the
592 // underlying browser. 593 // underlying browser.
593 if (command_line->HasSwitch(switches::kSingleProcessTestsFlag) || 594 if (command_line->HasSwitch(kSingleProcessTestsFlag) ||
594 command_line->HasSwitch(switches::kSingleProcessChromeFlag) || 595 command_line->HasSwitch(kSingleProcessTestsAndChromeFlag) ||
595 command_line->HasSwitch(kGTestListTestsFlag) || 596 command_line->HasSwitch(kGTestListTestsFlag) ||
596 command_line->HasSwitch(kGTestHelpFlag)) { 597 command_line->HasSwitch(kGTestHelpFlag)) {
597 #if defined(OS_WIN) 598 #if defined(OS_WIN)
598 if (command_line->HasSwitch(switches::kSingleProcessTestsFlag)) { 599 if (command_line->HasSwitch(kSingleProcessTestsFlag)) {
599 sandbox::SandboxInterfaceInfo sandbox_info; 600 sandbox::SandboxInterfaceInfo sandbox_info;
600 content::InitializeSandboxInfo(&sandbox_info); 601 content::InitializeSandboxInfo(&sandbox_info);
601 content::InitializeSandbox(&sandbox_info); 602 content::InitializeSandbox(&sandbox_info);
602 } 603 }
603 #endif 604 #endif
604 return launcher_delegate->RunTestSuite(argc, argv); 605 return launcher_delegate->RunTestSuite(argc, argv);
605 } 606 }
606 607
607 int return_code = 0; 608 int return_code = 0;
608 if (launcher_delegate->Run(argc, argv, &return_code)) 609 if (launcher_delegate->Run(argc, argv, &return_code))
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 cycles--; 669 cycles--;
669 } 670 }
670 return exit_code; 671 return exit_code;
671 } 672 }
672 673
673 TestLauncherDelegate* GetCurrentTestLauncherDelegate() { 674 TestLauncherDelegate* GetCurrentTestLauncherDelegate() {
674 return g_launcher_delegate; 675 return g_launcher_delegate;
675 } 676 }
676 677
677 } // namespace test_launcher 678 } // namespace test_launcher
OLDNEW
« no previous file with comments | « content/public/test/test_launcher.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698