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

Unified Diff: base/test/launcher/test_launcher.cc

Issue 324893004: Truncate huge output snippets in the test launcher before printing them (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/test/launcher/test_launcher.cc
diff --git a/base/test/launcher/test_launcher.cc b/base/test/launcher/test_launcher.cc
index 8d62afac53a26f9f529c3880a2bb329e95b4478d..d50bf0efa50c7352076704ad7feec5ea24ca68bd 100644
--- a/base/test/launcher/test_launcher.cc
+++ b/base/test/launcher/test_launcher.cc
@@ -76,6 +76,11 @@ const char kUnreliableResultsTag[] = "UNRELIABLE_RESULTS";
// debugging in case the process hangs anyway.
const int kOutputTimeoutSeconds = 15;
+// Limit of output snippet lines when printing to stdout.
+// Avoids flooding the logs with amount of output that gums up
+// the infrastructure.
+const size_t kOutputSnippetLinesLimit = 50;
+
// Set of live launch test processes with corresponding lock (it is allowed
// for callers to launch processes on different threads).
LazyInstance<std::map<ProcessHandle, CommandLine> > g_live_processes
@@ -451,7 +456,16 @@ void TestLauncher::OnTestFinished(const TestResult& result) {
<< ": " << print_test_stdio;
}
if (print_snippet) {
- fprintf(stdout, "%s", result.output_snippet.c_str());
+ std::vector<std::string> snippet_lines;
sky 2014/06/10 16:25:14 This initially confused me. I would have thought y
+ SplitString(result.output_snippet, '\n', &snippet_lines);
+ if (snippet_lines.size() > kOutputSnippetLinesLimit) {
+ size_t truncated_size = snippet_lines.size() - kOutputSnippetLinesLimit;
+ snippet_lines.erase(
+ snippet_lines.begin(),
+ snippet_lines.begin() + truncated_size);
+ snippet_lines.insert(snippet_lines.begin(), "<truncated>");
+ }
+ fprintf(stdout, "%s", JoinString(snippet_lines, "\n").c_str());
fflush(stdout);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698