diff options
author | 2016-11-04 10:59:36 +0000 | |
---|---|---|
committer | 2016-11-04 11:01:51 +0000 | |
commit | 6a8424ff374b17706f2ac7fa77eaf1a03b75c538 (patch) | |
tree | 617f0259b919b6e4e012e868c0ffe15d46efeae8 /src/test | |
parent | a396b070ae36032a973672e11145533621c39edc (diff) |
Fix test breakage on Windows.
The test was asserting that a proto message was
containing another one, by asserting string
containment. However on Windows the one method was
using CRLF line endings while the other was using
LF.
Fixes half of https://github.com/bazelbuild/bazel/issues/2025
--
MOS_MIGRATED_REVID=138175575
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/buildeventstream/transports/TextFormatFileTransportTest.java | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/buildeventstream/transports/TextFormatFileTransportTest.java b/src/test/java/com/google/devtools/build/lib/buildeventstream/transports/TextFormatFileTransportTest.java index 798e8557c8..bb1d1fd334 100644 --- a/src/test/java/com/google/devtools/build/lib/buildeventstream/transports/TextFormatFileTransportTest.java +++ b/src/test/java/com/google/devtools/build/lib/buildeventstream/transports/TextFormatFileTransportTest.java @@ -83,9 +83,17 @@ public class TextFormatFileTransportTest { transport.close(); String contents = - Joiner.on(System.lineSeparator()).join(Files.readLines(output, StandardCharsets.UTF_8)); - assertThat(contents).contains(TextFormat.printToString(started)); - assertThat(contents).contains(TextFormat.printToString(progress)); - assertThat(contents).contains(TextFormat.printToString(completed)); + trimLines( + Joiner.on(System.lineSeparator()) + .join(Files.readLines(output, StandardCharsets.UTF_8))); + + assertThat(contents).contains(trimLines(TextFormat.printToString(started))); + assertThat(contents).contains(trimLines(TextFormat.printToString(progress))); + assertThat(contents).contains(trimLines(TextFormat.printToString(completed))); + } + + private static String trimLines(String text) { + // Replace CRLF with LF and trim leading and trailing spaces. + return text.replaceAll("\\r", "").replaceAll(" *\\n *", "\n"); } } |