Skylark stack traces are now displayed in Python format.

--
MOS_MIGRATED_REVID=101572295
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 1a489d2..29a9459 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
@@ -42,18 +42,35 @@
   }
 
   @Test
+  public void testStackTraceSkipBuiltInOnly() throws Exception {
+    // The error message should not include the stack trace when there is
+    // only one built-in function.
+    new SkylarkTest()
+        .testIfExactError(
+            "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",
+            "'test'.index(1)");
+  }
+
+  @Test
   public void testStackTrace() throws Exception {
-    new SkylarkTest().testIfExactError(
-        "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\n"
-        + "\tin string.index [Built-In]\n"
-        + "\tin bar [4:4]\n"
-        + "\tin foo [2:4]",
-        "def foo():",
-        "   bar(1)",
-        "def bar(x):",
-        "   'test'.index(x)",
-        "foo()");
+    // Unlike SkylarintegrationTests#testStackTraceErrorInFunction(), this test
+    // has neither a BUILD nor a bzl file.
+    new SkylarkTest()
+        .testIfExactError(
+            "Traceback (most recent call last):\n"
+                + "\tFile \"<unknown>\", line 2, in foo\n"
+                + "\t\tbar\n"
+                + "\tFile \"<unknown>\", line 4, in bar\n"
+                + "\t\tstring.index\n"
+                + "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",
+            "def foo():",
+            "   bar(1)",
+            "def bar(x):",
+            "   'test'.index(x)",
+            "foo()");
   }
 
   @Test
diff --git a/src/test/java/com/google/devtools/build/lib/syntax/SkylarkEvaluationTest.java b/src/test/java/com/google/devtools/build/lib/syntax/SkylarkEvaluationTest.java
index 22c7153..b11866d 100644
--- a/src/test/java/com/google/devtools/build/lib/syntax/SkylarkEvaluationTest.java
+++ b/src/test/java/com/google/devtools/build/lib/syntax/SkylarkEvaluationTest.java
@@ -283,8 +283,11 @@
   public void testForNotIterable() throws Exception {
     new SkylarkTest()
         .update("mock", new Mock())
-        .testIfExactError("type 'int' is not iterable", "def func():",
-            "  for i in mock.value_of('1'): a = i", "func()\n");
+        .testIfErrorContains(
+            "type 'int' is not iterable",
+            "def func():",
+            "  for i in mock.value_of('1'): a = i",
+            "func()\n");
   }
 
   @Test
@@ -777,14 +780,16 @@
 
   @Test
   public void testListIndexAsLValueAsLValue() throws Exception {
-    new SkylarkTest().testIfExactError("unsupported operand type(s) for +: 'list' and 'dict'",
-        "def id(l):",
-        "  return l",
-        "def func():",
-        "  l = id([1])",
-        "  l[0] = 2",
-        "  return l",
-        "l = func()");
+    new SkylarkTest()
+        .testIfErrorContains(
+            "unsupported operand type(s) for +: 'list' and 'dict'",
+            "def id(l):",
+            "  return l",
+            "def func():",
+            "  l = id([1])",
+            "  l[0] = 2",
+            "  return l",
+            "l = func()");
   }
 
   @Test
@@ -987,23 +992,32 @@
   @Override
   @Test
   public void testListComprehensionsMultipleVariablesFail() throws Exception {
-    new SkylarkTest().testIfExactError("lvalue has length 3, but rvalue has has length 2",
-        "def foo (): return [x + y for x, y, z in [(1, 2), (3, 4)]]",
-        "foo()");
+    new SkylarkTest()
+        .testIfErrorContains(
+            "lvalue has length 3, but rvalue has has length 2",
+            "def foo (): return [x + y for x, y, z in [(1, 2), (3, 4)]]",
+            "foo()");
 
-    new SkylarkTest().testIfExactError("type 'int' is not a collection",
-        "def bar (): return [x + y for x, y in (1, 2)]",
-        "bar()");
+    new SkylarkTest()
+        .testIfErrorContains(
+            "type 'int' is not a collection",
+            "def bar (): return [x + y for x, y in (1, 2)]",
+            "bar()");
 
-    new SkylarkTest().testIfExactError("lvalue has length 3, but rvalue has has length 2",
-        "[x + y for x, y, z in [(1, 2), (3, 4)]]");
+    new SkylarkTest()
+        .testIfErrorContains(
+            "lvalue has length 3, but rvalue has has length 2",
+            "[x + y for x, y, z in [(1, 2), (3, 4)]]");
 
     // can't reuse the same local variable twice(!)
-    new SkylarkTest().testIfExactError("ERROR 2:1: Variable x is read only",
-        "[x + y for x, y in (1, 2)]", "[x + y for x, y in (1, 2)]");
+    new SkylarkTest()
+        .testIfErrorContains(
+            "ERROR 2:1: Variable x is read only",
+            "[x + y for x, y in (1, 2)]",
+            "[x + y for x, y in (1, 2)]");
 
-    new SkylarkTest().testIfExactError("type 'int' is not a collection",
-        "[x2 + y2 for x2, y2 in (1, 2)]");
+    new SkylarkTest()
+        .testIfErrorContains("type 'int' is not a collection", "[x2 + y2 for x2, y2 in (1, 2)]");
   }
 
   @Override