diff options
author | Florian Weikert <fwe@google.com> | 2016-09-06 14:54:22 +0000 |
---|---|---|
committer | Kristina Chodorow <kchodorow@google.com> | 2016-09-06 15:39:59 +0000 |
commit | cb3d799cc89276c9b1d9185e5556df870abec1c9 (patch) | |
tree | 84766f86959474ca9844b0c9c208c285d578200f /src/test | |
parent | 304f5cbfac3c8cc272a0c43d3077a4cff0e1cc5a (diff) |
Skylark no longer crashes when the default value of an attribute is a label string that points to a remote repository.
Fixes #1442.
--
MOS_MIGRATED_REVID=132320130
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/skylark/SkylarkIntegrationTest.java | 22 |
1 files changed, 22 insertions, 0 deletions
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 6d156f23cb..338794109a 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 @@ -64,6 +64,28 @@ public class SkylarkIntegrationTest extends BuildViewTestCase { } @Test + public void testRemoteLabelAsDefaultAttributeValue() throws Exception { + scratch.file( + "test/skylark/extension.bzl", + "def _impl(ctx):", + " pass", + "my_rule = rule(implementation = _impl,", + " attrs = { 'dep' : attr.label_list(default=[\"@r//:t\"]) })"); + + // We are only interested in whether the label string in the default value can be converted + // to a proper Label without an exception (see GitHub issue #1442). + // Consequently, we expect getTarget() to fail later since the repository does not exist. + checkError( + "test/skylark", + "the_rule", + "no such package '@r//': error loading package 'external': " + + "The repository named 'r' could not be resolved", + "load('/test/skylark/extension', 'my_rule')", + "", + "my_rule(name='the_rule')"); + } + + @Test public void testSameMethodNames() throws Exception { // The alias feature of load() may hide the fact that two methods in the stack trace have the // same name. This is perfectly legal as long as these two methods are actually distinct. |