Commit 0fbbee21 authored by nick's avatar nick Committed by Commit bot

base/test/launcher: Don't trim leading whitespace from test output

base/strings: Remove an unnecessary UTF8 check from one of the trim functions

gtest's message often use leading whitespace in a way that's visually meaningful. Some examples:

======== EXPECT_EQ(this, this+1);
my_test.cc(2048): error: Value of: this+1
  Actual: 24F8B8D4
Expected: this
Which is: 24F8B8A0
========
======== EXPECT_EQ("AA\nBB\nDD", std::string("AA\nXX\nDD"));
my_test.cc(2049): error: Value of: std::string("AA\nXX\nDD")
  Actual: "AA\nXX\nDD"
Expected: "AA\nBB\nDD"
With diff:
@@ -1,3 +1,3 @@
 AA
-BB
+XX
 DD
========

Today leading whitespaces are stripped out by the test launcher, leading to less readable test stdout on the bots (and headaches, especially, if the 'AA' value in the example above had leading whitespace itself -- which is how I noticed this).

The current whitespace trimming seems to be an accidental effect of [https://codereview.chromium.org/324893004], so it should be safe to change back.

BUG=475265

Review URL: https://codereview.chromium.org/1081493002

Cr-Commit-Position: refs/heads/master@{#325512}
parent d362de5b
......@@ -6,7 +6,6 @@
#include "base/logging.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/third_party/icu/icu_utf.h"
namespace base {
......@@ -193,7 +192,6 @@ void SplitStringDontTrim(const string16& str,
void SplitStringDontTrim(const std::string& str,
char c,
std::vector<std::string>* r) {
DCHECK(IsStringUTF8(str));
#if CHAR_MIN < 0
DCHECK_GE(c, 0);
#endif
......
......@@ -570,7 +570,7 @@ void TestLauncher::OnTestFinished(const TestResult& result) {
}
if (print_snippet) {
std::vector<std::string> snippet_lines;
SplitString(result.output_snippet, '\n', &snippet_lines);
SplitStringDontTrim(result.output_snippet, '\n', &snippet_lines);
if (snippet_lines.size() > kOutputSnippetLinesLimit) {
size_t truncated_size = snippet_lines.size() - kOutputSnippetLinesLimit;
snippet_lines.erase(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment