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 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/at_exit.h" | 9 #include "base/at_exit.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/environment.h" | 12 #include "base/environment.h" |
13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
14 #include "base/files/file_util.h" | 14 #include "base/files/file_util.h" |
15 #include "base/files/scoped_file.h" | 15 #include "base/files/scoped_file.h" |
16 #include "base/format_macros.h" | 16 #include "base/format_macros.h" |
17 #include "base/hash.h" | 17 #include "base/hash.h" |
18 #include "base/lazy_instance.h" | 18 #include "base/lazy_instance.h" |
19 #include "base/location.h" | 19 #include "base/location.h" |
20 #include "base/logging.h" | 20 #include "base/logging.h" |
21 #include "base/macros.h" | 21 #include "base/macros.h" |
22 #include "base/memory/ptr_util.h" | 22 #include "base/memory/ptr_util.h" |
23 #include "base/message_loop/message_loop.h" | 23 #include "base/message_loop/message_loop.h" |
24 #include "base/process/kill.h" | 24 #include "base/process/kill.h" |
25 #include "base/process/launch.h" | 25 #include "base/process/launch.h" |
26 #include "base/run_loop.h" | 26 #include "base/run_loop.h" |
27 #include "base/single_thread_task_runner.h" | 27 #include "base/single_thread_task_runner.h" |
28 #include "base/strings/pattern.h" | 28 #include "base/strings/pattern.h" |
29 #include "base/strings/string_number_conversions.h" | 29 #include "base/strings/string_number_conversions.h" |
| 30 #include "base/strings/string_piece.h" |
30 #include "base/strings/string_split.h" | 31 #include "base/strings/string_split.h" |
31 #include "base/strings/string_util.h" | 32 #include "base/strings/string_util.h" |
32 #include "base/strings/stringize_macros.h" | 33 #include "base/strings/stringize_macros.h" |
33 #include "base/strings/stringprintf.h" | 34 #include "base/strings/stringprintf.h" |
34 #include "base/strings/utf_string_conversions.h" | 35 #include "base/strings/utf_string_conversions.h" |
35 #include "base/test/gtest_util.h" | 36 #include "base/test/gtest_util.h" |
36 #include "base/test/launcher/test_launcher_tracer.h" | 37 #include "base/test/launcher/test_launcher_tracer.h" |
37 #include "base/test/launcher/test_results_tracker.h" | 38 #include "base/test/launcher/test_results_tracker.h" |
38 #include "base/test/sequenced_worker_pool_owner.h" | 39 #include "base/test/sequenced_worker_pool_owner.h" |
39 #include "base/test/test_switches.h" | 40 #include "base/test/test_switches.h" |
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
608 print_snippet = (result.status != TestResult::TEST_SUCCESS); | 609 print_snippet = (result.status != TestResult::TEST_SUCCESS); |
609 } else if (print_test_stdio == "always") { | 610 } else if (print_test_stdio == "always") { |
610 print_snippet = true; | 611 print_snippet = true; |
611 } else if (print_test_stdio == "never") { | 612 } else if (print_test_stdio == "never") { |
612 print_snippet = false; | 613 print_snippet = false; |
613 } else { | 614 } else { |
614 LOG(WARNING) << "Invalid value of " << switches::kTestLauncherPrintTestStdio | 615 LOG(WARNING) << "Invalid value of " << switches::kTestLauncherPrintTestStdio |
615 << ": " << print_test_stdio; | 616 << ": " << print_test_stdio; |
616 } | 617 } |
617 if (print_snippet) { | 618 if (print_snippet) { |
618 std::vector<std::string> snippet_lines = SplitString( | 619 std::vector<base::StringPiece> snippet_lines = |
619 result.output_snippet, "\n", base::KEEP_WHITESPACE, | 620 SplitStringPiece(result.output_snippet, "\n", base::KEEP_WHITESPACE, |
620 base::SPLIT_WANT_ALL); | 621 base::SPLIT_WANT_ALL); |
621 if (snippet_lines.size() > kOutputSnippetLinesLimit) { | 622 if (snippet_lines.size() > kOutputSnippetLinesLimit) { |
622 size_t truncated_size = snippet_lines.size() - kOutputSnippetLinesLimit; | 623 size_t truncated_size = snippet_lines.size() - kOutputSnippetLinesLimit; |
623 snippet_lines.erase( | 624 snippet_lines.erase( |
624 snippet_lines.begin(), | 625 snippet_lines.begin(), |
625 snippet_lines.begin() + truncated_size); | 626 snippet_lines.begin() + truncated_size); |
626 snippet_lines.insert(snippet_lines.begin(), "<truncated>"); | 627 snippet_lines.insert(snippet_lines.begin(), "<truncated>"); |
627 } | 628 } |
628 fprintf(stdout, "%s", base::JoinString(snippet_lines, "\n").c_str()); | 629 fprintf(stdout, "%s", base::JoinString(snippet_lines, "\n").c_str()); |
629 fflush(stdout); | 630 fflush(stdout); |
630 } | 631 } |
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1211 } | 1212 } |
1212 | 1213 |
1213 std::string snippet(full_output.substr(run_pos)); | 1214 std::string snippet(full_output.substr(run_pos)); |
1214 if (end_pos != std::string::npos) | 1215 if (end_pos != std::string::npos) |
1215 snippet = full_output.substr(run_pos, end_pos - run_pos); | 1216 snippet = full_output.substr(run_pos, end_pos - run_pos); |
1216 | 1217 |
1217 return snippet; | 1218 return snippet; |
1218 } | 1219 } |
1219 | 1220 |
1220 } // namespace base | 1221 } // namespace base |
OLD | NEW |