aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Yun Peng <pcloudy@google.com>2016-09-09 09:11:42 +0000
committerGravatar Kristina Chodorow <kchodorow@google.com>2016-09-09 14:16:27 +0000
commite7e55bb3ab5ab4f3d81cdae2635f08a3772e20b5 (patch)
tree27ae97bcafa7945e41b9493f316023140a11729b
parent1aa9295b41bb3669745d13c18f6826950279d582 (diff)
Fixed SkylarkTests on Windows
Fixed #1729 -- Change-Id: I4c4e8bf351eb8d18aeb8345542f92c5c47596a86 Reviewed-on: https://bazel-review.googlesource.com/#/c/5930 MOS_MIGRATED_REVID=132652736
-rw-r--r--src/main/java/com/google/devtools/build/lib/syntax/EvalExceptionWithStackTrace.java3
-rw-r--r--src/test/java/com/google/devtools/build/lib/skylark/SkylarkAspectsTest.java9
-rw-r--r--src/test/java/com/google/devtools/build/lib/skylark/SkylarkIntegrationTest.java9
-rw-r--r--src/test/java/com/google/devtools/build/lib/syntax/MethodLibraryTest.java32
4 files changed, 33 insertions, 20 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/EvalExceptionWithStackTrace.java b/src/main/java/com/google/devtools/build/lib/syntax/EvalExceptionWithStackTrace.java
index 3fbbe9486d..f9d75bbce5 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/EvalExceptionWithStackTrace.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/EvalExceptionWithStackTrace.java
@@ -16,7 +16,6 @@ package com.google.devtools.build.lib.syntax;
import com.google.common.base.Joiner;
import com.google.devtools.build.lib.events.Location;
import com.google.devtools.build.lib.util.Preconditions;
-
import java.util.Deque;
import java.util.LinkedList;
import java.util.Objects;
@@ -243,7 +242,7 @@ public class EvalExceptionWithStackTrace extends EvalException {
}
addMessage(output, message);
- return Joiner.on("\n").join(output);
+ return Joiner.on(System.lineSeparator()).join(output);
}
/**
diff --git a/src/test/java/com/google/devtools/build/lib/skylark/SkylarkAspectsTest.java b/src/test/java/com/google/devtools/build/lib/skylark/SkylarkAspectsTest.java
index c13eac8f37..3a3638380d 100644
--- a/src/test/java/com/google/devtools/build/lib/skylark/SkylarkAspectsTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skylark/SkylarkAspectsTest.java
@@ -417,13 +417,16 @@ public class SkylarkAspectsTest extends AnalysisTestCase {
assertContainsEvent(
"ERROR /workspace/test/BUILD:1:1: in "
+ "//test:aspect.bzl%MyAspect aspect on java_library rule //test:xxx: \n"
- + "Traceback (most recent call last):\n"
+ + "Traceback (most recent call last):"
+ + LINE_SEPARATOR
+ "\tFile \"/workspace/test/BUILD\", line 1"
+ LINE_SEPARATOR
- + "\t\t//test:aspect.bzl%MyAspect(...)\n"
+ + "\t\t//test:aspect.bzl%MyAspect(...)"
+ + LINE_SEPARATOR
+ "\tFile \"/workspace/test/aspect.bzl\", line 2, in _impl"
+ LINE_SEPARATOR
- + "\t\t1 / 0\n"
+ + "\t\t1 / 0"
+ + LINE_SEPARATOR
+ "integer division by zero");
}
diff --git a/src/test/java/com/google/devtools/build/lib/skylark/SkylarkIntegrationTest.java b/src/test/java/com/google/devtools/build/lib/skylark/SkylarkIntegrationTest.java
index 338794109a..a140187290 100644
--- a/src/test/java/com/google/devtools/build/lib/skylark/SkylarkIntegrationTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skylark/SkylarkIntegrationTest.java
@@ -220,7 +220,8 @@ public class SkylarkIntegrationTest extends BuildViewTestCase {
public void testStackTraceErrorInFunction() throws Exception {
runStackTraceTest(
"str",
- "\t\tstr.index(1)\n"
+ "\t\tstr.index(1)"
+ + System.lineSeparator()
+ "Method string.index(sub: string, start: int, end: int or NoneType) is not "
+ "applicable for arguments (int, int, NoneType): 'sub' is int, "
+ "but should be string");
@@ -228,13 +229,15 @@ public class SkylarkIntegrationTest extends BuildViewTestCase {
@Test
public void testStackTraceMissingMethod() throws Exception {
- runStackTraceTest("None", "\t\tNone.index(1)\n" + "Type NoneType has no function index(int)");
+ runStackTraceTest(
+ "None",
+ "\t\tNone.index(1)" + System.lineSeparator() + "Type NoneType has no function index(int)");
}
protected void runStackTraceTest(String object, String errorMessage) throws Exception {
reporter.removeHandler(failFastHandler);
String expectedTrace =
- Joiner.on("\n")
+ Joiner.on(System.lineSeparator())
.join(
"Traceback (most recent call last):",
"\tFile \"/workspace/test/skylark/BUILD\", line 3",
diff --git a/src/test/java/com/google/devtools/build/lib/syntax/MethodLibraryTest.java b/src/test/java/com/google/devtools/build/lib/syntax/MethodLibraryTest.java
index 5f994dbd1c..0866a286f8 100644
--- a/src/test/java/com/google/devtools/build/lib/syntax/MethodLibraryTest.java
+++ b/src/test/java/com/google/devtools/build/lib/syntax/MethodLibraryTest.java
@@ -351,14 +351,17 @@ public class MethodLibraryTest extends EvaluationTestCase {
public void testStackTraceLocation() throws Exception {
new SkylarkTest()
.testIfErrorContains(
- "Traceback (most recent call last):\n\t"
- + "File \"<unknown>\", line 8"
+ "Traceback (most recent call last):"
+ LINE_SEPARATOR
- + "\t\tfoo()\n\t"
- + "File \"<unknown>\", line 2, in foo"
+ + "\tFile \"<unknown>\", line 8"
+ LINE_SEPARATOR
- + "\t\tbar(1)\n\t"
- + "File \"<unknown>\", line 7, in bar"
+ + "\t\tfoo()"
+ + LINE_SEPARATOR
+ + "\tFile \"<unknown>\", line 2, in foo"
+ + LINE_SEPARATOR
+ + "\t\tbar(1)"
+ + LINE_SEPARATOR
+ + "\tFile \"<unknown>\", line 7, in bar"
+ LINE_SEPARATOR
+ "\t\t'test'.index(x)",
"def foo():",
@@ -377,8 +380,9 @@ public class MethodLibraryTest extends EvaluationTestCase {
.testIfErrorContains(
"File \"<unknown>\", line 5"
+ LINE_SEPARATOR
- + "\t\tfoo()\n\t"
- + "File \"<unknown>\", line 3, in foo"
+ + "\t\tfoo()"
+ + LINE_SEPARATOR
+ + "\tFile \"<unknown>\", line 3, in foo"
+ LINE_SEPARATOR
+ "\t\ts[0]",
"def foo():",
@@ -405,16 +409,20 @@ public class MethodLibraryTest extends EvaluationTestCase {
// has neither a BUILD nor a bzl file.
new SkylarkTest()
.testIfExactError(
- "Traceback (most recent call last):\n"
+ "Traceback (most recent call last):"
+ + LINE_SEPARATOR
+ "\tFile \"<unknown>\", line 6"
+ LINE_SEPARATOR
- + "\t\tfoo()\n"
+ + "\t\tfoo()"
+ + LINE_SEPARATOR
+ "\tFile \"<unknown>\", line 2, in foo"
+ LINE_SEPARATOR
- + "\t\tbar(1)\n"
+ + "\t\tbar(1)"
+ + LINE_SEPARATOR
+ "\tFile \"<unknown>\", line 5, in bar"
+ LINE_SEPARATOR
- + "\t\t'test'.index(x)\n"
+ + "\t\t'test'.index(x)"
+ + LINE_SEPARATOR
+ "Method string.index(sub: string, start: int, end: int or NoneType) "
+ "is not applicable "
+ "for arguments (int, int, NoneType): 'sub' is int, but should be string",