| 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/test/test_launcher.h" | 5 #include "content/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" |
| (...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 "Starting tests...\n" | 628 "Starting tests...\n" |
| 629 "IMPORTANT DEBUGGING NOTE: each test is run inside its own process.\n" | 629 "IMPORTANT DEBUGGING NOTE: each test is run inside its own process.\n" |
| 630 "For debugging a test inside a debugger, use the\n" | 630 "For debugging a test inside a debugger, use the\n" |
| 631 "--gtest_filter=<your_test_name> flag along with either\n" | 631 "--gtest_filter=<your_test_name> flag along with either\n" |
| 632 "--single_process (to run all tests in one launcher/browser process) or\n" | 632 "--single_process (to run all tests in one launcher/browser process) or\n" |
| 633 "--single-process (to do the above, and also run Chrome in single-\n" | 633 "--single-process (to do the above, and also run Chrome in single-\n" |
| 634 "process mode).\n"); | 634 "process mode).\n"); |
| 635 | 635 |
| 636 testing::InitGoogleTest(&argc, argv); | 636 testing::InitGoogleTest(&argc, argv); |
| 637 TestTimeouts::Initialize(); | 637 TestTimeouts::Initialize(); |
| 638 int exit_code = 0; |
| 638 | 639 |
| 639 // Make sure the entire browser code is loaded into memory. Reading it | 640 // Make sure the entire browser code is loaded into memory. Reading it |
| 640 // from disk may be slow on a busy bot, and can easily exceed the default | 641 // from disk may be slow on a busy bot, and can easily exceed the default |
| 641 // timeout causing flaky test failures. Use an empty test that only starts | 642 // timeout causing flaky test failures. Use an empty test that only starts |
| 642 // and closes a browser with a long timeout to avoid those problems. | 643 // and closes a browser with a long timeout to avoid those problems. |
| 643 int exit_code = RunTest(launcher_delegate, | 644 // NOTE: we don't do this when specifying a filter because this slows down the |
| 644 kEmptyTestName, | 645 // common case of running one test locally, and also on trybots when sharding |
| 645 TestTimeouts::large_test_timeout_ms(), | 646 // as this one test runs ~200 times and wastes a few minutes. |
| 646 NULL); | 647 if (!should_shard && !command_line->HasSwitch(kGTestFilterFlag)) { |
| 647 if (exit_code != 0) | 648 exit_code = RunTest(launcher_delegate, |
| 648 return exit_code; | 649 kEmptyTestName, |
| 650 TestTimeouts::large_test_timeout_ms(), |
| 651 NULL); |
| 652 if (exit_code != 0) |
| 653 return exit_code; |
| 654 } |
| 649 | 655 |
| 650 int cycles = 1; | 656 int cycles = 1; |
| 651 if (command_line->HasSwitch(kGTestRepeatFlag)) { | 657 if (command_line->HasSwitch(kGTestRepeatFlag)) { |
| 652 base::StringToInt(command_line->GetSwitchValueASCII(kGTestRepeatFlag), | 658 base::StringToInt(command_line->GetSwitchValueASCII(kGTestRepeatFlag), |
| 653 &cycles); | 659 &cycles); |
| 654 } | 660 } |
| 655 | 661 |
| 656 while (cycles != 0) { | 662 while (cycles != 0) { |
| 657 if (!RunTests(launcher_delegate, | 663 if (!RunTests(launcher_delegate, |
| 658 should_shard, | 664 should_shard, |
| 659 total_shards, | 665 total_shards, |
| 660 shard_index)) { | 666 shard_index)) { |
| 661 exit_code = 1; | 667 exit_code = 1; |
| 662 break; | 668 break; |
| 663 } | 669 } |
| 664 | 670 |
| 665 // Special value "-1" means "repeat indefinitely". | 671 // Special value "-1" means "repeat indefinitely". |
| 666 if (cycles != -1) | 672 if (cycles != -1) |
| 667 cycles--; | 673 cycles--; |
| 668 } | 674 } |
| 669 return exit_code; | 675 return exit_code; |
| 670 } | 676 } |
| 671 | 677 |
| 672 } // namespace test_launcher | 678 } // namespace test_launcher |
| OLD | NEW |