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

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

Issue 1274123003: Update SplitString calls to new form (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: no media changes Created 5 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
« no previous file with comments | « base/process/process_metrics_linux.cc ('k') | base/trace_event/trace_config.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/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 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 print_snippet = (result.status != TestResult::TEST_SUCCESS); 554 print_snippet = (result.status != TestResult::TEST_SUCCESS);
555 } else if (print_test_stdio == "always") { 555 } else if (print_test_stdio == "always") {
556 print_snippet = true; 556 print_snippet = true;
557 } else if (print_test_stdio == "never") { 557 } else if (print_test_stdio == "never") {
558 print_snippet = false; 558 print_snippet = false;
559 } else { 559 } else {
560 LOG(WARNING) << "Invalid value of " << switches::kTestLauncherPrintTestStdio 560 LOG(WARNING) << "Invalid value of " << switches::kTestLauncherPrintTestStdio
561 << ": " << print_test_stdio; 561 << ": " << print_test_stdio;
562 } 562 }
563 if (print_snippet) { 563 if (print_snippet) {
564 std::vector<std::string> snippet_lines; 564 std::vector<std::string> snippet_lines = SplitString(
565 SplitStringDontTrim(result.output_snippet, '\n', &snippet_lines); 565 result.output_snippet, "\n", base::KEEP_WHITESPACE,
566 base::SPLIT_WANT_ALL);
566 if (snippet_lines.size() > kOutputSnippetLinesLimit) { 567 if (snippet_lines.size() > kOutputSnippetLinesLimit) {
567 size_t truncated_size = snippet_lines.size() - kOutputSnippetLinesLimit; 568 size_t truncated_size = snippet_lines.size() - kOutputSnippetLinesLimit;
568 snippet_lines.erase( 569 snippet_lines.erase(
569 snippet_lines.begin(), 570 snippet_lines.begin(),
570 snippet_lines.begin() + truncated_size); 571 snippet_lines.begin() + truncated_size);
571 snippet_lines.insert(snippet_lines.begin(), "<truncated>"); 572 snippet_lines.insert(snippet_lines.begin(), "<truncated>");
572 } 573 }
573 fprintf(stdout, "%s", base::JoinString(snippet_lines, "\n").c_str()); 574 fprintf(stdout, "%s", base::JoinString(snippet_lines, "\n").c_str());
574 fflush(stdout); 575 fflush(stdout);
575 } 576 }
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
784 785
785 if (command_line->HasSwitch(switches::kTestLauncherFilterFile)) { 786 if (command_line->HasSwitch(switches::kTestLauncherFilterFile)) {
786 std::string filter; 787 std::string filter;
787 if (!ReadFileToString( 788 if (!ReadFileToString(
788 command_line->GetSwitchValuePath(switches::kTestLauncherFilterFile), 789 command_line->GetSwitchValuePath(switches::kTestLauncherFilterFile),
789 &filter)) { 790 &filter)) {
790 LOG(ERROR) << "Failed to read the filter file."; 791 LOG(ERROR) << "Failed to read the filter file.";
791 return false; 792 return false;
792 } 793 }
793 794
794 std::vector<std::string> filter_lines; 795 std::vector<std::string> filter_lines = SplitString(
795 SplitString(filter, '\n', &filter_lines); 796 filter, "\n", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
796 for (size_t i = 0; i < filter_lines.size(); i++) { 797 for (size_t i = 0; i < filter_lines.size(); i++) {
797 if (filter_lines[i].empty()) 798 if (filter_lines[i].empty())
798 continue; 799 continue;
799 800
800 if (filter_lines[i][0] == '-') 801 if (filter_lines[i][0] == '-')
801 negative_test_filter_.push_back(filter_lines[i].substr(1)); 802 negative_test_filter_.push_back(filter_lines[i].substr(1));
802 else 803 else
803 positive_test_filter_.push_back(filter_lines[i]); 804 positive_test_filter_.push_back(filter_lines[i]);
804 } 805 }
805 } else { 806 } else {
806 // Split --gtest_filter at '-', if there is one, to separate into 807 // Split --gtest_filter at '-', if there is one, to separate into
807 // positive filter and negative filter portions. 808 // positive filter and negative filter portions.
808 std::string filter = command_line->GetSwitchValueASCII(kGTestFilterFlag); 809 std::string filter = command_line->GetSwitchValueASCII(kGTestFilterFlag);
809 size_t dash_pos = filter.find('-'); 810 size_t dash_pos = filter.find('-');
810 if (dash_pos == std::string::npos) { 811 if (dash_pos == std::string::npos) {
811 SplitString(filter, ':', &positive_test_filter_); 812 positive_test_filter_ = SplitString(
813 filter, ":", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
812 } else { 814 } else {
813 // Everything up to the dash. 815 // Everything up to the dash.
814 SplitString(filter.substr(0, dash_pos), ':', &positive_test_filter_); 816 positive_test_filter_ = SplitString(
817 filter.substr(0, dash_pos), ":", base::TRIM_WHITESPACE,
818 base::SPLIT_WANT_ALL);
815 819
816 // Everything after the dash. 820 // Everything after the dash.
817 SplitString(filter.substr(dash_pos + 1), ':', &negative_test_filter_); 821 negative_test_filter_ = SplitString(
822 filter.substr(dash_pos + 1), ":", base::TRIM_WHITESPACE,
823 base::SPLIT_WANT_ALL);
818 } 824 }
819 } 825 }
820 826
821 if (!launcher_delegate_->GetTests(&tests_)) { 827 if (!launcher_delegate_->GetTests(&tests_)) {
822 LOG(ERROR) << "Failed to get list of tests."; 828 LOG(ERROR) << "Failed to get list of tests.";
823 return false; 829 return false;
824 } 830 }
825 831
826 if (!results_tracker_.Init(*command_line)) { 832 if (!results_tracker_.Init(*command_line)) {
827 LOG(ERROR) << "Failed to initialize test results tracker."; 833 LOG(ERROR) << "Failed to initialize test results tracker.";
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
1073 } 1079 }
1074 1080
1075 std::string snippet(full_output.substr(run_pos)); 1081 std::string snippet(full_output.substr(run_pos));
1076 if (end_pos != std::string::npos) 1082 if (end_pos != std::string::npos)
1077 snippet = full_output.substr(run_pos, end_pos - run_pos); 1083 snippet = full_output.substr(run_pos, end_pos - run_pos);
1078 1084
1079 return snippet; 1085 return snippet;
1080 } 1086 }
1081 1087
1082 } // namespace base 1088 } // namespace base
OLDNEW
« no previous file with comments | « base/process/process_metrics_linux.cc ('k') | base/trace_event/trace_config.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698