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

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

Issue 1312923003: Fix test launcher crash on non-UTF-8 output snippets (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 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_results_tracker.cc
diff --git a/base/test/launcher/test_results_tracker.cc b/base/test/launcher/test_results_tracker.cc
index 92ee04a4ee3c10de9542611517610c6f699c0aa9..3c7faa32193cb5112f3f95d53eb7e54489ef988f 100644
--- a/base/test/launcher/test_results_tracker.cc
+++ b/base/test/launcher/test_results_tracker.cc
@@ -262,16 +262,20 @@ bool TestResultsTracker::SaveSummaryAsJSON(const FilePath& path) const {
"elapsed_time_ms",
static_cast<int>(test_result.elapsed_time.InMilliseconds()));
- // There are no guarantees about character encoding of the output
- // snippet. Escape it and record whether it was losless.
- // It's useful to have the output snippet as string in the summary
- // for easy viewing.
- std::string escaped_output_snippet;
- bool losless_snippet = EscapeJSONString(
- test_result.output_snippet, false, &escaped_output_snippet);
- test_result_value->SetString("output_snippet",
- escaped_output_snippet);
- test_result_value->SetBoolean("losless_snippet", losless_snippet);
+ bool lossless_snippet = false;
+ if (IsStringUTF8(test_result.output_snippet)) {
+ test_result_value->SetString(
+ "output_snippet", test_result.output_snippet);
+ lossless_snippet = true;
+ } else {
+ test_result_value->SetString(
+ "output_snippet",
+ "<non-UTF-8 snippet, see output_snippet_base64>");
sky 2015/08/27 16:51:56 Actually, one question here, can we escape the str
Paweł Hajdan Jr. 2015/08/28 08:04:24 That's what the previous code was trying to do. Ap
+ }
+
+ // TODO(phajdan.jr): Fix typo in JSON key (losless -> lossless)
+ // making sure not to break any consumers of this data.
+ test_result_value->SetBoolean("losless_snippet", lossless_snippet);
// Also include the raw version (base64-encoded so that it can be safely
// JSON-serialized - there are no guarantees about character encoding
« 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