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

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

Issue 418093004: Factored out duplicate code for formatting full test name (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed bug Created 6 years, 4 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 | « base/test/launcher/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 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/test_launcher.h" 5 #include "base/test/launcher/test_launcher.h"
6 6
7 #if defined(OS_POSIX) 7 #if defined(OS_POSIX)
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #endif 9 #endif
10 10
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 569
570 fprintf(stdout, "Retrying %" PRIuS " test%s (retry #%" PRIuS ")\n", 570 fprintf(stdout, "Retrying %" PRIuS " test%s (retry #%" PRIuS ")\n",
571 retry_started_count, 571 retry_started_count,
572 retry_started_count > 1 ? "s" : "", 572 retry_started_count > 1 ? "s" : "",
573 retry_count_); 573 retry_count_);
574 fflush(stdout); 574 fflush(stdout);
575 575
576 test_started_count_ += retry_started_count; 576 test_started_count_ += retry_started_count;
577 } 577 }
578 578
579 // static
580 std::string TestLauncher::FormatFullTestName(const std::string& test_case_name,
581 const std::string& test_name) {
582 return test_case_name + "." + test_name;
583 }
584
579 bool TestLauncher::Init() { 585 bool TestLauncher::Init() {
580 const CommandLine* command_line = CommandLine::ForCurrentProcess(); 586 const CommandLine* command_line = CommandLine::ForCurrentProcess();
581 587
582 // Initialize sharding. Command line takes precedence over legacy environment 588 // Initialize sharding. Command line takes precedence over legacy environment
583 // variables. 589 // variables.
584 if (command_line->HasSwitch(switches::kTestLauncherTotalShards) && 590 if (command_line->HasSwitch(switches::kTestLauncherTotalShards) &&
585 command_line->HasSwitch(switches::kTestLauncherShardIndex)) { 591 command_line->HasSwitch(switches::kTestLauncherShardIndex)) {
586 if (!StringToInt( 592 if (!StringToInt(
587 command_line->GetSwitchValueASCII( 593 command_line->GetSwitchValueASCII(
588 switches::kTestLauncherTotalShards), 594 switches::kTestLauncherTotalShards),
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 784
779 void TestLauncher::RunTests() { 785 void TestLauncher::RunTests() {
780 testing::UnitTest* const unit_test = testing::UnitTest::GetInstance(); 786 testing::UnitTest* const unit_test = testing::UnitTest::GetInstance();
781 787
782 std::vector<std::string> test_names; 788 std::vector<std::string> test_names;
783 789
784 for (int i = 0; i < unit_test->total_test_case_count(); ++i) { 790 for (int i = 0; i < unit_test->total_test_case_count(); ++i) {
785 const testing::TestCase* test_case = unit_test->GetTestCase(i); 791 const testing::TestCase* test_case = unit_test->GetTestCase(i);
786 for (int j = 0; j < test_case->total_test_count(); ++j) { 792 for (int j = 0; j < test_case->total_test_count(); ++j) {
787 const testing::TestInfo* test_info = test_case->GetTestInfo(j); 793 const testing::TestInfo* test_info = test_case->GetTestInfo(j);
788 std::string test_name = test_info->test_case_name(); 794 std::string test_name = FormatFullTestName(
789 test_name.append("."); 795 test_info->test_case_name(), test_info->name());
790 test_name.append(test_info->name());
791 796
792 results_tracker_.AddTest(test_name); 797 results_tracker_.AddTest(test_name);
793 798
794 const CommandLine* command_line = CommandLine::ForCurrentProcess(); 799 const CommandLine* command_line = CommandLine::ForCurrentProcess();
795 if (test_name.find("DISABLED") != std::string::npos) { 800 if (test_name.find("DISABLED") != std::string::npos) {
796 results_tracker_.AddDisabledTest(test_name); 801 results_tracker_.AddDisabledTest(test_name);
797 802
798 // Skip disabled tests unless explicitly requested. 803 // Skip disabled tests unless explicitly requested.
799 if (!command_line->HasSwitch(kGTestRunDisabledTestsFlag)) 804 if (!command_line->HasSwitch(kGTestRunDisabledTestsFlag))
800 continue; 805 continue;
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
1089 1094
1090 g_live_processes.Get().erase(process_handle); 1095 g_live_processes.Get().erase(process_handle);
1091 } 1096 }
1092 1097
1093 base::CloseProcessHandle(process_handle); 1098 base::CloseProcessHandle(process_handle);
1094 1099
1095 return exit_code; 1100 return exit_code;
1096 } 1101 }
1097 1102
1098 } // namespace base 1103 } // namespace base
OLDNEW
« no previous file with comments | « base/test/launcher/test_launcher.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698