aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/build/lib/syntax/SkylarkImportsTest.java
diff options
context:
space:
mode:
authorGravatar laurentlb <laurentlb@google.com>2018-03-01 08:07:14 -0800
committerGravatar Copybara-Service <copybara-piper@google.com>2018-03-01 08:09:26 -0800
commit940dbc531bf79907806bcf4f09543b3a2468d9b1 (patch)
tree5ee410c3cefa2e1913e57d2bd7b22235e13d2b72 /src/test/java/com/google/devtools/build/lib/syntax/SkylarkImportsTest.java
parent06e687495b4c85f86215c7cc7f1a01dc7f6709f9 (diff)
Remove --incompatible_load_argument_is_label flag
RELNOTES: Removed flag `--incompatible_load_argument_is_label`. PiperOrigin-RevId: 187479614
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/syntax/SkylarkImportsTest.java')
-rw-r--r--src/test/java/com/google/devtools/build/lib/syntax/SkylarkImportsTest.java64
1 files changed, 7 insertions, 57 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/syntax/SkylarkImportsTest.java b/src/test/java/com/google/devtools/build/lib/syntax/SkylarkImportsTest.java
index 3488047237..c1168dd380 100644
--- a/src/test/java/com/google/devtools/build/lib/syntax/SkylarkImportsTest.java
+++ b/src/test/java/com/google/devtools/build/lib/syntax/SkylarkImportsTest.java
@@ -66,25 +66,6 @@ public class SkylarkImportsTest {
/*expected path*/ "/some/skylark/file.bzl");
}
- @Test
- public void testValidAbsolutePath() throws Exception {
- String pathToTest = "/some/skylark/file";
- SkylarkImport importForPath = SkylarkImports.create(pathToTest);
-
- assertThat(importForPath.hasAbsolutePath()).named("hasAbsolutePath()").isTrue();
- assertThat(importForPath.getImportString()).named("getImportString()").isEqualTo(pathToTest);
-
- Label irrelevantContainingFile = Label.parseAbsoluteUnchecked("//another/path:BUILD");
- assertThat(importForPath.getAbsolutePath()).named("getAbsolutePath()")
- .isEqualTo(PathFragment.create("//some/skylark/file.bzl"));
-
- assertThat(importForPath.asPathFragment()).named("asPathFragment()")
- .isEqualTo(PathFragment.create("/some/skylark/file.bzl"));
-
- thrown.expect(IllegalStateException.class);
- importForPath.getLabel(irrelevantContainingFile);
- }
-
private void validRelativeLabelTest(String labelString,
String containingLabelString, String expectedLabelString, String expectedPathString)
throws Exception {
@@ -137,40 +118,6 @@ public class SkylarkImportsTest {
/*expected path*/ "subdir/containing/file.bzl");
}
- private void validRelativePathTest(String pathString, String containingLabelString,
- String expectedLabelString, String expectedPathString) throws Exception {
- SkylarkImport importForPath = SkylarkImports.create(pathString);
-
- assertThat(importForPath.hasAbsolutePath()).named("hasAbsolutePath()").isFalse();
-
- // The import label is relative to the parent's directory not the parent's package.
- Label containingLabel = Label.parseAbsolute(containingLabelString);
- assertThat(importForPath.getLabel(containingLabel)).named("getLabel()")
- .isEqualTo(Label.parseAbsolute(expectedLabelString));
-
- assertThat(importForPath.asPathFragment()).named("asPathFragment()")
- .isEqualTo(PathFragment.create(expectedPathString));
-
- thrown.expect(IllegalStateException.class);
- importForPath.getAbsolutePath();
- }
-
- @Test
- public void testValidRelativePathInPackageDir() throws Exception {
- validRelativePathTest("file",
- /*containing*/ "//some/skylark:BUILD",
- /*expected label*/ "//some/skylark:file.bzl",
- /*expected path*/ "file.bzl");
- }
-
- @Test
- public void testValidRelativePathInPackageSubdir() throws Exception {
- validRelativePathTest("file",
- /*containing*/ "//some/path/to:skylark/parent.bzl",
- /*expected label*/ "//some/path/to:skylark/file.bzl",
- /*expected path*/ "file.bzl");
- }
-
private void invalidImportTest(String importString, String expectedMsgPrefix) throws Exception {
thrown.expect(SkylarkImportSyntaxException.class);
thrown.expectMessage(startsWith(expectedMsgPrefix));
@@ -184,6 +131,11 @@ public class SkylarkImportsTest {
}
@Test
+ public void testInvalidPathSyntax() throws Exception {
+ invalidImportTest("some/path/foo.bzl", SkylarkImports.INVALID_PATH_SYNTAX);
+ }
+
+ @Test
public void testInvalidAbsoluteLabelSyntaxWithRepo() throws Exception {
// final '/' is illegal
invalidImportTest("@my_repo//some/skylark/:file.bzl", SkylarkImports.INVALID_LABEL_PREFIX);
@@ -227,16 +179,14 @@ public class SkylarkImportsTest {
@Test
public void testInvalidRelativePathInvalidFilename() throws Exception {
// tab character is invalid
- invalidImportTest("\tfile", SkylarkImports.INVALID_FILENAME_PREFIX);
+ invalidImportTest("\tfile", SkylarkImports.INVALID_PATH_SYNTAX);
}
@Test
public void serialization() throws Exception {
new SerializationTester(
SkylarkImports.create("//some/skylark:file.bzl"),
- SkylarkImports.create("/some/skylark/file"),
- SkylarkImports.create(":subdirectory/containing/file.bzl"),
- SkylarkImports.create("file"))
+ SkylarkImports.create(":subdirectory/containing/file.bzl"))
.runTests();
}
}