OLD | NEW |
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 Loading... |
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 = SplitString( | 564 std::vector<std::string> snippet_lines; |
565 result.output_snippet, "\n", base::KEEP_WHITESPACE, | 565 SplitStringDontTrim(result.output_snippet, '\n', &snippet_lines); |
566 base::SPLIT_WANT_ALL); | |
567 if (snippet_lines.size() > kOutputSnippetLinesLimit) { | 566 if (snippet_lines.size() > kOutputSnippetLinesLimit) { |
568 size_t truncated_size = snippet_lines.size() - kOutputSnippetLinesLimit; | 567 size_t truncated_size = snippet_lines.size() - kOutputSnippetLinesLimit; |
569 snippet_lines.erase( | 568 snippet_lines.erase( |
570 snippet_lines.begin(), | 569 snippet_lines.begin(), |
571 snippet_lines.begin() + truncated_size); | 570 snippet_lines.begin() + truncated_size); |
572 snippet_lines.insert(snippet_lines.begin(), "<truncated>"); | 571 snippet_lines.insert(snippet_lines.begin(), "<truncated>"); |
573 } | 572 } |
574 fprintf(stdout, "%s", base::JoinString(snippet_lines, "\n").c_str()); | 573 fprintf(stdout, "%s", base::JoinString(snippet_lines, "\n").c_str()); |
575 fflush(stdout); | 574 fflush(stdout); |
576 } | 575 } |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
785 | 784 |
786 if (command_line->HasSwitch(switches::kTestLauncherFilterFile)) { | 785 if (command_line->HasSwitch(switches::kTestLauncherFilterFile)) { |
787 std::string filter; | 786 std::string filter; |
788 if (!ReadFileToString( | 787 if (!ReadFileToString( |
789 command_line->GetSwitchValuePath(switches::kTestLauncherFilterFile), | 788 command_line->GetSwitchValuePath(switches::kTestLauncherFilterFile), |
790 &filter)) { | 789 &filter)) { |
791 LOG(ERROR) << "Failed to read the filter file."; | 790 LOG(ERROR) << "Failed to read the filter file."; |
792 return false; | 791 return false; |
793 } | 792 } |
794 | 793 |
795 std::vector<std::string> filter_lines = SplitString( | 794 std::vector<std::string> filter_lines; |
796 filter, "\n", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); | 795 SplitString(filter, '\n', &filter_lines); |
797 for (size_t i = 0; i < filter_lines.size(); i++) { | 796 for (size_t i = 0; i < filter_lines.size(); i++) { |
798 if (filter_lines[i].empty()) | 797 if (filter_lines[i].empty()) |
799 continue; | 798 continue; |
800 | 799 |
801 if (filter_lines[i][0] == '-') | 800 if (filter_lines[i][0] == '-') |
802 negative_test_filter_.push_back(filter_lines[i].substr(1)); | 801 negative_test_filter_.push_back(filter_lines[i].substr(1)); |
803 else | 802 else |
804 positive_test_filter_.push_back(filter_lines[i]); | 803 positive_test_filter_.push_back(filter_lines[i]); |
805 } | 804 } |
806 } else { | 805 } else { |
807 // Split --gtest_filter at '-', if there is one, to separate into | 806 // Split --gtest_filter at '-', if there is one, to separate into |
808 // positive filter and negative filter portions. | 807 // positive filter and negative filter portions. |
809 std::string filter = command_line->GetSwitchValueASCII(kGTestFilterFlag); | 808 std::string filter = command_line->GetSwitchValueASCII(kGTestFilterFlag); |
810 size_t dash_pos = filter.find('-'); | 809 size_t dash_pos = filter.find('-'); |
811 if (dash_pos == std::string::npos) { | 810 if (dash_pos == std::string::npos) { |
812 positive_test_filter_ = SplitString( | 811 SplitString(filter, ':', &positive_test_filter_); |
813 filter, ":", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); | |
814 } else { | 812 } else { |
815 // Everything up to the dash. | 813 // Everything up to the dash. |
816 positive_test_filter_ = SplitString( | 814 SplitString(filter.substr(0, dash_pos), ':', &positive_test_filter_); |
817 filter.substr(0, dash_pos), ":", base::TRIM_WHITESPACE, | |
818 base::SPLIT_WANT_ALL); | |
819 | 815 |
820 // Everything after the dash. | 816 // Everything after the dash. |
821 negative_test_filter_ = SplitString( | 817 SplitString(filter.substr(dash_pos + 1), ':', &negative_test_filter_); |
822 filter.substr(dash_pos + 1), ":", base::TRIM_WHITESPACE, | |
823 base::SPLIT_WANT_ALL); | |
824 } | 818 } |
825 } | 819 } |
826 | 820 |
827 if (!launcher_delegate_->GetTests(&tests_)) { | 821 if (!launcher_delegate_->GetTests(&tests_)) { |
828 LOG(ERROR) << "Failed to get list of tests."; | 822 LOG(ERROR) << "Failed to get list of tests."; |
829 return false; | 823 return false; |
830 } | 824 } |
831 | 825 |
832 if (!results_tracker_.Init(*command_line)) { | 826 if (!results_tracker_.Init(*command_line)) { |
833 LOG(ERROR) << "Failed to initialize test results tracker."; | 827 LOG(ERROR) << "Failed to initialize test results tracker."; |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1079 } | 1073 } |
1080 | 1074 |
1081 std::string snippet(full_output.substr(run_pos)); | 1075 std::string snippet(full_output.substr(run_pos)); |
1082 if (end_pos != std::string::npos) | 1076 if (end_pos != std::string::npos) |
1083 snippet = full_output.substr(run_pos, end_pos - run_pos); | 1077 snippet = full_output.substr(run_pos, end_pos - run_pos); |
1084 | 1078 |
1085 return snippet; | 1079 return snippet; |
1086 } | 1080 } |
1087 | 1081 |
1088 } // namespace base | 1082 } // namespace base |
OLD | NEW |