diff options
author | 2016-07-05 10:08:54 +0000 | |
---|---|---|
committer | 2016-07-05 10:27:50 +0000 | |
commit | 50681c1b6cca1856f5f7b401ee5c757f22aa2e54 (patch) | |
tree | fb9211bd4f1a7961f023ad0b885a25ff2b499455 /src/test/java/com/google/devtools/build/lib/skylark | |
parent | c3112c2dea86cc64c6f68f4b7c9c620e014e620e (diff) |
Add allow_single_file in attr.label, deprecate single_file.
--
MOS_MIGRATED_REVID=126620866
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/skylark')
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleClassFunctionsTest.java | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleClassFunctionsTest.java b/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleClassFunctionsTest.java index 0716654b14..f73d1b9301 100644 --- a/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleClassFunctionsTest.java +++ b/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleClassFunctionsTest.java @@ -166,11 +166,28 @@ public class SkylarkRuleClassFunctionsTest extends SkylarkTestCase { } @Test + public void testAttrAllowedSingleFileTypesWrongType() throws Exception { + checkErrorContains( + "allow_single_file should be a boolean or a string list", + "attr.label(allow_single_file = 18)"); + } + + @Test public void testAttrWithList() throws Exception { Attribute attr = evalAttributeDefinition("attr.label_list(allow_files = ['.xml'])") .build("a1"); assertTrue(attr.getAllowedFileTypesPredicate().apply("a.xml")); assertFalse(attr.getAllowedFileTypesPredicate().apply("a.txt")); + assertFalse(attr.isSingleArtifact()); + } + + @Test + public void testAttrSingleFileWithList() throws Exception { + Attribute attr = evalAttributeDefinition("attr.label(allow_single_file = ['.xml'])") + .build("a1"); + assertTrue(attr.getAllowedFileTypesPredicate().apply("a.xml")); + assertFalse(attr.getAllowedFileTypesPredicate().apply("a.txt")); + assertTrue(attr.isSingleArtifact()); } @Test |