OLD | NEW |
---|---|
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" | |
22 #include "base/test/test_timeouts.h" | 23 #include "base/test/test_timeouts.h" |
23 #include "base/time.h" | 24 #include "base/time.h" |
24 #include "base/utf_string_conversions.h" | 25 #include "base/utf_string_conversions.h" |
25 #include "content/public/app/startup_helper_win.h" | 26 #include "content/public/app/startup_helper_win.h" |
26 #include "content/public/common/sandbox_init.h" | 27 #include "content/public/common/sandbox_init.h" |
27 #include "content/public/test/browser_test.h" | 28 #include "content/public/test/browser_test.h" |
28 #include "net/base/escape.h" | 29 #include "net/base/escape.h" |
29 #include "testing/gtest/include/gtest/gtest.h" | 30 #include "testing/gtest/include/gtest/gtest.h" |
30 | 31 |
31 #if defined(OS_WIN) | 32 #if defined(OS_WIN) |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
334 | 335 |
335 for (CommandLine::SwitchMap::const_iterator iter = switches.begin(); | 336 for (CommandLine::SwitchMap::const_iterator iter = switches.begin(); |
336 iter != switches.end(); ++iter) { | 337 iter != switches.end(); ++iter) { |
337 new_cmd_line.AppendSwitchNative((*iter).first, (*iter).second); | 338 new_cmd_line.AppendSwitchNative((*iter).first, (*iter).second); |
338 } | 339 } |
339 | 340 |
340 // Always enable disabled tests. This method is not called with disabled | 341 // Always enable disabled tests. This method is not called with disabled |
341 // tests unless this flag was specified to the browser test executable. | 342 // tests unless this flag was specified to the browser test executable. |
342 new_cmd_line.AppendSwitch("gtest_also_run_disabled_tests"); | 343 new_cmd_line.AppendSwitch("gtest_also_run_disabled_tests"); |
343 new_cmd_line.AppendSwitchASCII("gtest_filter", test_name); | 344 new_cmd_line.AppendSwitchASCII("gtest_filter", test_name); |
344 new_cmd_line.AppendSwitch(kSingleProcessTestsFlag); | 345 new_cmd_line.AppendSwitch(switches::kSingleProcessTestsFlag); |
Paweł Hajdan Jr.
2012/06/22 07:52:42
Also remove the declaration of kSingleProcessTests
Scott Byer
2012/06/22 22:02:55
Done.
| |
345 | 346 |
346 // Do not let the child ignore failures. We need to propagate the | 347 // Do not let the child ignore failures. We need to propagate the |
347 // failure status back to the parent. | 348 // failure status back to the parent. |
348 new_cmd_line.AppendSwitch(base::TestSuite::kStrictFailureHandling); | 349 new_cmd_line.AppendSwitch(base::TestSuite::kStrictFailureHandling); |
349 | 350 |
350 if (!launcher_delegate->AdjustChildProcessCommandLine(&new_cmd_line)) | 351 if (!launcher_delegate->AdjustChildProcessCommandLine(&new_cmd_line)) |
351 return -1; | 352 return -1; |
352 | 353 |
353 const char* browser_wrapper = getenv("BROWSER_WRAPPER"); | 354 const char* browser_wrapper = getenv("BROWSER_WRAPPER"); |
354 if (browser_wrapper) { | 355 if (browser_wrapper) { |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
558 | 559 |
559 } // namespace | 560 } // namespace |
560 | 561 |
561 const char kGTestFilterFlag[] = "gtest_filter"; | 562 const char kGTestFilterFlag[] = "gtest_filter"; |
562 const char kGTestHelpFlag[] = "gtest_help"; | 563 const char kGTestHelpFlag[] = "gtest_help"; |
563 const char kGTestListTestsFlag[] = "gtest_list_tests"; | 564 const char kGTestListTestsFlag[] = "gtest_list_tests"; |
564 const char kGTestRepeatFlag[] = "gtest_repeat"; | 565 const char kGTestRepeatFlag[] = "gtest_repeat"; |
565 const char kGTestRunDisabledTestsFlag[] = "gtest_also_run_disabled_tests"; | 566 const char kGTestRunDisabledTestsFlag[] = "gtest_also_run_disabled_tests"; |
566 const char kGTestOutputFlag[] = "gtest_output"; | 567 const char kGTestOutputFlag[] = "gtest_output"; |
567 | 568 |
568 const char kSingleProcessTestsFlag[] = "single_process"; | |
569 const char kSingleProcessTestsAndChromeFlag[] = "single-process"; | |
570 // The following is kept for historical reasons (so people that are used to | 569 // The following is kept for historical reasons (so people that are used to |
571 // using it don't get surprised). | 570 // using it don't get surprised). |
572 const char kChildProcessFlag[] = "child"; | 571 const char kChildProcessFlag[] = "child"; |
573 | 572 |
574 const char kHelpFlag[] = "help"; | 573 const char kHelpFlag[] = "help"; |
575 | 574 |
576 TestLauncherDelegate::~TestLauncherDelegate() { | 575 TestLauncherDelegate::~TestLauncherDelegate() { |
577 } | 576 } |
578 | 577 |
579 int LaunchTests(TestLauncherDelegate* launcher_delegate, | 578 int LaunchTests(TestLauncherDelegate* launcher_delegate, |
580 int argc, | 579 int argc, |
581 char** argv) { | 580 char** argv) { |
582 launcher_delegate->EarlyInitialize(); | 581 launcher_delegate->EarlyInitialize(); |
583 | 582 |
584 CommandLine::Init(argc, argv); | 583 CommandLine::Init(argc, argv); |
585 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 584 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
586 | 585 |
587 if (command_line->HasSwitch(kHelpFlag)) { | 586 if (command_line->HasSwitch(kHelpFlag)) { |
588 PrintUsage(); | 587 PrintUsage(); |
589 return 0; | 588 return 0; |
590 } | 589 } |
591 | 590 |
592 // TODO(pkasting): This "single_process vs. single-process" design is | 591 // TODO(pkasting): This "single_process vs. single-process" design is |
593 // terrible UI. Instead, there should be some sort of signal flag on the | 592 // terrible UI. Instead, there should be some sort of signal flag on the |
594 // command line, with all subsequent arguments passed through to the | 593 // command line, with all subsequent arguments passed through to the |
595 // underlying browser. | 594 // underlying browser. |
596 if (command_line->HasSwitch(kSingleProcessTestsFlag) || | 595 if (command_line->HasSwitch(switches::kSingleProcessTestsFlag) || |
597 command_line->HasSwitch(kSingleProcessTestsAndChromeFlag) || | 596 command_line->HasSwitch(switches::kSingleProcessTestsAndChromeFlag) || |
598 command_line->HasSwitch(kGTestListTestsFlag) || | 597 command_line->HasSwitch(kGTestListTestsFlag) || |
599 command_line->HasSwitch(kGTestHelpFlag)) { | 598 command_line->HasSwitch(kGTestHelpFlag)) { |
600 #if defined(OS_WIN) | 599 #if defined(OS_WIN) |
601 if (command_line->HasSwitch(kSingleProcessTestsFlag)) { | 600 if (command_line->HasSwitch(switches::kSingleProcessTestsFlag)) { |
602 sandbox::SandboxInterfaceInfo sandbox_info; | 601 sandbox::SandboxInterfaceInfo sandbox_info; |
603 content::InitializeSandboxInfo(&sandbox_info); | 602 content::InitializeSandboxInfo(&sandbox_info); |
604 content::InitializeSandbox(&sandbox_info); | 603 content::InitializeSandbox(&sandbox_info); |
605 } | 604 } |
606 #endif | 605 #endif |
607 return launcher_delegate->RunTestSuite(argc, argv); | 606 return launcher_delegate->RunTestSuite(argc, argv); |
608 } | 607 } |
609 | 608 |
610 int return_code = 0; | 609 int return_code = 0; |
611 if (launcher_delegate->Run(argc, argv, &return_code)) | 610 if (launcher_delegate->Run(argc, argv, &return_code)) |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
662 } | 661 } |
663 | 662 |
664 // Special value "-1" means "repeat indefinitely". | 663 // Special value "-1" means "repeat indefinitely". |
665 if (cycles != -1) | 664 if (cycles != -1) |
666 cycles--; | 665 cycles--; |
667 } | 666 } |
668 return exit_code; | 667 return exit_code; |
669 } | 668 } |
670 | 669 |
671 } // namespace test_launcher | 670 } // namespace test_launcher |
OLD | NEW |