aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/build/lib/util/DependencySetTest.java
diff options
context:
space:
mode:
authorGravatar Yun Peng <pcloudy@google.com>2016-05-09 11:08:25 +0000
committerGravatar Klaus Aehlig <aehlig@google.com>2016-05-09 13:05:55 +0000
commit352f7e7b5f3adae4128a6041bdfe1324c433ce28 (patch)
tree05855bb5d817c4cedbaa3043f54965a59f50ca9c /src/test/java/com/google/devtools/build/lib/util/DependencySetTest.java
parent0e27fded9d74e86d7fee412995d75601ed3d4380 (diff)
Support case-insensitive comparision in Path.java with WindowsFileSystem
Since file path is case-insensitive on Windows, we need to support this. Also fixed .d file inclusions check in CppCompileAction.java on Windows -- MOS_MIGRATED_REVID=121823250
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/util/DependencySetTest.java')
-rw-r--r--src/test/java/com/google/devtools/build/lib/util/DependencySetTest.java73
1 files changed, 36 insertions, 37 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/util/DependencySetTest.java b/src/test/java/com/google/devtools/build/lib/util/DependencySetTest.java
index db1f289cc8..fd33d34bc6 100644
--- a/src/test/java/com/google/devtools/build/lib/util/DependencySetTest.java
+++ b/src/test/java/com/google/devtools/build/lib/util/DependencySetTest.java
@@ -17,11 +17,12 @@ import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
+import com.google.common.collect.ImmutableList;
import com.google.common.collect.Sets;
import com.google.devtools.build.lib.testutil.Scratch;
+import com.google.devtools.build.lib.vfs.FileSystem;
import com.google.devtools.build.lib.vfs.FileSystemUtils;
import com.google.devtools.build.lib.vfs.Path;
-import com.google.devtools.build.lib.vfs.PathFragment;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -35,15 +36,17 @@ import java.util.Collection;
public class DependencySetTest {
private Scratch scratch = new Scratch();
+ private FileSystem fileSystem = scratch.getFileSystem();
+ private Path root = scratch.resolve("/");
private DependencySet newDependencySet() {
- return new DependencySet(scratch.resolve("/"));
+ return new DependencySet(root);
}
@Test
public void dotDParser_simple() throws Exception {
- PathFragment file1 = new PathFragment("/usr/local/blah/blah/genhello/hello.cc");
- PathFragment file2 = new PathFragment("/usr/local/blah/blah/genhello/hello.h");
+ Path file1 = fileSystem.getPath("/usr/local/blah/blah/genhello/hello.cc");
+ Path file2 = fileSystem.getPath("/usr/local/blah/blah/genhello/hello.h");
String filename = "hello.o";
Path dotd = scratch.file("/tmp/foo.d",
filename + ": \\",
@@ -56,8 +59,8 @@ public class DependencySetTest {
@Test
public void dotDParser_simple_crlf() throws Exception {
- PathFragment file1 = new PathFragment("/usr/local/blah/blah/genhello/hello.cc");
- PathFragment file2 = new PathFragment("/usr/local/blah/blah/genhello/hello.h");
+ Path file1 = fileSystem.getPath("/usr/local/blah/blah/genhello/hello.cc");
+ Path file2 = fileSystem.getPath("/usr/local/blah/blah/genhello/hello.h");
String filename = "hello.o";
Path dotd = scratch.file("/tmp/foo.d",
filename + ": \\\r",
@@ -70,8 +73,8 @@ public class DependencySetTest {
@Test
public void dotDParser_simple_cr() throws Exception {
- PathFragment file1 = new PathFragment("/usr/local/blah/blah/genhello/hello.cc");
- PathFragment file2 = new PathFragment("/usr/local/blah/blah/genhello/hello.h");
+ Path file1 = fileSystem.getPath("/usr/local/blah/blah/genhello/hello.cc");
+ Path file2 = fileSystem.getPath("/usr/local/blah/blah/genhello/hello.h");
String filename = "hello.o";
Path dotd = scratch.file("/tmp/foo.d",
filename + ": \\\r"
@@ -84,8 +87,8 @@ public class DependencySetTest {
@Test
public void dotDParser_leading_crlf() throws Exception {
- PathFragment file1 = new PathFragment("/usr/local/blah/blah/genhello/hello.cc");
- PathFragment file2 = new PathFragment("/usr/local/blah/blah/genhello/hello.h");
+ Path file1 = fileSystem.getPath("/usr/local/blah/blah/genhello/hello.cc");
+ Path file2 = fileSystem.getPath("/usr/local/blah/blah/genhello/hello.h");
String filename = "hello.o";
Path dotd = scratch.file("/tmp/foo.d",
"\r\n" + filename + ": \\\r\n"
@@ -98,10 +101,10 @@ public class DependencySetTest {
@Test
public void dotDParser_oddFormatting() throws Exception {
- PathFragment file1 = new PathFragment("/usr/local/blah/blah/genhello/hello.cc");
- PathFragment file2 = new PathFragment("/usr/local/blah/blah/genhello/hello.h");
- PathFragment file3 = new PathFragment("/usr/local/blah/blah/genhello/other.h");
- PathFragment file4 = new PathFragment("/usr/local/blah/blah/genhello/onemore.h");
+ Path file1 = fileSystem.getPath("/usr/local/blah/blah/genhello/hello.cc");
+ Path file2 = fileSystem.getPath("/usr/local/blah/blah/genhello/hello.h");
+ Path file3 = fileSystem.getPath("/usr/local/blah/blah/genhello/other.h");
+ Path file4 = fileSystem.getPath("/usr/local/blah/blah/genhello/onemore.h");
String filename = "hello.o";
Path dotd = scratch.file("/tmp/foo.d",
filename + ": " + file1 + " \\",
@@ -115,13 +118,13 @@ public class DependencySetTest {
@Test
public void dotDParser_relativeFilenames() throws Exception {
- PathFragment file1 = new PathFragment("hello.cc");
- PathFragment file2 = new PathFragment("hello.h");
+ Path file1 = root.getRelative("hello.cc");
+ Path file2 = root.getRelative("hello.h");
String filename = "hello.o";
Path dotd = scratch.file("/tmp/foo.d",
filename + ": \\",
- " " + file1 + " \\",
- " " + file2 + " ");
+ " " + file1.relativeTo(root) + " \\",
+ " " + file2.relativeTo(root) + " ");
DependencySet depset = newDependencySet().read(dotd);
assertThat(depset.getDependencies()).containsExactlyElementsIn(Sets.newHashSet(file1, file2));
assertEquals(depset.getOutputFileName(), filename);
@@ -131,7 +134,7 @@ public class DependencySetTest {
public void dotDParser_emptyFile() throws Exception {
Path dotd = scratch.file("/tmp/empty.d");
DependencySet depset = newDependencySet().read(dotd);
- Collection<PathFragment> headers = depset.getDependencies();
+ Collection<Path> headers = depset.getDependencies();
if (!headers.isEmpty()) {
fail("Not empty: " + headers.size() + " " + headers);
}
@@ -140,8 +143,8 @@ public class DependencySetTest {
@Test
public void dotDParser_multipleTargets() throws Exception {
- PathFragment file1 = new PathFragment("/usr/local/blah/blah/genhello/hello.cc");
- PathFragment file2 = new PathFragment("/usr/local/blah/blah/genhello/hello.h");
+ Path file1 = fileSystem.getPath("/usr/local/blah/blah/genhello/hello.cc");
+ Path file2 = fileSystem.getPath("/usr/local/blah/blah/genhello/hello.h");
Path dotd = scratch.file("/tmp/foo.d",
"hello.o: \\",
" " + file1,
@@ -160,9 +163,9 @@ public class DependencySetTest {
*/
@Test
public void dotDParser_duplicateStanza() throws Exception {
- PathFragment file1 = new PathFragment("/usr/local/blah/blah/genhello/hello.cc");
- PathFragment file2 = new PathFragment("/usr/local/blah/blah/genhello/hello.h");
- PathFragment file3 = new PathFragment("/usr/local/blah/blah/genhello/other.h");
+ Path file1 = fileSystem.getPath("/usr/local/blah/blah/genhello/hello.cc");
+ Path file2 = fileSystem.getPath("/usr/local/blah/blah/genhello/hello.h");
+ Path file3 = fileSystem.getPath("/usr/local/blah/blah/genhello/other.h");
Path dotd = scratch.file("/tmp/foo.d",
"hello.o: \\",
" " + file1 + " \\",
@@ -176,7 +179,7 @@ public class DependencySetTest {
@Test
public void dotDParser_errorOnNoTrailingNewline() throws Exception {
- PathFragment file1 = new PathFragment("/usr/local/blah/blah/genhello/hello.cc");
+ Path file1 = fileSystem.getPath("/usr/local/blah/blah/genhello/hello.cc");
Path dotd = scratch.file("/tmp/foo.d");
FileSystemUtils.writeContent(
dotd, ("hello.o: \\\n " + file1).getBytes(Charset.forName("UTF-8")));
@@ -190,15 +193,13 @@ public class DependencySetTest {
@Test
public void writeSet() throws Exception {
- PathFragment file1 = new PathFragment("/usr/local/blah/blah/genhello/hello.cc");
- PathFragment file2 = new PathFragment("/usr/local/blah/blah/genhello/hello.h");
- PathFragment file3 = new PathFragment("/usr/local/blah/blah/genhello/other.h");
+ Path file1 = fileSystem.getPath("/usr/local/blah/blah/genhello/hello.cc");
+ Path file2 = fileSystem.getPath("/usr/local/blah/blah/genhello/hello.h");
+ Path file3 = fileSystem.getPath("/usr/local/blah/blah/genhello/other.h");
String filename = "/usr/local/blah/blah/genhello/hello.o";
DependencySet depSet1 = newDependencySet();
- depSet1.addDependency(file1);
- depSet1.addDependency(file2);
- depSet1.addDependency(file3);
+ depSet1.addDependencies(ImmutableList.of(file1, file2, file3));
depSet1.setOutputFileName(filename);
Path outfile = scratch.resolve(filename);
@@ -219,13 +220,11 @@ public class DependencySetTest {
@Test
public void writeReadSet() throws Exception {
String filename = "/usr/local/blah/blah/genhello/hello.d";
- PathFragment file1 = new PathFragment("/usr/local/blah/blah/genhello/hello.cc");
- PathFragment file2 = new PathFragment("/usr/local/blah/blah/genhello/hello.h");
- PathFragment file3 = new PathFragment("/usr/local/blah/blah/genhello/other.h");
+ Path file1 = fileSystem.getPath("/usr/local/blah/blah/genhello/hello.cc");
+ Path file2 = fileSystem.getPath("/usr/local/blah/blah/genhello/hello.h");
+ Path file3 = fileSystem.getPath("/usr/local/blah/blah/genhello/other.h");
DependencySet depSet1 = newDependencySet();
- depSet1.addDependency(file1);
- depSet1.addDependency(file2);
- depSet1.addDependency(file3);
+ depSet1.addDependencies(ImmutableList.of(file1, file2, file3));
depSet1.setOutputFileName(filename);
Path dotd = scratch.resolve(filename);