aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/build
diff options
context:
space:
mode:
authorGravatar John Cater <jcater@google.com>2017-07-05 14:28:12 -0400
committerGravatar John Cater <jcater@google.com>2017-07-06 07:13:29 -0400
commita15d648410000cedbde9578c9ee22a023f1b96df (patch)
tree539f31141da2fab31c0c94b8368531d700f5f0ad /src/test/java/com/google/devtools/build
parent2db52703129b010bb864d7ee4180c7c598239f69 (diff)
Fix LocalRepositoryLookupFunction to normalize paths so they are compared properly.
Part of #2811. Change-Id: I15da53d1f6ec7f4a41f5d14fdd9dafd5ad82f9fc PiperOrigin-RevId: 160982624
Diffstat (limited to 'src/test/java/com/google/devtools/build')
-rw-r--r--src/test/java/com/google/devtools/build/lib/skyframe/LocalRepositoryLookupFunctionTest.java40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/LocalRepositoryLookupFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/LocalRepositoryLookupFunctionTest.java
index c8c5bae031..12230c48d9 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/LocalRepositoryLookupFunctionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/LocalRepositoryLookupFunctionTest.java
@@ -164,6 +164,46 @@ public class LocalRepositoryLookupFunctionTest extends FoundationTestCase {
}
@Test
+ public void testLocalRepository_absolutePath() throws Exception {
+ scratch.overwriteFile("WORKSPACE", "local_repository(name='local', path='/abs/local/repo')");
+ scratch.file("/abs/local/repo/WORKSPACE");
+ scratch.file("/abs/local/repo/BUILD");
+
+ LocalRepositoryLookupValue repositoryLookupValue =
+ lookupDirectory(
+ RootedPath.toRootedPath(
+ rootDirectory.getRelative("/abs"), PathFragment.create("local/repo")));
+ assertThat(repositoryLookupValue).isNotNull();
+ assertThat(repositoryLookupValue.getRepository().getName()).isEqualTo("@local");
+ }
+
+ @Test
+ public void testLocalRepository_nonNormalizedPath() throws Exception {
+ scratch.overwriteFile("WORKSPACE", "local_repository(name='local', path='./local/repo')");
+ scratch.file("local/repo/WORKSPACE");
+ scratch.file("local/repo/BUILD");
+
+ LocalRepositoryLookupValue repositoryLookupValue =
+ lookupDirectory(RootedPath.toRootedPath(rootDirectory, PathFragment.create("local/repo")));
+ assertThat(repositoryLookupValue).isNotNull();
+ assertThat(repositoryLookupValue.getRepository().getName()).isEqualTo("@local");
+ }
+
+ @Test
+ public void testLocalRepository_absolutePath_nonNormalized() throws Exception {
+ scratch.overwriteFile("WORKSPACE", "local_repository(name='local', path='/abs/local/./repo')");
+ scratch.file("/abs/local/repo/WORKSPACE");
+ scratch.file("/abs/local/repo/BUILD");
+
+ LocalRepositoryLookupValue repositoryLookupValue =
+ lookupDirectory(
+ RootedPath.toRootedPath(
+ rootDirectory.getRelative("/abs"), PathFragment.create("local/repo")));
+ assertThat(repositoryLookupValue).isNotNull();
+ assertThat(repositoryLookupValue.getRepository().getName()).isEqualTo("@local");
+ }
+
+ @Test
public void testLocalRepositorySubPackage() throws Exception {
scratch.overwriteFile("WORKSPACE", "local_repository(name='local', path='local/repo')");
scratch.file("local/repo/WORKSPACE");