aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Nathan Harmata <nharmata@google.com>2015-10-09 13:16:08 +0000
committerGravatar Kristina Chodorow <kchodorow@google.com>2015-10-09 14:41:54 +0000
commit3c74af02c9ab519fa9551bf518c834f77babd8a4 (patch)
treecc2df1c2488f4eea81422c004fa1c87f92603c67
parentb9321901f2cb457c08037193154bdc7e5b7f9c5e (diff)
Description redacted.
-- MOS_MIGRATED_REVID=105050723
-rw-r--r--src/main/java/com/google/devtools/build/lib/vfs/Path.java2
-rw-r--r--src/test/java/com/google/devtools/build/lib/vfs/PathTest.java8
2 files changed, 9 insertions, 1 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/vfs/Path.java b/src/main/java/com/google/devtools/build/lib/vfs/Path.java
index 8b8e9c0c23..aac68ee8b0 100644
--- a/src/main/java/com/google/devtools/build/lib/vfs/Path.java
+++ b/src/main/java/com/google/devtools/build/lib/vfs/Path.java
@@ -1113,7 +1113,7 @@ public class Path implements Comparable<Path>, Serializable {
previousb = b;
a = a.getParentDirectory();
b = b.getParentDirectory();
- } while (a != b); // This has to happen eventually.
+ } while (!a.equals(b)); // This has to happen eventually.
return previousa.name.compareTo(previousb.name);
}
}
diff --git a/src/test/java/com/google/devtools/build/lib/vfs/PathTest.java b/src/test/java/com/google/devtools/build/lib/vfs/PathTest.java
index 75c89eb6f0..61f8c0f601 100644
--- a/src/test/java/com/google/devtools/build/lib/vfs/PathTest.java
+++ b/src/test/java/com/google/devtools/build/lib/vfs/PathTest.java
@@ -291,6 +291,14 @@ public class PathTest {
assertTrue(p2.startsWith(dsP1));
assertTrue(dsP2.startsWith(p1));
assertTrue(dsP2.startsWith(dsP1));
+
+ // Regression test for a very specific bug in compareTo involving our incorrect usage of
+ // reference equality rather than logical equality.
+ String relativePathStringA = "child/grandchildA";
+ String relativePathStringB = "child/grandchildB";
+ assertEquals(
+ p1.getRelative(relativePathStringA).compareTo(p1.getRelative(relativePathStringB)),
+ p1.getRelative(relativePathStringA).compareTo(dsP1.getRelative(relativePathStringB)));
} finally {
Path.setFileSystemForSerialization(oldFileSystem);
}