aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/com/google/devtools')
-rw-r--r--src/test/java/com/google/devtools/build/lib/actions/DigestUtilsTest.java14
-rw-r--r--src/test/java/com/google/devtools/build/lib/analysis/AnalysisWithIOExceptionsTest.java8
-rw-r--r--src/test/java/com/google/devtools/build/lib/exec/SingleBuildFileCacheTest.java35
-rw-r--r--src/test/java/com/google/devtools/build/lib/packages/PackageFactoryTest.java3
-rw-r--r--src/test/java/com/google/devtools/build/lib/packages/util/PackageFactoryTestBase.java6
-rw-r--r--src/test/java/com/google/devtools/build/lib/pkgcache/IOExceptionsTest.java77
-rw-r--r--src/test/java/com/google/devtools/build/lib/pkgcache/IncrementalLoadingTest.java12
-rw-r--r--src/test/java/com/google/devtools/build/lib/pkgcache/TargetPatternEvaluatorIOTest.java19
-rw-r--r--src/test/java/com/google/devtools/build/lib/skyframe/ASTFileLookupFunctionTest.java7
-rw-r--r--src/test/java/com/google/devtools/build/lib/skyframe/ArtifactFunctionTest.java7
-rw-r--r--src/test/java/com/google/devtools/build/lib/skyframe/ArtifactFunctionTestCase.java3
-rw-r--r--src/test/java/com/google/devtools/build/lib/skyframe/FileFunctionTest.java37
-rw-r--r--src/test/java/com/google/devtools/build/lib/skyframe/FilesystemValueCheckerTest.java5
-rw-r--r--src/test/java/com/google/devtools/build/lib/skyframe/GlobFunctionTest.java13
-rw-r--r--src/test/java/com/google/devtools/build/lib/skyframe/PackageFunctionTest.java35
-rw-r--r--src/test/java/com/google/devtools/build/lib/skyframe/ParallelBuilderTest.java88
-rw-r--r--src/test/java/com/google/devtools/build/lib/skyframe/SkyframeLabelVisitorTest.java2
-rw-r--r--src/test/java/com/google/devtools/build/lib/skyframe/SkyframeLabelVisitorTestCase.java8
-rw-r--r--src/test/java/com/google/devtools/build/lib/skyframe/TargetMarkerFunctionTest.java9
-rw-r--r--src/test/java/com/google/devtools/build/lib/skyframe/TreeArtifactMetadataTest.java3
-rw-r--r--src/test/java/com/google/devtools/build/lib/util/DependencySetWindowsTest.java40
-rw-r--r--src/test/java/com/google/devtools/build/lib/vfs/FileSystemTest.java41
-rw-r--r--src/test/java/com/google/devtools/build/lib/vfs/FileSystemUtilsTest.java16
-rw-r--r--src/test/java/com/google/devtools/build/lib/vfs/GlobTest.java21
-rw-r--r--src/test/java/com/google/devtools/build/lib/vfs/PathTrieTest.java78
-rw-r--r--src/test/java/com/google/devtools/build/lib/vfs/SearchPathTest.java2
-rw-r--r--src/test/java/com/google/devtools/build/lib/vfs/SymlinkAwareFileSystemTest.java24
-rw-r--r--src/test/java/com/google/devtools/build/lib/vfs/UnionFileSystemTest.java97
-rw-r--r--src/test/java/com/google/devtools/build/lib/vfs/UnixLocalPathTest.java11
-rw-r--r--src/test/java/com/google/devtools/build/lib/vfs/WindowsLocalPathTest.java39
-rw-r--r--src/test/java/com/google/devtools/build/lib/windows/WindowsFileSystemTest.java17
31 files changed, 367 insertions, 410 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/actions/DigestUtilsTest.java b/src/test/java/com/google/devtools/build/lib/actions/DigestUtilsTest.java
index 259e0f2088..6fee2c1061 100644
--- a/src/test/java/com/google/devtools/build/lib/actions/DigestUtilsTest.java
+++ b/src/test/java/com/google/devtools/build/lib/actions/DigestUtilsTest.java
@@ -25,6 +25,7 @@ import com.google.devtools.build.lib.testutil.TestUtils;
import com.google.devtools.build.lib.vfs.FileSystem;
import com.google.devtools.build.lib.vfs.FileSystem.HashFunction;
import com.google.devtools.build.lib.vfs.FileSystemUtils;
+import com.google.devtools.build.lib.vfs.LocalPath;
import com.google.devtools.build.lib.vfs.Path;
import com.google.devtools.build.lib.vfs.inmemoryfs.InMemoryFileSystem;
import java.io.IOException;
@@ -58,7 +59,7 @@ public class DigestUtilsTest {
FileSystem myfs =
new InMemoryFileSystem(BlazeClock.instance(), hf) {
@Override
- protected byte[] getDigest(Path path, HashFunction hashFunction) throws IOException {
+ protected byte[] getDigest(LocalPath path, HashFunction hashFunction) throws IOException {
try {
barrierLatch.countDown();
readyLatch.countDown();
@@ -72,7 +73,8 @@ public class DigestUtilsTest {
}
@Override
- protected byte[] getFastDigest(Path path, HashFunction hashFunction) throws IOException {
+ protected byte[] getFastDigest(LocalPath path, HashFunction hashFunction)
+ throws IOException {
return fastDigest ? super.getDigest(path, hashFunction) : null;
}
};
@@ -131,7 +133,7 @@ public class DigestUtilsTest {
FileSystem myFS =
new InMemoryFileSystem(BlazeClock.instance(), hf) {
@Override
- protected byte[] getFastDigest(Path path, HashFunction hashFunction)
+ protected byte[] getFastDigest(LocalPath path, HashFunction hashFunction)
throws IOException {
// Digest functions have more than 3 bytes, usually at least 16.
return malformed;
@@ -139,6 +141,7 @@ public class DigestUtilsTest {
};
Path path = myFS.getPath("/file");
FileSystemUtils.writeContentAsLatin1(path, "a");
+
byte[] result = DigestUtils.getDigestOrFail(path, 1);
assertThat(result).isEqualTo(path.getDigest());
assertThat(result).isNotSameAs(malformed);
@@ -221,13 +224,14 @@ public class DigestUtilsTest {
FileSystem tracingFileSystem =
new InMemoryFileSystem(BlazeClock.instance()) {
@Override
- protected byte[] getFastDigest(Path path, HashFunction hashFunction) throws IOException {
+ protected byte[] getFastDigest(LocalPath path, HashFunction hashFunction)
+ throws IOException {
getFastDigestCounter.incrementAndGet();
return null;
}
@Override
- protected byte[] getDigest(Path path, HashFunction hashFunction) throws IOException {
+ protected byte[] getDigest(LocalPath path, HashFunction hashFunction) throws IOException {
getDigestCounter.incrementAndGet();
return super.getDigest(path, hashFunction);
}
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/AnalysisWithIOExceptionsTest.java b/src/test/java/com/google/devtools/build/lib/analysis/AnalysisWithIOExceptionsTest.java
index 67d9b6254a..b7711aaa8d 100644
--- a/src/test/java/com/google/devtools/build/lib/analysis/AnalysisWithIOExceptionsTest.java
+++ b/src/test/java/com/google/devtools/build/lib/analysis/AnalysisWithIOExceptionsTest.java
@@ -19,7 +19,7 @@ import com.google.devtools.build.lib.analysis.util.AnalysisTestCase;
import com.google.devtools.build.lib.clock.BlazeClock;
import com.google.devtools.build.lib.vfs.FileStatus;
import com.google.devtools.build.lib.vfs.FileSystem;
-import com.google.devtools.build.lib.vfs.Path;
+import com.google.devtools.build.lib.vfs.LocalPath;
import com.google.devtools.build.lib.vfs.inmemoryfs.InMemoryFileSystem;
import java.io.IOException;
import java.util.function.Function;
@@ -30,15 +30,15 @@ import org.junit.runners.JUnit4;
/** {@link AnalysisTestCase} with custom filesystem that can throw on stat if desired. */
@RunWith(JUnit4.class)
public class AnalysisWithIOExceptionsTest extends AnalysisTestCase {
- private static final Function<Path, String> NULL_FUNCTION = (path) -> null;
+ private static final Function<LocalPath, String> NULL_FUNCTION = (path) -> null;
- private Function<Path, String> crashMessage = NULL_FUNCTION;
+ private Function<LocalPath, String> crashMessage = NULL_FUNCTION;
@Override
protected FileSystem createFileSystem() {
return new InMemoryFileSystem(BlazeClock.instance()) {
@Override
- public FileStatus stat(Path path, boolean followSymlinks) throws IOException {
+ public FileStatus stat(LocalPath path, boolean followSymlinks) throws IOException {
String crash = crashMessage.apply(path);
if (crash != null) {
throw new IOException(crash);
diff --git a/src/test/java/com/google/devtools/build/lib/exec/SingleBuildFileCacheTest.java b/src/test/java/com/google/devtools/build/lib/exec/SingleBuildFileCacheTest.java
index f9d0372e0a..023b41e57c 100644
--- a/src/test/java/com/google/devtools/build/lib/exec/SingleBuildFileCacheTest.java
+++ b/src/test/java/com/google/devtools/build/lib/exec/SingleBuildFileCacheTest.java
@@ -24,6 +24,7 @@ import com.google.devtools.build.lib.actions.DigestOfDirectoryException;
import com.google.devtools.build.lib.testutil.Suite;
import com.google.devtools.build.lib.testutil.TestSpec;
import com.google.devtools.build.lib.vfs.FileSystem;
+import com.google.devtools.build.lib.vfs.LocalPath;
import com.google.devtools.build.lib.vfs.Path;
import com.google.devtools.build.lib.vfs.inmemoryfs.InMemoryFileSystem;
import com.google.protobuf.ByteString;
@@ -54,23 +55,23 @@ public class SingleBuildFileCacheTest {
public final void setUp() throws Exception {
calls = new HashMap<>();
md5Overrides = new HashMap<>();
- fs = new InMemoryFileSystem() {
- @Override
- protected InputStream getInputStream(Path path) throws IOException {
- int c = calls.containsKey(path.toString())
- ? calls.get(path.toString()) : 0;
- c++;
- calls.put(path.toString(), c);
- return super.getInputStream(path);
- }
-
- @Override
- protected byte[] getDigest(Path path, HashFunction hf) throws IOException {
- assertThat(hf).isEqualTo(HashFunction.MD5);
- byte[] override = md5Overrides.get(path.getPathString());
- return override != null ? override : super.getDigest(path, hf);
- }
- };
+ fs =
+ new InMemoryFileSystem() {
+ @Override
+ protected InputStream getInputStream(LocalPath path) throws IOException {
+ int c = calls.containsKey(path.toString()) ? calls.get(path.toString()) : 0;
+ c++;
+ calls.put(path.toString(), c);
+ return super.getInputStream(path);
+ }
+
+ @Override
+ protected byte[] getDigest(LocalPath path, HashFunction hf) throws IOException {
+ assertThat(hf).isEqualTo(HashFunction.MD5);
+ byte[] override = md5Overrides.get(path.getPathString());
+ return override != null ? override : super.getDigest(path, hf);
+ }
+ };
underTest = new SingleBuildFileCache("/", fs);
Path root = fs.getRootDirectory();
Path file = root.getChild("empty");
diff --git a/src/test/java/com/google/devtools/build/lib/packages/PackageFactoryTest.java b/src/test/java/com/google/devtools/build/lib/packages/PackageFactoryTest.java
index bbb8be7e82..7f1f342d5e 100644
--- a/src/test/java/com/google/devtools/build/lib/packages/PackageFactoryTest.java
+++ b/src/test/java/com/google/devtools/build/lib/packages/PackageFactoryTest.java
@@ -28,6 +28,7 @@ import com.google.devtools.build.lib.packages.util.PackageFactoryApparatus;
import com.google.devtools.build.lib.packages.util.PackageFactoryTestBase;
import com.google.devtools.build.lib.syntax.Type;
import com.google.devtools.build.lib.testutil.TestUtils;
+import com.google.devtools.build.lib.vfs.LocalPath;
import com.google.devtools.build.lib.vfs.Path;
import com.google.devtools.build.lib.vfs.PathFragment;
import java.util.ArrayList;
@@ -999,7 +1000,7 @@ public class PackageFactoryTest extends PackageFactoryTestBase {
scratch.file("/e/BUILD", "sh_library(name = 'e', data = glob(['*.txt']))");
Path parentDir = buildFile.getParentDirectory();
scratch.file("/e/data.txt");
- throwOnReaddir = parentDir;
+ throwOnReaddir = LocalPath.create(parentDir.getPathString());
try {
packages.createPackage("e", buildFile);
} catch (NoSuchPackageException expected) {
diff --git a/src/test/java/com/google/devtools/build/lib/packages/util/PackageFactoryTestBase.java b/src/test/java/com/google/devtools/build/lib/packages/util/PackageFactoryTestBase.java
index eb614fc49c..fa5e7605ac 100644
--- a/src/test/java/com/google/devtools/build/lib/packages/util/PackageFactoryTestBase.java
+++ b/src/test/java/com/google/devtools/build/lib/packages/util/PackageFactoryTestBase.java
@@ -39,6 +39,7 @@ import com.google.devtools.build.lib.util.Pair;
import com.google.devtools.build.lib.vfs.Dirent;
import com.google.devtools.build.lib.vfs.FileSystem;
import com.google.devtools.build.lib.vfs.FileSystemUtils;
+import com.google.devtools.build.lib.vfs.LocalPath;
import com.google.devtools.build.lib.vfs.Path;
import com.google.devtools.build.lib.vfs.inmemoryfs.InMemoryFileSystem;
import java.io.FileNotFoundException;
@@ -80,7 +81,7 @@ public abstract class PackageFactoryTestBase {
protected abstract PackageFactoryApparatus createPackageFactoryApparatus();
- protected Path throwOnReaddir = null;
+ protected LocalPath throwOnReaddir = null;
protected static AttributeMap attributes(Rule rule) {
return RawAttributeMapper.of(rule);
@@ -122,7 +123,8 @@ public abstract class PackageFactoryTestBase {
FileSystem fs =
new InMemoryFileSystem() {
@Override
- public Collection<Dirent> readdir(Path path, boolean followSymlinks) throws IOException {
+ public Collection<Dirent> readdir(LocalPath path, boolean followSymlinks)
+ throws IOException {
if (path.equals(throwOnReaddir)) {
throw new FileNotFoundException(path.getPathString());
}
diff --git a/src/test/java/com/google/devtools/build/lib/pkgcache/IOExceptionsTest.java b/src/test/java/com/google/devtools/build/lib/pkgcache/IOExceptionsTest.java
index 184f22201b..9f84f73a57 100644
--- a/src/test/java/com/google/devtools/build/lib/pkgcache/IOExceptionsTest.java
+++ b/src/test/java/com/google/devtools/build/lib/pkgcache/IOExceptionsTest.java
@@ -25,6 +25,7 @@ import com.google.devtools.build.lib.skyframe.TransitiveTargetKey;
import com.google.devtools.build.lib.skyframe.TransitiveTargetValue;
import com.google.devtools.build.lib.vfs.FileStatus;
import com.google.devtools.build.lib.vfs.FileSystem;
+import com.google.devtools.build.lib.vfs.LocalPath;
import com.google.devtools.build.lib.vfs.ModifiedFileSet;
import com.google.devtools.build.lib.vfs.Path;
import com.google.devtools.build.lib.vfs.PathFragment;
@@ -48,15 +49,16 @@ public class IOExceptionsTest extends PackageLoadingTestCase {
private static final String FS_ROOT = "/fsg";
- private static final Function<Path, String> NULL_FUNCTION = new Function<Path, String>() {
- @Override
- @Nullable
- public String apply(Path path) {
- return null;
- }
- };
+ private static final Function<LocalPath, String> NULL_FUNCTION =
+ new Function<LocalPath, String>() {
+ @Override
+ @Nullable
+ public String apply(LocalPath path) {
+ return null;
+ }
+ };
- private Function<Path, String> crashMessage = NULL_FUNCTION;
+ private Function<LocalPath, String> crashMessage = NULL_FUNCTION;
@Before
public final void initializeVisitor() throws Exception {
@@ -82,7 +84,7 @@ public class IOExceptionsTest extends PackageLoadingTestCase {
protected FileSystem createFileSystem() {
return new InMemoryFileSystem(BlazeClock.instance(), PathFragment.create(FS_ROOT)) {
@Override
- public FileStatus stat(Path path, boolean followSymlinks) throws IOException {
+ public FileStatus stat(LocalPath path, boolean followSymlinks) throws IOException {
String crash = crashMessage.apply(path);
if (crash != null) {
throw new IOException(crash);
@@ -97,15 +99,16 @@ public class IOExceptionsTest extends PackageLoadingTestCase {
reporter.removeHandler(failFastHandler); // expect errors
final Path buildPath = scratch.file("pkg/BUILD",
"sh_library(name = 'x')");
- crashMessage = new Function<Path, String>() {
- @Override
- public String apply(Path path) {
- if (buildPath.equals(path)) {
- return "custom crash: " + buildPath;
- }
- return null;
- }
- };
+ crashMessage =
+ new Function<LocalPath, String>() {
+ @Override
+ public String apply(LocalPath path) {
+ if (buildPath.getLocalPath().equals(path)) {
+ return "custom crash: " + buildPath;
+ }
+ return null;
+ }
+ };
assertThat(visitTransitively(Label.parseAbsolute("//pkg:x"))).isFalse();
scratch.overwriteFile("pkg/BUILD",
"# another comment to force reload",
@@ -126,15 +129,16 @@ public class IOExceptionsTest extends PackageLoadingTestCase {
"sh_library(name = 'top', deps = ['//pkg:x'])");
final Path buildPath = scratch.file("pkg/BUILD",
"sh_library(name = 'x')");
- crashMessage = new Function<Path, String>() {
- @Override
- public String apply(Path path) {
- if (buildPath.equals(path)) {
- return "custom crash: " + buildPath;
- }
- return null;
- }
- };
+ crashMessage =
+ new Function<LocalPath, String>() {
+ @Override
+ public String apply(LocalPath path) {
+ if (buildPath.getLocalPath().equals(path)) {
+ return "custom crash: " + buildPath;
+ }
+ return null;
+ }
+ };
assertThat(visitTransitively(Label.parseAbsolute("//top:top"))).isFalse();
assertContainsEvent("no such package 'pkg'");
// The traditional label visitor does not propagate the original IOException message.
@@ -159,15 +163,16 @@ public class IOExceptionsTest extends PackageLoadingTestCase {
final Path buildPath = scratch.file("top/BUILD",
"sh_library(name = 'x')");
buildPath.getParentDirectory().getRelative("pkg").createDirectory();
- crashMessage = new Function<Path, String>() {
- @Override
- public String apply(Path path) {
- if (buildPath.equals(path)) {
- return "custom crash: " + buildPath;
- }
- return null;
- }
- };
+ crashMessage =
+ new Function<LocalPath, String>() {
+ @Override
+ public String apply(LocalPath path) {
+ if (buildPath.getLocalPath().equals(path)) {
+ return "custom crash: " + buildPath;
+ }
+ return null;
+ }
+ };
assertThat(visitTransitively(Label.parseAbsolute("//top/pkg:x"))).isFalse();
}
}
diff --git a/src/test/java/com/google/devtools/build/lib/pkgcache/IncrementalLoadingTest.java b/src/test/java/com/google/devtools/build/lib/pkgcache/IncrementalLoadingTest.java
index 6e83bbedca..04e41a3c79 100644
--- a/src/test/java/com/google/devtools/build/lib/pkgcache/IncrementalLoadingTest.java
+++ b/src/test/java/com/google/devtools/build/lib/pkgcache/IncrementalLoadingTest.java
@@ -48,6 +48,7 @@ import com.google.devtools.build.lib.vfs.Dirent;
import com.google.devtools.build.lib.vfs.FileStatus;
import com.google.devtools.build.lib.vfs.FileSystem;
import com.google.devtools.build.lib.vfs.FileSystemUtils;
+import com.google.devtools.build.lib.vfs.LocalPath;
import com.google.devtools.build.lib.vfs.ModifiedFileSet;
import com.google.devtools.build.lib.vfs.Path;
import com.google.devtools.build.lib.vfs.PathFragment;
@@ -76,8 +77,8 @@ import org.junit.runners.JUnit4;
public class IncrementalLoadingTest {
protected PackageCacheTester tester;
- private Path throwOnReaddir = null;
- private Path throwOnStat = null;
+ private LocalPath throwOnReaddir = null;
+ private LocalPath throwOnStat = null;
@Before
public final void createTester() throws Exception {
@@ -85,7 +86,8 @@ public class IncrementalLoadingTest {
FileSystem fs =
new InMemoryFileSystem(clock) {
@Override
- public Collection<Dirent> readdir(Path path, boolean followSymlinks) throws IOException {
+ public Collection<Dirent> readdir(LocalPath path, boolean followSymlinks)
+ throws IOException {
if (path.equals(throwOnReaddir)) {
throw new FileNotFoundException(path.getPathString());
}
@@ -94,7 +96,7 @@ public class IncrementalLoadingTest {
@Nullable
@Override
- public FileStatus stat(Path path, boolean followSymlinks) throws IOException {
+ public FileStatus stat(LocalPath path, boolean followSymlinks) throws IOException {
if (path.equals(throwOnStat)) {
throw new IOException("bork " + path.getPathString());
}
@@ -337,7 +339,7 @@ public class IncrementalLoadingTest {
Path buildFile = tester.addFile("e/BUILD", "sh_library(name = 'e', data = glob(['*.txt']))");
Path parentDir = buildFile.getParentDirectory();
tester.addFile("e/data.txt");
- throwOnReaddir = parentDir;
+ throwOnReaddir = parentDir.getLocalPath();
tester.sync();
try {
tester.getTarget("//e:e");
diff --git a/src/test/java/com/google/devtools/build/lib/pkgcache/TargetPatternEvaluatorIOTest.java b/src/test/java/com/google/devtools/build/lib/pkgcache/TargetPatternEvaluatorIOTest.java
index 37a992d405..1eb87496a4 100644
--- a/src/test/java/com/google/devtools/build/lib/pkgcache/TargetPatternEvaluatorIOTest.java
+++ b/src/test/java/com/google/devtools/build/lib/pkgcache/TargetPatternEvaluatorIOTest.java
@@ -21,6 +21,7 @@ import com.google.devtools.build.lib.vfs.Dirent;
import com.google.devtools.build.lib.vfs.FileStatus;
import com.google.devtools.build.lib.vfs.FileSystem;
import com.google.devtools.build.lib.vfs.FileSystemUtils;
+import com.google.devtools.build.lib.vfs.LocalPath;
import com.google.devtools.build.lib.vfs.Path;
import com.google.devtools.build.lib.vfs.PathFragment;
import com.google.devtools.build.lib.vfs.inmemoryfs.InMemoryContentInfo;
@@ -41,14 +42,15 @@ public class TargetPatternEvaluatorIOTest extends AbstractTargetPatternEvaluator
private static class Transformer {
@SuppressWarnings("unused")
@Nullable
- public FileStatus stat(FileStatus stat, Path path, boolean followSymlinks) throws IOException {
+ public FileStatus stat(FileStatus stat, LocalPath path, boolean followSymlinks)
+ throws IOException {
return stat;
}
@SuppressWarnings("unused")
@Nullable
- public Collection<Dirent> readdir(Collection<Dirent> readdir, Path path, boolean followSymlinks)
- throws IOException {
+ public Collection<Dirent> readdir(
+ Collection<Dirent> readdir, LocalPath path, boolean followSymlinks) throws IOException {
return readdir;
}
}
@@ -59,13 +61,14 @@ public class TargetPatternEvaluatorIOTest extends AbstractTargetPatternEvaluator
protected FileSystem createFileSystem() {
return new InMemoryFileSystem(BlazeClock.instance(), PathFragment.create(FS_ROOT)) {
@Override
- public FileStatus stat(Path path, boolean followSymlinks) throws IOException {
+ public FileStatus stat(LocalPath path, boolean followSymlinks) throws IOException {
FileStatus defaultResult = super.stat(path, followSymlinks);
return transformer.stat(defaultResult, path, followSymlinks);
}
@Override
- protected Collection<Dirent> readdir(Path path, boolean followSymlinks) throws IOException {
+ protected Collection<Dirent> readdir(LocalPath path, boolean followSymlinks)
+ throws IOException {
Collection<Dirent> defaultResult = super.readdir(path, followSymlinks);
return transformer.readdir(defaultResult, path, followSymlinks);
}
@@ -133,7 +136,7 @@ public class TargetPatternEvaluatorIOTest extends AbstractTargetPatternEvaluator
return new Transformer() {
@Nullable
@Override
- public FileStatus stat(final FileStatus stat, Path path, boolean followSymlinks)
+ public FileStatus stat(FileStatus stat, LocalPath path, boolean followSymlinks)
throws IOException {
if (path.getPathString().endsWith(badPathSuffix)) {
return new InMemoryContentInfo(BlazeClock.instance()) {
@@ -200,8 +203,8 @@ public class TargetPatternEvaluatorIOTest extends AbstractTargetPatternEvaluator
return new Transformer() {
@Nullable
@Override
- public Collection<Dirent> readdir(Collection<Dirent> readdir, Path path,
- boolean followSymlinks) throws IOException {
+ public Collection<Dirent> readdir(
+ Collection<Dirent> readdir, LocalPath path, boolean followSymlinks) throws IOException {
if (path.getPathString().endsWith(badPathSuffix)) {
throw new IOException("Path ended in " + badPathSuffix + ", so readdir failed.");
}
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/ASTFileLookupFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/ASTFileLookupFunctionTest.java
index 68437dbdb3..289b420eac 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/ASTFileLookupFunctionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/ASTFileLookupFunctionTest.java
@@ -26,7 +26,7 @@ import com.google.devtools.build.lib.syntax.SkylarkImport;
import com.google.devtools.build.lib.testutil.TestConstants;
import com.google.devtools.build.lib.vfs.FileStatus;
import com.google.devtools.build.lib.vfs.FileSystem;
-import com.google.devtools.build.lib.vfs.Path;
+import com.google.devtools.build.lib.vfs.LocalPath;
import com.google.devtools.build.lib.vfs.inmemoryfs.InMemoryFileSystem;
import com.google.devtools.build.skyframe.ErrorInfo;
import com.google.devtools.build.skyframe.EvaluationResult;
@@ -47,10 +47,9 @@ public class ASTFileLookupFunctionTest extends BuildViewTestCase {
boolean statThrowsIoException;
@Override
- public FileStatus stat(Path path, boolean followSymlinks) throws IOException {
+ public FileStatus stat(LocalPath path, boolean followSymlinks) throws IOException {
if (statThrowsIoException
- && path.asFragment()
- .getPathString()
+ && path.getPathString()
.equals("/workspace/tools/build_rules/prelude_" + TestConstants.PRODUCT_NAME)) {
throw new IOException("bork");
}
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/ArtifactFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/ArtifactFunctionTest.java
index 4004e85b8f..de9a9ab594 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/ArtifactFunctionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/ArtifactFunctionTest.java
@@ -40,6 +40,7 @@ import com.google.devtools.build.lib.events.NullEventHandler;
import com.google.devtools.build.lib.util.Pair;
import com.google.devtools.build.lib.vfs.FileStatus;
import com.google.devtools.build.lib.vfs.FileSystemUtils;
+import com.google.devtools.build.lib.vfs.LocalPath;
import com.google.devtools.build.lib.vfs.Path;
import com.google.devtools.build.lib.vfs.PathFragment;
import com.google.devtools.build.skyframe.EvaluationResult;
@@ -101,7 +102,7 @@ public class ArtifactFunctionTest extends ArtifactFunctionTestCase {
setupRoot(
new CustomInMemoryFs() {
@Override
- public byte[] getDigest(Path path, HashFunction hf) throws IOException {
+ public byte[] getDigest(LocalPath path, HashFunction hf) throws IOException {
return path.getBaseName().equals("unreadable")
? expectedDigest
: super.getDigest(path, hf);
@@ -158,7 +159,7 @@ public class ArtifactFunctionTest extends ArtifactFunctionTestCase {
setupRoot(
new CustomInMemoryFs() {
@Override
- public byte[] getDigest(Path path, HashFunction hf) throws IOException {
+ public byte[] getDigest(LocalPath path, HashFunction hf) throws IOException {
throw exception;
}
});
@@ -182,7 +183,7 @@ public class ArtifactFunctionTest extends ArtifactFunctionTestCase {
setupRoot(
new CustomInMemoryFs() {
@Override
- public FileStatus stat(Path path, boolean followSymlinks) throws IOException {
+ public FileStatus stat(LocalPath path, boolean followSymlinks) throws IOException {
if (path.getBaseName().equals("bad")) {
throw exception;
}
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/ArtifactFunctionTestCase.java b/src/test/java/com/google/devtools/build/lib/skyframe/ArtifactFunctionTestCase.java
index ff83c4a4dd..6fd4837e1e 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/ArtifactFunctionTestCase.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/ArtifactFunctionTestCase.java
@@ -29,6 +29,7 @@ import com.google.devtools.build.lib.testutil.TestRuleClassProvider;
import com.google.devtools.build.lib.testutil.TestUtils;
import com.google.devtools.build.lib.util.io.TimestampGranularityMonitor;
import com.google.devtools.build.lib.vfs.FileSystemUtils;
+import com.google.devtools.build.lib.vfs.LocalPath;
import com.google.devtools.build.lib.vfs.Path;
import com.google.devtools.build.lib.vfs.inmemoryfs.InMemoryFileSystem;
import com.google.devtools.build.skyframe.InMemoryMemoizingEvaluator;
@@ -171,7 +172,7 @@ abstract class ArtifactFunctionTestCase {
/** InMemoryFileSystem that can pretend to do a fast digest. */
protected class CustomInMemoryFs extends InMemoryFileSystem {
@Override
- protected byte[] getFastDigest(Path path, HashFunction hashFunction) throws IOException {
+ protected byte[] getFastDigest(LocalPath path, HashFunction hashFunction) throws IOException {
return fastDigest ? getDigest(path, hashFunction) : null;
}
}
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/FileFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/FileFunctionTest.java
index e28fef3774..ee0f01976d 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/FileFunctionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/FileFunctionTest.java
@@ -52,6 +52,7 @@ import com.google.devtools.build.lib.util.io.TimestampGranularityMonitor;
import com.google.devtools.build.lib.vfs.FileStatus;
import com.google.devtools.build.lib.vfs.FileSystem;
import com.google.devtools.build.lib.vfs.FileSystemUtils;
+import com.google.devtools.build.lib.vfs.LocalPath;
import com.google.devtools.build.lib.vfs.Path;
import com.google.devtools.build.lib.vfs.PathFragment;
import com.google.devtools.build.lib.vfs.RootedPath;
@@ -444,7 +445,7 @@ public class FileFunctionTest {
createFsAndRoot(
new CustomInMemoryFs(manualClock) {
@Override
- protected byte[] getFastDigest(Path path, HashFunction hf) throws IOException {
+ protected byte[] getFastDigest(LocalPath path, HashFunction hf) throws IOException {
return digest;
}
});
@@ -485,7 +486,7 @@ public class FileFunctionTest {
createFsAndRoot(
new CustomInMemoryFs(manualClock) {
@Override
- protected byte[] getFastDigest(Path path, HashFunction hf) {
+ protected byte[] getFastDigest(LocalPath path, HashFunction hf) {
return path.getBaseName().equals("unreadable") ? expectedDigest : null;
}
});
@@ -830,7 +831,7 @@ public class FileFunctionTest {
fs =
new CustomInMemoryFs(manualClock) {
@Override
- protected byte[] getDigest(Path path, HashFunction hf) throws IOException {
+ protected byte[] getDigest(LocalPath path, HashFunction hf) throws IOException {
digestCalls.incrementAndGet();
return super.getDigest(path, hf);
}
@@ -895,8 +896,8 @@ public class FileFunctionTest {
// Our custom filesystem says "a" does not exist, so FileFunction shouldn't bother trying to
// think about "a/b". Test for this by having a stat of "a/b" fail with an io error, and
// observing that we don't encounter the error.
- fs.stubStat(path("a"), null);
- fs.stubStatError(path("a/b"), new IOException("ouch!"));
+ fs.stubStat(path("a").getLocalPath(), null);
+ fs.stubStatError(path("a/b").getLocalPath(), new IOException("ouch!"));
assertThat(valueForPath(path("a/b")).exists()).isFalse();
}
@@ -946,7 +947,7 @@ public class FileFunctionTest {
return 0;
}
};
- fs.stubStat(path("a"), inconsistentParentFileStatus);
+ fs.stubStat(path("a").getLocalPath(), inconsistentParentFileStatus);
// Disable fast-path md5 so that we don't try try to md5 the "a" (since it actually physically
// is a directory).
fastDigest = false;
@@ -967,7 +968,7 @@ public class FileFunctionTest {
public void testFilesystemInconsistencies_GetFastDigest() throws Exception {
file("a");
// Our custom filesystem says "a/b" exists but "a" does not exist.
- fs.stubFastDigestError(path("a"), new IOException("nope"));
+ fs.stubFastDigestError(path("a").getLocalPath(), new IOException("nope"));
SequentialBuildDriver driver = makeDriver();
SkyKey skyKey = skyKey("a");
EvaluationResult<FileValue> result =
@@ -985,7 +986,7 @@ public class FileFunctionTest {
createFsAndRoot(
new CustomInMemoryFs(manualClock) {
@Override
- protected boolean isReadable(Path path) throws IOException {
+ protected boolean isReadable(LocalPath path) throws IOException {
if (path.getBaseName().equals("unreadable")) {
throw new IOException("isReadable failed");
}
@@ -1291,7 +1292,7 @@ public class FileFunctionTest {
public void testInjectionOverIOException() throws Exception {
Path foo = file("foo");
SkyKey fooKey = skyKey("foo");
- fs.stubStatError(foo, new IOException("bork"));
+ fs.stubStatError(foo.getLocalPath(), new IOException("bork"));
BuildDriver driver = makeDriver();
EvaluationResult<FileValue> result =
driver.evaluate(
@@ -1306,7 +1307,7 @@ public class FileFunctionTest {
.hasExceptionThat()
.hasMessageThat()
.isEqualTo("bork");
- fs.stubbedStatErrors.remove(foo);
+ fs.stubbedStatErrors.remove(foo.getLocalPath());
differencer.inject(
fileStateSkyKey("foo"),
FileStateValue.create(
@@ -1676,36 +1677,36 @@ public class FileFunctionTest {
private class CustomInMemoryFs extends InMemoryFileSystem {
- private final Map<Path, FileStatus> stubbedStats = Maps.newHashMap();
- private final Map<Path, IOException> stubbedStatErrors = Maps.newHashMap();
- private final Map<Path, IOException> stubbedFastDigestErrors = Maps.newHashMap();
+ private final Map<LocalPath, FileStatus> stubbedStats = Maps.newHashMap();
+ private final Map<LocalPath, IOException> stubbedStatErrors = Maps.newHashMap();
+ private final Map<LocalPath, IOException> stubbedFastDigestErrors = Maps.newHashMap();
public CustomInMemoryFs(ManualClock manualClock) {
super(manualClock);
}
- public void stubFastDigestError(Path path, IOException error) {
+ public void stubFastDigestError(LocalPath path, IOException error) {
stubbedFastDigestErrors.put(path, error);
}
@Override
- protected byte[] getFastDigest(Path path, HashFunction hashFunction) throws IOException {
+ protected byte[] getFastDigest(LocalPath path, HashFunction hashFunction) throws IOException {
if (stubbedFastDigestErrors.containsKey(path)) {
throw stubbedFastDigestErrors.get(path);
}
return fastDigest ? getDigest(path) : null;
}
- public void stubStat(Path path, @Nullable FileStatus stubbedResult) {
+ public void stubStat(LocalPath path, @Nullable FileStatus stubbedResult) {
stubbedStats.put(path, stubbedResult);
}
- public void stubStatError(Path path, IOException error) {
+ public void stubStatError(LocalPath path, IOException error) {
stubbedStatErrors.put(path, error);
}
@Override
- public FileStatus stat(Path path, boolean followSymlinks) throws IOException {
+ public FileStatus stat(LocalPath path, boolean followSymlinks) throws IOException {
if (stubbedStatErrors.containsKey(path)) {
throw stubbedStatErrors.get(path);
}
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/FilesystemValueCheckerTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/FilesystemValueCheckerTest.java
index eb2d141b1c..a57f39526f 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/FilesystemValueCheckerTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/FilesystemValueCheckerTest.java
@@ -48,6 +48,7 @@ import com.google.devtools.build.lib.vfs.FileStatus;
import com.google.devtools.build.lib.vfs.FileStatusWithDigest;
import com.google.devtools.build.lib.vfs.FileStatusWithDigestAdapter;
import com.google.devtools.build.lib.vfs.FileSystemUtils;
+import com.google.devtools.build.lib.vfs.LocalPath;
import com.google.devtools.build.lib.vfs.ModifiedFileSet;
import com.google.devtools.build.lib.vfs.Path;
import com.google.devtools.build.lib.vfs.PathFragment;
@@ -807,7 +808,7 @@ public class FilesystemValueCheckerTest {
}
@Override
- public FileStatus stat(Path path, boolean followSymlinks) throws IOException {
+ public FileStatus stat(LocalPath path, boolean followSymlinks) throws IOException {
if (statThrowsRuntimeException) {
throw new RuntimeException("bork");
}
@@ -815,7 +816,7 @@ public class FilesystemValueCheckerTest {
}
@Override
- protected PathFragment readSymbolicLink(Path path) throws IOException {
+ protected String readSymbolicLink(LocalPath path) throws IOException {
if (readlinkThrowsIoException) {
throw new IOException("readlink failed");
}
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/GlobFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/GlobFunctionTest.java
index 13acf704e9..3ac3dc49a6 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/GlobFunctionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/GlobFunctionTest.java
@@ -43,6 +43,7 @@ import com.google.devtools.build.lib.util.io.TimestampGranularityMonitor;
import com.google.devtools.build.lib.vfs.Dirent;
import com.google.devtools.build.lib.vfs.FileStatus;
import com.google.devtools.build.lib.vfs.FileSystemUtils;
+import com.google.devtools.build.lib.vfs.LocalPath;
import com.google.devtools.build.lib.vfs.Path;
import com.google.devtools.build.lib.vfs.PathFragment;
import com.google.devtools.build.lib.vfs.RootedPath;
@@ -629,7 +630,7 @@ public abstract class GlobFunctionTest {
@Test
public void testResilienceToFilesystemInconsistencies_DirectoryExistence() throws Exception {
// Our custom filesystem says "pkgPath/BUILD" exists but "pkgPath" does not exist.
- fs.stubStat(pkgPath, null);
+ fs.stubStat(pkgPath.getLocalPath(), null);
RootedPath pkgRootedPath = RootedPath.toRootedPath(root, pkgPath);
FileStateValue pkgDirFileStateValue = FileStateValue.create(pkgRootedPath, null);
FileValue pkgDirValue =
@@ -654,7 +655,7 @@ public abstract class GlobFunctionTest {
// Our custom filesystem says directory "pkgPath/foo/bar" contains a subdirectory "wiz" but a
// direct stat on "pkgPath/foo/bar/wiz" says it does not exist.
Path fooBarDir = pkgPath.getRelative("foo/bar");
- fs.stubStat(fooBarDir.getRelative("wiz"), null);
+ fs.stubStat(fooBarDir.getRelative("wiz").getLocalPath(), null);
RootedPath fooBarDirRootedPath = RootedPath.toRootedPath(root, fooBarDir);
SkyValue fooBarDirListingValue =
DirectoryListingStateValue.create(
@@ -683,7 +684,7 @@ public abstract class GlobFunctionTest {
RootedPath.toRootedPath(root, pkgPath.getRelative("foo/bar/wiz/file"));
final FileStatus realStat = fileRootedPath.asPath().stat();
fs.stubStat(
- fileRootedPath.asPath(),
+ fileRootedPath.asPath().getLocalPath(),
new FileStatus() {
@Override
@@ -760,18 +761,18 @@ public abstract class GlobFunctionTest {
private static final class CustomInMemoryFs extends InMemoryFileSystem {
- private Map<Path, FileStatus> stubbedStats = Maps.newHashMap();
+ private Map<LocalPath, FileStatus> stubbedStats = Maps.newHashMap();
public CustomInMemoryFs(ManualClock manualClock) {
super(manualClock);
}
- public void stubStat(Path path, @Nullable FileStatus stubbedResult) {
+ public void stubStat(LocalPath path, @Nullable FileStatus stubbedResult) {
stubbedStats.put(path, stubbedResult);
}
@Override
- public FileStatus stat(Path path, boolean followSymlinks) throws IOException {
+ public FileStatus stat(LocalPath path, boolean followSymlinks) throws IOException {
if (stubbedStats.containsKey(path)) {
return stubbedStats.get(path);
}
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/PackageFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/PackageFunctionTest.java
index 8773d54825..54f23f430d 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/PackageFunctionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/PackageFunctionTest.java
@@ -39,6 +39,7 @@ import com.google.devtools.build.lib.vfs.Dirent;
import com.google.devtools.build.lib.vfs.FileStatus;
import com.google.devtools.build.lib.vfs.FileSystem;
import com.google.devtools.build.lib.vfs.FileSystemUtils;
+import com.google.devtools.build.lib.vfs.LocalPath;
import com.google.devtools.build.lib.vfs.ModifiedFileSet;
import com.google.devtools.build.lib.vfs.Path;
import com.google.devtools.build.lib.vfs.PathFragment;
@@ -164,7 +165,7 @@ public class PackageFunctionTest extends BuildViewTestCase {
return 0;
}
};
- fs.stubStat(fooDir, inconsistentParentFileStatus);
+ fs.stubStat(fooDir.getLocalPath(), inconsistentParentFileStatus);
RootedPath pkgRootedPath = RootedPath.toRootedPath(pkgRoot, fooDir);
SkyValue fooDirValue = FileStateValue.create(pkgRootedPath, tsgm);
differencer.inject(ImmutableMap.of(FileStateValue.key(pkgRootedPath), fooDirValue));
@@ -196,7 +197,7 @@ public class PackageFunctionTest extends BuildViewTestCase {
// Our custom filesystem says "foo/bar/baz" does not exist but it also says that "foo/bar"
// has a child directory "baz".
- fs.stubStat(bazDir, null);
+ fs.stubStat(bazDir.getLocalPath(), null);
RootedPath barDirRootedPath = RootedPath.toRootedPath(pkgRoot, barDir);
FileStateValue barDirFileStateValue = FileStateValue.create(barDirRootedPath, tsgm);
FileValue barDirFileValue = FileValue.value(barDirRootedPath, barDirFileStateValue,
@@ -225,7 +226,7 @@ public class PackageFunctionTest extends BuildViewTestCase {
Path fooDir = fooBuildFile.getParentDirectory();
Path barDir = fooDir.getRelative("bar");
scratch.file("foo/bar/baz.sh");
- fs.scheduleMakeUnreadableAfterReaddir(barDir);
+ fs.scheduleMakeUnreadableAfterReaddir(barDir.getLocalPath());
SkyKey skyKey = PackageValue.key(PackageIdentifier.parse("@//foo"));
String expectedMessage = "Encountered error 'Directory is not readable'";
@@ -536,7 +537,7 @@ public class PackageFunctionTest extends BuildViewTestCase {
scratch.file("foo/BUILD",
"sh_library(name = 'foo', srcs = ['bar/baz.sh'])");
Path barBuildFile = scratch.file("foo/bar/BUILD");
- fs.stubStatError(barBuildFile, new IOException("nope"));
+ fs.stubStatError(barBuildFile.getLocalPath(), new IOException("nope"));
SkyKey skyKey = PackageValue.key(PackageIdentifier.parse("@//foo"));
EvaluationResult<PackageValue> result = SkyframeExecutorTestUtils.evaluate(
getSkyframeExecutor(), skyKey, /*keepGoing=*/false, reporter);
@@ -674,7 +675,7 @@ public class PackageFunctionTest extends BuildViewTestCase {
public void testPackageLoadingErrorOnIOExceptionReadingBuildFile() throws Exception {
Path fooBuildFilePath = scratch.file("foo/BUILD");
IOException exn = new IOException("nope");
- fs.throwExceptionOnGetInputStream(fooBuildFilePath, exn);
+ fs.throwExceptionOnGetInputStream(fooBuildFilePath.getLocalPath(), exn);
SkyKey skyKey = PackageValue.key(PackageIdentifier.parse("@//foo"));
EvaluationResult<PackageValue> result = SkyframeExecutorTestUtils.evaluate(
@@ -692,7 +693,7 @@ public class PackageFunctionTest extends BuildViewTestCase {
scratch.file("foo/BUILD", "load('//foo:bzl.bzl', 'x')");
Path fooBzlFilePath = scratch.file("foo/bzl.bzl");
IOException exn = new IOException("nope");
- fs.throwExceptionOnGetInputStream(fooBzlFilePath, exn);
+ fs.throwExceptionOnGetInputStream(fooBzlFilePath.getLocalPath(), exn);
SkyKey skyKey = PackageValue.key(PackageIdentifier.parse("@//foo"));
EvaluationResult<PackageValue> result = SkyframeExecutorTestUtils.evaluate(
@@ -739,49 +740,49 @@ public class PackageFunctionTest extends BuildViewTestCase {
}
}
- private final Map<Path, FileStatusOrException> stubbedStats = Maps.newHashMap();
- private final Set<Path> makeUnreadableAfterReaddir = Sets.newHashSet();
- private final Map<Path, IOException> pathsToErrorOnGetInputStream = Maps.newHashMap();
+ private final Map<LocalPath, FileStatusOrException> stubbedStats = Maps.newHashMap();
+ private final Set<LocalPath> makeUnreadableAfterReaddir = Sets.newHashSet();
+ private final Map<LocalPath, IOException> pathsToErrorOnGetInputStream = Maps.newHashMap();
public CustomInMemoryFs(ManualClock manualClock) {
super(manualClock);
}
- public void stubStat(Path path, @Nullable FileStatus stubbedResult) {
+ public void stubStat(LocalPath path, @Nullable FileStatus stubbedResult) {
stubbedStats.put(path, new FileStatusOrException.FileStatusImpl(stubbedResult));
}
- public void stubStatError(Path path, IOException stubbedResult) {
+ public void stubStatError(LocalPath path, IOException stubbedResult) {
stubbedStats.put(path, new FileStatusOrException.ExceptionImpl(stubbedResult));
}
@Override
- public FileStatus stat(Path path, boolean followSymlinks) throws IOException {
+ public FileStatus stat(LocalPath path, boolean followSymlinks) throws IOException {
if (stubbedStats.containsKey(path)) {
return stubbedStats.get(path).get();
}
return super.stat(path, followSymlinks);
}
- public void scheduleMakeUnreadableAfterReaddir(Path path) {
+ public void scheduleMakeUnreadableAfterReaddir(LocalPath path) {
makeUnreadableAfterReaddir.add(path);
}
@Override
- public Collection<Dirent> readdir(Path path, boolean followSymlinks) throws IOException {
+ public Collection<Dirent> readdir(LocalPath path, boolean followSymlinks) throws IOException {
Collection<Dirent> result = super.readdir(path, followSymlinks);
if (makeUnreadableAfterReaddir.contains(path)) {
- path.setReadable(false);
+ setReadable(path, false);
}
return result;
}
- public void throwExceptionOnGetInputStream(Path path, IOException exn) {
+ public void throwExceptionOnGetInputStream(LocalPath path, IOException exn) {
pathsToErrorOnGetInputStream.put(path, exn);
}
@Override
- protected InputStream getInputStream(Path path) throws IOException {
+ protected InputStream getInputStream(LocalPath path) throws IOException {
IOException exnToThrow = pathsToErrorOnGetInputStream.get(path);
if (exnToThrow != null) {
throw exnToThrow;
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/ParallelBuilderTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/ParallelBuilderTest.java
index e271d90237..13f5fa2df3 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/ParallelBuilderTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/ParallelBuilderTest.java
@@ -45,6 +45,7 @@ import com.google.devtools.build.lib.testutil.TestUtils;
import com.google.devtools.build.lib.vfs.FileStatus;
import com.google.devtools.build.lib.vfs.FileSystem;
import com.google.devtools.build.lib.vfs.FileSystemUtils;
+import com.google.devtools.build.lib.vfs.LocalPath;
import com.google.devtools.build.lib.vfs.Path;
import com.google.devtools.build.lib.vfs.inmemoryfs.InMemoryFileSystem;
import java.io.FileNotFoundException;
@@ -241,58 +242,59 @@ public class ParallelBuilderTest extends TimestampBuilderTestCase {
@Test
public void testUpdateCacheError() throws Exception {
- FileSystem fs = new InMemoryFileSystem() {
- @Override
- public FileStatus stat(Path path, boolean followSymlinks) throws IOException {
- final FileStatus stat = super.stat(path, followSymlinks);
- if (path.toString().endsWith("/out/foo")) {
- return new FileStatus() {
- private final FileStatus original = stat;
+ FileSystem fs =
+ new InMemoryFileSystem() {
+ @Override
+ public FileStatus stat(LocalPath path, boolean followSymlinks) throws IOException {
+ final FileStatus stat = super.stat(path, followSymlinks);
+ if (path.toString().endsWith("/out/foo")) {
+ return new FileStatus() {
+ private final FileStatus original = stat;
- @Override
- public boolean isSymbolicLink() {
- return original.isSymbolicLink();
- }
+ @Override
+ public boolean isSymbolicLink() {
+ return original.isSymbolicLink();
+ }
- @Override
- public boolean isFile() {
- return original.isFile();
- }
+ @Override
+ public boolean isFile() {
+ return original.isFile();
+ }
- @Override
- public boolean isDirectory() {
- return original.isDirectory();
- }
+ @Override
+ public boolean isDirectory() {
+ return original.isDirectory();
+ }
- @Override
- public boolean isSpecialFile() {
- return original.isSpecialFile();
- }
+ @Override
+ public boolean isSpecialFile() {
+ return original.isSpecialFile();
+ }
- @Override
- public long getSize() throws IOException {
- return original.getSize();
- }
+ @Override
+ public long getSize() throws IOException {
+ return original.getSize();
+ }
- @Override
- public long getNodeId() throws IOException {
- return original.getNodeId();
- }
+ @Override
+ public long getNodeId() throws IOException {
+ return original.getNodeId();
+ }
- @Override
- public long getLastModifiedTime() throws IOException {
- throw new IOException();
- }
+ @Override
+ public long getLastModifiedTime() throws IOException {
+ throw new IOException();
+ }
- @Override
- public long getLastChangeTime() throws IOException {
- return original.getLastChangeTime();
+ @Override
+ public long getLastChangeTime() throws IOException {
+ return original.getLastChangeTime();
+ }
+ };
}
- };
- }
- return stat;
- }
- };
+ return stat;
+ }
+ };
Artifact foo = createDerivedArtifact(fs, "foo");
registerAction(new TestAction(TestAction.NO_EFFECT, emptySet, ImmutableList.of(foo)));
reporter.removeHandler(failFastHandler);
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/SkyframeLabelVisitorTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/SkyframeLabelVisitorTest.java
index 63e900f344..8bca6bd55c 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/SkyframeLabelVisitorTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/SkyframeLabelVisitorTest.java
@@ -490,7 +490,7 @@ public class SkyframeLabelVisitorTest extends SkyframeLabelVisitorTestCase {
return 0;
}
};
- fs.stubStat(bazDir, inconsistentParentFileStatus);
+ fs.stubStat(bazDir.getLocalPath(), inconsistentParentFileStatus);
Set<Label> labels = ImmutableSet.of(Label.parseAbsolute("//foo:foo"));
getSkyframeExecutor()
.getPackageManager()
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/SkyframeLabelVisitorTestCase.java b/src/test/java/com/google/devtools/build/lib/skyframe/SkyframeLabelVisitorTestCase.java
index f20cea8a51..e3c54a55a2 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/SkyframeLabelVisitorTestCase.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/SkyframeLabelVisitorTestCase.java
@@ -36,8 +36,8 @@ import com.google.devtools.build.lib.pkgcache.TransitivePackageLoader;
import com.google.devtools.build.lib.testutil.ManualClock;
import com.google.devtools.build.lib.vfs.FileStatus;
import com.google.devtools.build.lib.vfs.FileSystem;
+import com.google.devtools.build.lib.vfs.LocalPath;
import com.google.devtools.build.lib.vfs.ModifiedFileSet;
-import com.google.devtools.build.lib.vfs.Path;
import com.google.devtools.build.lib.vfs.inmemoryfs.InMemoryFileSystem;
import com.google.devtools.build.skyframe.DelegatingWalkableGraph;
import com.google.devtools.build.skyframe.InMemoryMemoizingEvaluator;
@@ -240,18 +240,18 @@ abstract public class SkyframeLabelVisitorTestCase extends PackageLoadingTestCas
protected static class CustomInMemoryFs extends InMemoryFileSystem {
- private Map<Path, FileStatus> stubbedStats = Maps.newHashMap();
+ private Map<LocalPath, FileStatus> stubbedStats = Maps.newHashMap();
public CustomInMemoryFs(ManualClock manualClock) {
super(manualClock);
}
- public void stubStat(Path path, @Nullable FileStatus stubbedResult) {
+ public void stubStat(LocalPath path, @Nullable FileStatus stubbedResult) {
stubbedStats.put(path, stubbedResult);
}
@Override
- public FileStatus stat(Path path, boolean followSymlinks) throws IOException {
+ public FileStatus stat(LocalPath path, boolean followSymlinks) throws IOException {
if (stubbedStats.containsKey(path)) {
return stubbedStats.get(path);
}
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/TargetMarkerFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/TargetMarkerFunctionTest.java
index 1e944d22cb..986c5a5038 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/TargetMarkerFunctionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/TargetMarkerFunctionTest.java
@@ -26,6 +26,7 @@ import com.google.devtools.build.lib.packages.NoSuchTargetException;
import com.google.devtools.build.lib.skyframe.util.SkyframeExecutorTestUtils;
import com.google.devtools.build.lib.vfs.FileStatus;
import com.google.devtools.build.lib.vfs.FileSystem;
+import com.google.devtools.build.lib.vfs.LocalPath;
import com.google.devtools.build.lib.vfs.ModifiedFileSet;
import com.google.devtools.build.lib.vfs.Path;
import com.google.devtools.build.lib.vfs.PathFragment;
@@ -132,7 +133,7 @@ public class TargetMarkerFunctionTest extends BuildViewTestCase {
reporter.removeHandler(failFastHandler);
scratch.file("a/BUILD", "sh_library(name = 'b/c')");
Path subpackageBuildFile = scratch.file("a/b/BUILD", "sh_library(name = 'c')");
- fs.stubStatIOException(subpackageBuildFile, new IOException("nope"));
+ fs.stubStatIOException(subpackageBuildFile.getLocalPath(), new IOException("nope"));
BuildFileNotFoundException exn =
(BuildFileNotFoundException) getErrorFromTargetValue("//a:b/c");
assertThat(exn).hasMessageThat().contains("nope");
@@ -140,18 +141,18 @@ public class TargetMarkerFunctionTest extends BuildViewTestCase {
private static class CustomInMemoryFs extends InMemoryFileSystem {
- private Map<Path, IOException> stubbedStatExceptions = Maps.newHashMap();
+ private Map<LocalPath, IOException> stubbedStatExceptions = Maps.newHashMap();
public CustomInMemoryFs() {
super(BlazeClock.instance());
}
- public void stubStatIOException(Path path, IOException stubbedResult) {
+ public void stubStatIOException(LocalPath path, IOException stubbedResult) {
stubbedStatExceptions.put(path, stubbedResult);
}
@Override
- public FileStatus stat(Path path, boolean followSymlinks) throws IOException {
+ public FileStatus stat(LocalPath path, boolean followSymlinks) throws IOException {
if (stubbedStatExceptions.containsKey(path)) {
throw stubbedStatExceptions.get(path);
}
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/TreeArtifactMetadataTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/TreeArtifactMetadataTest.java
index 3e156beaec..1e52a54ec5 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/TreeArtifactMetadataTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/TreeArtifactMetadataTest.java
@@ -40,6 +40,7 @@ import com.google.devtools.build.lib.actions.util.TestAction.DummyAction;
import com.google.devtools.build.lib.events.NullEventHandler;
import com.google.devtools.build.lib.vfs.FileStatus;
import com.google.devtools.build.lib.vfs.FileSystemUtils;
+import com.google.devtools.build.lib.vfs.LocalPath;
import com.google.devtools.build.lib.vfs.Path;
import com.google.devtools.build.lib.vfs.PathFragment;
import com.google.devtools.build.skyframe.EvaluationResult;
@@ -180,7 +181,7 @@ public class TreeArtifactMetadataTest extends ArtifactFunctionTestCase {
setupRoot(
new CustomInMemoryFs() {
@Override
- public FileStatus stat(Path path, boolean followSymlinks) throws IOException {
+ public FileStatus stat(LocalPath path, boolean followSymlinks) throws IOException {
if (path.getBaseName().equals("one")) {
throw exception;
}
diff --git a/src/test/java/com/google/devtools/build/lib/util/DependencySetWindowsTest.java b/src/test/java/com/google/devtools/build/lib/util/DependencySetWindowsTest.java
index d4a079db94..be410fdf6f 100644
--- a/src/test/java/com/google/devtools/build/lib/util/DependencySetWindowsTest.java
+++ b/src/test/java/com/google/devtools/build/lib/util/DependencySetWindowsTest.java
@@ -38,11 +38,13 @@ public class DependencySetWindowsTest {
@Test
public void dotDParser_windowsPaths() throws Exception {
- Path dotd = scratch.file("/tmp/foo.d",
- "bazel-out/hello-lib/cpp/hello-lib.o: \\",
- " cpp/hello-lib.cc cpp/hello-lib.h c:\\mingw\\include\\stdio.h \\",
- " c:\\mingw\\include\\_mingw.h \\",
- " c:\\mingw\\lib\\gcc\\mingw32\\4.8.1\\include\\stdarg.h");
+ Path dotd =
+ scratch.file(
+ "C:/tmp/foo.d",
+ "bazel-out/hello-lib/cpp/hello-lib.o: \\",
+ " cpp/hello-lib.cc cpp/hello-lib.h c:\\mingw\\include\\stdio.h \\",
+ " c:\\mingw\\include\\_mingw.h \\",
+ " c:\\mingw\\lib\\gcc\\mingw32\\4.8.1\\include\\stdarg.h");
Set<Path> expected = Sets.newHashSet(
root.getRelative("cpp/hello-lib.cc"),
@@ -56,9 +58,11 @@ public class DependencySetWindowsTest {
@Test
public void dotDParser_windowsPathsWithSpaces() throws Exception {
- Path dotd = scratch.file("/tmp/foo.d",
- "bazel-out/hello-lib/cpp/hello-lib.o: \\",
- "C:\\Program\\ Files\\ (x86)\\LLVM\\stddef.h");
+ Path dotd =
+ scratch.file(
+ "C:/tmp/foo.d",
+ "bazel-out/hello-lib/cpp/hello-lib.o: \\",
+ "C:\\Program\\ Files\\ (x86)\\LLVM\\stddef.h");
assertThat(newDependencySet().read(dotd).getDependencies())
.containsExactlyElementsIn(
Sets.newHashSet(fileSystem.getPath("C:/Program Files (x86)/LLVM/stddef.h")));
@@ -69,12 +73,14 @@ public class DependencySetWindowsTest {
// This is (slightly simplified) actual output from clang. Yes, clang will happily mix
// forward slashes and backslashes in a single path, not to mention using backslashes as
// separators next to backslashes as escape characters.
- Path dotd = scratch.file("/tmp/foo.d",
- "bazel-out/hello-lib/cpp/hello-lib.o: \\",
- "cpp/hello-lib.cc cpp/hello-lib.h /mingw/include\\stdio.h \\",
- "/mingw/include\\_mingw.h \\",
- "C:\\Program\\ Files\\ (x86)\\LLVM\\bin\\..\\lib\\clang\\3.5.0\\include\\stddef.h \\",
- "C:\\Program\\ Files\\ (x86)\\LLVM\\bin\\..\\lib\\clang\\3.5.0\\include\\stdarg.h");
+ Path dotd =
+ scratch.file(
+ "C:/tmp/foo.d",
+ "bazel-out/hello-lib/cpp/hello-lib.o: \\",
+ "cpp/hello-lib.cc cpp/hello-lib.h /mingw/include\\stdio.h \\",
+ "/mingw/include\\_mingw.h \\",
+ "C:\\Program\\ Files\\ (x86)\\LLVM\\bin\\..\\lib\\clang\\3.5.0\\include\\stddef.h \\",
+ "C:\\Program\\ Files\\ (x86)\\LLVM\\bin\\..\\lib\\clang\\3.5.0\\include\\stdarg.h");
Set<Path> expected = Sets.newHashSet(
root.getRelative("cpp/hello-lib.cc"),
@@ -93,10 +99,8 @@ public class DependencySetWindowsTest {
Path file2 = fileSystem.getPath("C:/blah/blah/genhello/hello.h");
Path file2DiffCase = fileSystem.getPath("C:/Blah/blah/Genhello/hello.h");
String filename = "hello.o";
- Path dotd = scratch.file("/tmp/foo.d",
- filename + ": \\",
- " " + file1 + " \\",
- " " + file2 + " ");
+ Path dotd =
+ scratch.file("C:/tmp/foo.d", filename + ": \\", " " + file1 + " \\", " " + file2 + " ");
assertThat(newDependencySet().read(dotd).getDependencies())
.containsExactly(file1, file2DiffCase);
}
diff --git a/src/test/java/com/google/devtools/build/lib/vfs/FileSystemTest.java b/src/test/java/com/google/devtools/build/lib/vfs/FileSystemTest.java
index 278a288dda..09ac79eec6 100644
--- a/src/test/java/com/google/devtools/build/lib/vfs/FileSystemTest.java
+++ b/src/test/java/com/google/devtools/build/lib/vfs/FileSystemTest.java
@@ -379,7 +379,7 @@ public abstract class FileSystemTest {
@Test
public void testSymbolicFileLinkExists() throws Exception {
Path someLink = absolutize("some-link");
- if (testFS.supportsSymbolicLinksNatively(someLink)) {
+ if (testFS.supportsSymbolicLinksNatively(someLink.getLocalPath())) {
someLink.createSymbolicLink(xFile);
assertThat(someLink.exists()).isTrue();
assertThat(someLink.statIfFound()).isNotNull();
@@ -389,7 +389,7 @@ public abstract class FileSystemTest {
@Test
public void testSymbolicFileLinkIsSymbolicLink() throws Exception {
Path someLink = absolutize("some-link");
- if (testFS.supportsSymbolicLinksNatively(someLink)) {
+ if (testFS.supportsSymbolicLinksNatively(someLink.getLocalPath())) {
someLink.createSymbolicLink(xFile);
assertThat(someLink.isSymbolicLink()).isTrue();
}
@@ -398,7 +398,7 @@ public abstract class FileSystemTest {
@Test
public void testSymbolicFileLinkIsFile() throws Exception {
Path someLink = absolutize("some-link");
- if (testFS.supportsSymbolicLinksNatively(someLink)) {
+ if (testFS.supportsSymbolicLinksNatively(someLink.getLocalPath())) {
someLink.createSymbolicLink(xFile);
assertThat(someLink.isFile()).isTrue();
}
@@ -407,7 +407,7 @@ public abstract class FileSystemTest {
@Test
public void testSymbolicFileLinkIsNotDirectory() throws Exception {
Path someLink = absolutize("some-link");
- if (testFS.supportsSymbolicLinksNatively(someLink)) {
+ if (testFS.supportsSymbolicLinksNatively(someLink.getLocalPath())) {
someLink.createSymbolicLink(xFile);
assertThat(someLink.isDirectory()).isFalse();
}
@@ -416,7 +416,7 @@ public abstract class FileSystemTest {
@Test
public void testSymbolicDirLinkExists() throws Exception {
Path someLink = absolutize("some-link");
- if (testFS.supportsSymbolicLinksNatively(someLink)) {
+ if (testFS.supportsSymbolicLinksNatively(someLink.getLocalPath())) {
someLink.createSymbolicLink(xEmptyDirectory);
assertThat(someLink.exists()).isTrue();
assertThat(someLink.statIfFound()).isNotNull();
@@ -426,7 +426,7 @@ public abstract class FileSystemTest {
@Test
public void testSymbolicDirLinkIsSymbolicLink() throws Exception {
Path someLink = absolutize("some-link");
- if (testFS.supportsSymbolicLinksNatively(someLink)) {
+ if (testFS.supportsSymbolicLinksNatively(someLink.getLocalPath())) {
someLink.createSymbolicLink(xEmptyDirectory);
assertThat(someLink.isSymbolicLink()).isTrue();
}
@@ -435,7 +435,7 @@ public abstract class FileSystemTest {
@Test
public void testSymbolicDirLinkIsDirectory() throws Exception {
Path someLink = absolutize("some-link");
- if (testFS.supportsSymbolicLinksNatively(someLink)) {
+ if (testFS.supportsSymbolicLinksNatively(someLink.getLocalPath())) {
someLink.createSymbolicLink(xEmptyDirectory);
assertThat(someLink.isDirectory()).isTrue();
}
@@ -444,7 +444,7 @@ public abstract class FileSystemTest {
@Test
public void testSymbolicDirLinkIsNotFile() throws Exception {
Path someLink = absolutize("some-link");
- if (testFS.supportsSymbolicLinksNatively(someLink)) {
+ if (testFS.supportsSymbolicLinksNatively(someLink.getLocalPath())) {
someLink.createSymbolicLink(xEmptyDirectory);
assertThat(someLink.isFile()).isFalse();
}
@@ -1287,7 +1287,7 @@ public abstract class FileSystemTest {
Path xNonEmptyDirectoryBar = xNonEmptyDirectory.getChild("bar");
xNonEmptyDirectory.setWritable(false);
- if (testFS.supportsSymbolicLinksNatively(xNonEmptyDirectoryBar)) {
+ if (testFS.supportsSymbolicLinksNatively(xNonEmptyDirectoryBar.getLocalPath())) {
try {
createSymbolicLink(xNonEmptyDirectoryBar, xNonEmptyDirectoryFoo);
fail("No exception thrown.");
@@ -1335,19 +1335,19 @@ public abstract class FileSystemTest {
@Test
public void testResolveSymlinks() throws Exception {
- if (testFS.supportsSymbolicLinksNatively(xLink)) {
+ if (testFS.supportsSymbolicLinksNatively(xLink.getLocalPath())) {
createSymbolicLink(xLink, xFile);
FileSystemUtils.createEmptyFile(xFile);
- assertThat(testFS.resolveOneLink(xLink)).isEqualTo(xFile.asFragment());
+ assertThat(testFS.resolveOneLink(xLink.getLocalPath())).isEqualTo(xFile.getPathString());
assertThat(xLink.resolveSymbolicLinks()).isEqualTo(xFile);
}
}
@Test
public void testResolveDanglingSymlinks() throws Exception {
- if (testFS.supportsSymbolicLinksNatively(xLink)) {
+ if (testFS.supportsSymbolicLinksNatively(xLink.getLocalPath())) {
createSymbolicLink(xLink, xNothing);
- assertThat(testFS.resolveOneLink(xLink)).isEqualTo(xNothing.asFragment());
+ assertThat(testFS.resolveOneLink(xLink.getLocalPath())).isEqualTo(xNothing.getPathString());
try {
xLink.resolveSymbolicLinks();
fail();
@@ -1358,15 +1358,15 @@ public abstract class FileSystemTest {
@Test
public void testResolveNonSymlinks() throws Exception {
- if (testFS.supportsSymbolicLinksNatively(xFile)) {
- assertThat(testFS.resolveOneLink(xFile)).isNull();
+ if (testFS.supportsSymbolicLinksNatively(xFile.getLocalPath())) {
+ assertThat(testFS.resolveOneLink(xFile.getLocalPath())).isNull();
assertThat(xFile.resolveSymbolicLinks()).isEqualTo(xFile);
}
}
@Test
public void testCreateHardLink_Success() throws Exception {
- if (!testFS.supportsHardLinksNatively(xFile)) {
+ if (!testFS.supportsHardLinksNatively(xFile.getLocalPath())) {
return;
}
xFile.createHardLink(xLink);
@@ -1379,7 +1379,7 @@ public abstract class FileSystemTest {
@Test
public void testCreateHardLink_NeitherOriginalNorLinkExists() throws Exception {
- if (!testFS.supportsHardLinksNatively(xFile)) {
+ if (!testFS.supportsHardLinksNatively(xFile.getLocalPath())) {
return;
}
@@ -1398,7 +1398,7 @@ public abstract class FileSystemTest {
@Test
public void testCreateHardLink_OriginalDoesNotExistAndLinkExists() throws Exception {
- if (!testFS.supportsHardLinksNatively(xFile)) {
+ if (!testFS.supportsHardLinksNatively(xFile.getLocalPath())) {
return;
}
@@ -1419,7 +1419,7 @@ public abstract class FileSystemTest {
@Test
public void testCreateHardLink_BothOriginalAndLinkExist() throws Exception {
- if (!testFS.supportsHardLinksNatively(xFile)) {
+ if (!testFS.supportsHardLinksNatively(xFile.getLocalPath())) {
return;
}
/* Both original file and link file exist */
@@ -1437,6 +1437,7 @@ public abstract class FileSystemTest {
}
protected boolean isHardLinked(Path a, Path b) throws IOException {
- return testFS.stat(a, false).getNodeId() == testFS.stat(b, false).getNodeId();
+ return testFS.stat(a.getLocalPath(), false).getNodeId()
+ == testFS.stat(b.getLocalPath(), false).getNodeId();
}
}
diff --git a/src/test/java/com/google/devtools/build/lib/vfs/FileSystemUtilsTest.java b/src/test/java/com/google/devtools/build/lib/vfs/FileSystemUtilsTest.java
index 0e9b74ed3b..3b9a2dc76d 100644
--- a/src/test/java/com/google/devtools/build/lib/vfs/FileSystemUtilsTest.java
+++ b/src/test/java/com/google/devtools/build/lib/vfs/FileSystemUtilsTest.java
@@ -851,8 +851,8 @@ public class FileSystemUtilsTest {
FileSystemUtils.createHardLink(linkPath, originalPath);
assertThat(originalPath.exists()).isTrue();
assertThat(linkPath.exists()).isTrue();
- assertThat(fileSystem.stat(linkPath, false).getNodeId())
- .isEqualTo(fileSystem.stat(originalPath, false).getNodeId());
+ assertThat(fileSystem.stat(linkPath.getLocalPath(), false).getNodeId())
+ .isEqualTo(fileSystem.stat(originalPath.getLocalPath(), false).getNodeId());
}
@Test
@@ -892,11 +892,11 @@ public class FileSystemUtilsTest {
assertThat(linkPath1.exists()).isTrue();
assertThat(linkPath2.exists()).isTrue();
assertThat(linkPath3.exists()).isTrue();
- assertThat(fileSystem.stat(linkPath1, false).getNodeId())
- .isEqualTo(fileSystem.stat(originalPath1, false).getNodeId());
- assertThat(fileSystem.stat(linkPath2, false).getNodeId())
- .isEqualTo(fileSystem.stat(originalPath2, false).getNodeId());
- assertThat(fileSystem.stat(linkPath3, false).getNodeId())
- .isEqualTo(fileSystem.stat(originalPath3, false).getNodeId());
+ assertThat(fileSystem.stat(linkPath1.getLocalPath(), false).getNodeId())
+ .isEqualTo(fileSystem.stat(originalPath1.getLocalPath(), false).getNodeId());
+ assertThat(fileSystem.stat(linkPath2.getLocalPath(), false).getNodeId())
+ .isEqualTo(fileSystem.stat(originalPath2.getLocalPath(), false).getNodeId());
+ assertThat(fileSystem.stat(linkPath3.getLocalPath(), false).getNodeId())
+ .isEqualTo(fileSystem.stat(originalPath3.getLocalPath(), false).getNodeId());
}
}
diff --git a/src/test/java/com/google/devtools/build/lib/vfs/GlobTest.java b/src/test/java/com/google/devtools/build/lib/vfs/GlobTest.java
index 5b0958fae1..70fc86dc48 100644
--- a/src/test/java/com/google/devtools/build/lib/vfs/GlobTest.java
+++ b/src/test/java/com/google/devtools/build/lib/vfs/GlobTest.java
@@ -54,15 +54,18 @@ public class GlobTest {
@Before
public final void initializeFileSystem() throws Exception {
- fs = new InMemoryFileSystem() {
- @Override
- public Collection<Dirent> readdir(Path path, boolean followSymlinks) throws IOException {
- if (path.equals(throwOnReaddir)) {
- throw new FileNotFoundException(path.getPathString());
- }
- return super.readdir(path, followSymlinks);
- }
- };
+ fs =
+ new InMemoryFileSystem() {
+ @Override
+ public Collection<Dirent> readdir(LocalPath path, boolean followSymlinks)
+ throws IOException {
+ if (throwOnReaddir != null
+ && path.getPathString().equals(throwOnReaddir.getPathString())) {
+ throw new FileNotFoundException(path.getPathString());
+ }
+ return super.readdir(path, followSymlinks);
+ }
+ };
tmpPath = fs.getPath("/globtmp");
for (String dir : ImmutableList.of("foo/bar/wiz",
"foo/barnacle/wiz",
diff --git a/src/test/java/com/google/devtools/build/lib/vfs/PathTrieTest.java b/src/test/java/com/google/devtools/build/lib/vfs/PathTrieTest.java
deleted file mode 100644
index 0807b4aa5d..0000000000
--- a/src/test/java/com/google/devtools/build/lib/vfs/PathTrieTest.java
+++ /dev/null
@@ -1,78 +0,0 @@
-// Copyright 2014 The Bazel Authors. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-package com.google.devtools.build.lib.vfs;
-
-import static com.google.common.truth.Truth.assertThat;
-import static com.google.devtools.build.lib.testutil.MoreAsserts.assertThrows;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-
-/** Unit tests for {@link PathTrie}. */
-@RunWith(JUnit4.class)
-public class PathTrieTest {
- @Test
- public void empty() {
- PathTrie<Integer> pathTrie = new PathTrie<>();
- assertThat(pathTrie.get(PathFragment.EMPTY_FRAGMENT)).isNull();
- assertThat(pathTrie.get(PathFragment.create("/x"))).isNull();
- assertThat(pathTrie.get(PathFragment.create("/x/y"))).isNull();
- }
-
- @Test
- public void simpleBranches() {
- PathTrie<Integer> pathTrie = new PathTrie<>();
- pathTrie.put(PathFragment.create("/a"), 1);
- pathTrie.put(PathFragment.create("/b"), 2);
-
- assertThat(pathTrie.get(PathFragment.EMPTY_FRAGMENT)).isNull();
- assertThat(pathTrie.get(PathFragment.create("/a"))).isEqualTo(1);
- assertThat(pathTrie.get(PathFragment.create("/a/b"))).isEqualTo(1);
- assertThat(pathTrie.get(PathFragment.create("/a/b/c"))).isEqualTo(1);
- assertThat(pathTrie.get(PathFragment.create("/b"))).isEqualTo(2);
- assertThat(pathTrie.get(PathFragment.create("/b/c"))).isEqualTo(2);
- }
-
- @Test
- public void nestedDirectories() {
- PathTrie<Integer> pathTrie = new PathTrie<>();
- pathTrie.put(PathFragment.create("/a/b/c"), 3);
- assertThat(pathTrie.get(PathFragment.EMPTY_FRAGMENT)).isNull();
- assertThat(pathTrie.get(PathFragment.create("/a"))).isNull();
- assertThat(pathTrie.get(PathFragment.create("/a/b"))).isNull();
- assertThat(pathTrie.get(PathFragment.create("/a/b/c"))).isEqualTo(3);
- assertThat(pathTrie.get(PathFragment.create("/a/b/c/d"))).isEqualTo(3);
-
- pathTrie.put(PathFragment.create("/a"), 1);
- assertThat(pathTrie.get(PathFragment.EMPTY_FRAGMENT)).isNull();
- assertThat(pathTrie.get(PathFragment.create("/b"))).isNull();
- assertThat(pathTrie.get(PathFragment.create("/a"))).isEqualTo(1);
- assertThat(pathTrie.get(PathFragment.create("/a/b"))).isEqualTo(1);
- assertThat(pathTrie.get(PathFragment.create("/a/b/c"))).isEqualTo(3);
- assertThat(pathTrie.get(PathFragment.create("/a/b/c/d"))).isEqualTo(3);
-
- pathTrie.put(PathFragment.ROOT_FRAGMENT, 0);
- assertThat(pathTrie.get(PathFragment.EMPTY_FRAGMENT)).isEqualTo(0);
- assertThat(pathTrie.get(PathFragment.create("/b"))).isEqualTo(0);
- assertThat(pathTrie.get(PathFragment.create("/a"))).isEqualTo(1);
- assertThat(pathTrie.get(PathFragment.create("/a/b"))).isEqualTo(1);
- }
-
- @Test
- public void unrootedDirectoriesError() {
- PathTrie<Integer> pathTrie = new PathTrie<>();
- assertThrows(IllegalArgumentException.class, () -> pathTrie.put(PathFragment.create("a"), 1));
- }
-}
diff --git a/src/test/java/com/google/devtools/build/lib/vfs/SearchPathTest.java b/src/test/java/com/google/devtools/build/lib/vfs/SearchPathTest.java
index 6c545ac790..b49af40df9 100644
--- a/src/test/java/com/google/devtools/build/lib/vfs/SearchPathTest.java
+++ b/src/test/java/com/google/devtools/build/lib/vfs/SearchPathTest.java
@@ -38,7 +38,7 @@ public class SearchPathTest {
assertThat(SearchPath.parse(fs, "/:/bin")).isEqualTo(searchPath);
assertThat(SearchPath.parse(fs, ".:/:/bin")).isEqualTo(searchPath);
- fs.getOutputStream(fs.getPath("/bin/exe")).write(new byte[5]);
+ fs.getOutputStream(fs.getPath("/bin/exe").getLocalPath()).write(new byte[5]);
assertThat(SearchPath.which(searchPath, "exe")).isNull();
diff --git a/src/test/java/com/google/devtools/build/lib/vfs/SymlinkAwareFileSystemTest.java b/src/test/java/com/google/devtools/build/lib/vfs/SymlinkAwareFileSystemTest.java
index 4720a6e773..b9f6485c8a 100644
--- a/src/test/java/com/google/devtools/build/lib/vfs/SymlinkAwareFileSystemTest.java
+++ b/src/test/java/com/google/devtools/build/lib/vfs/SymlinkAwareFileSystemTest.java
@@ -78,7 +78,7 @@ public abstract class SymlinkAwareFileSystemTest extends FileSystemTest {
assertThat(linkPath.isDirectory(Symlinks.NOFOLLOW)).isFalse();
assertThat(linkPath.isDirectory(Symlinks.FOLLOW)).isFalse();
- if (testFS.supportsSymbolicLinksNatively(linkPath)) {
+ if (testFS.supportsSymbolicLinksNatively(linkPath.getLocalPath())) {
assertThat(linkPath.getFileSize(Symlinks.NOFOLLOW)).isEqualTo(newPath.toString().length());
assertThat(linkPath.getFileSize()).isEqualTo(newPath.getFileSize(Symlinks.NOFOLLOW));
}
@@ -196,7 +196,7 @@ public abstract class SymlinkAwareFileSystemTest extends FileSystemTest {
PathFragment relative = PathFragment.create(linkTarget);
linkPath.delete();
createSymbolicLink(linkPath, relative);
- if (testFS.supportsSymbolicLinksNatively(linkPath)) {
+ if (testFS.supportsSymbolicLinksNatively(linkPath.getLocalPath())) {
assertThat(linkPath.getFileSize(Symlinks.NOFOLLOW)).isEqualTo(linkTarget.length());
assertThat(linkPath.readSymbolicLink()).isEqualTo(relative);
}
@@ -224,7 +224,7 @@ public abstract class SymlinkAwareFileSystemTest extends FileSystemTest {
// The path may not be a symlink, neither on Darwin nor on Linux.
String nonLinkEntry = null;
- for (String child : testFS.getDirectoryEntries(rootPath)) {
+ for (String child : testFS.getDirectoryEntries(rootPath.getLocalPath())) {
Path p = rootPath.getChild(child);
if (!p.isSymbolicLink() && p.isDirectory()) {
nonLinkEntry = p.getBaseName();
@@ -259,7 +259,7 @@ public abstract class SymlinkAwareFileSystemTest extends FileSystemTest {
Path link = absolutize("recursive-link");
createSymbolicLink(link, link);
- if (testFS.supportsSymbolicLinksNatively(link)) {
+ if (testFS.supportsSymbolicLinksNatively(link.getLocalPath())) {
try {
link.resolveSymbolicLinks();
fail();
@@ -276,7 +276,7 @@ public abstract class SymlinkAwareFileSystemTest extends FileSystemTest {
createSymbolicLink(link2, link1);
createSymbolicLink(link1, link2);
- if (testFS.supportsSymbolicLinksNatively(link1)) {
+ if (testFS.supportsSymbolicLinksNatively(link1.getLocalPath())) {
try {
link1.resolveSymbolicLinks();
fail();
@@ -288,7 +288,7 @@ public abstract class SymlinkAwareFileSystemTest extends FileSystemTest {
@Test
public void testResolveSymbolicLinksENOENT() {
- if (testFS.supportsSymbolicLinksNatively(xDanglingLink)) {
+ if (testFS.supportsSymbolicLinksNatively(xDanglingLink.getLocalPath())) {
try {
xDanglingLink.resolveSymbolicLinks();
fail();
@@ -302,7 +302,7 @@ public abstract class SymlinkAwareFileSystemTest extends FileSystemTest {
public void testResolveSymbolicLinksENOTDIR() throws IOException {
Path badLinkTarget = xFile.getChild("bad"); // parent is not a directory!
Path badLink = absolutize("badLink");
- if (testFS.supportsSymbolicLinksNatively(badLink)) {
+ if (testFS.supportsSymbolicLinksNatively(badLink.getLocalPath())) {
createSymbolicLink(badLink, badLinkTarget);
try {
badLink.resolveSymbolicLinks();
@@ -317,7 +317,7 @@ public abstract class SymlinkAwareFileSystemTest extends FileSystemTest {
@Test
public void testResolveSymbolicLinksWithUplevelRefs() throws IOException {
- if (testFS.supportsSymbolicLinksNatively(xLinkToFile)) {
+ if (testFS.supportsSymbolicLinksNatively(xLinkToFile.getLocalPath())) {
// Create a series of links that refer to xFile as ./xFile,
// ./../foo/xFile, ./../../bar/foo/xFile, etc. They should all resolve
// to xFile.
@@ -335,7 +335,7 @@ public abstract class SymlinkAwareFileSystemTest extends FileSystemTest {
@Test
public void testReadSymbolicLink() throws IOException {
- if (testFS.supportsSymbolicLinksNatively(xDanglingLink)) {
+ if (testFS.supportsSymbolicLinksNatively(xDanglingLink.getLocalPath())) {
assertThat(xDanglingLink.readSymbolicLink().toString()).isEqualTo(xNothing.toString());
}
@@ -364,7 +364,7 @@ public abstract class SymlinkAwareFileSystemTest extends FileSystemTest {
throws IOException {
xEmptyDirectory.setWritable(false);
Path xChildOfReadonlyDir = xEmptyDirectory.getChild("x");
- if (testFS.supportsSymbolicLinksNatively(xChildOfReadonlyDir)) {
+ if (testFS.supportsSymbolicLinksNatively(xChildOfReadonlyDir.getLocalPath())) {
try {
xChildOfReadonlyDir.createSymbolicLink(xNothing);
fail();
@@ -386,7 +386,7 @@ public abstract class SymlinkAwareFileSystemTest extends FileSystemTest {
assertThat(someLink.isSymbolicLink()).isTrue();
assertThat(someLink.exists(Symlinks.NOFOLLOW)).isTrue(); // the link itself exists
assertThat(someLink.exists()).isFalse(); // ...but the referent doesn't
- if (testFS.supportsSymbolicLinksNatively(someLink)) {
+ if (testFS.supportsSymbolicLinksNatively(someLink.getLocalPath())) {
try {
someLink.resolveSymbolicLinks();
} catch (FileNotFoundException e) {
@@ -398,7 +398,7 @@ public abstract class SymlinkAwareFileSystemTest extends FileSystemTest {
@Test
public void testCannotCreateSymbolicLinkWithoutParent() throws IOException {
Path xChildOfMissingDir = xNothing.getChild("x");
- if (testFS.supportsSymbolicLinksNatively(xChildOfMissingDir)) {
+ if (testFS.supportsSymbolicLinksNatively(xChildOfMissingDir.getLocalPath())) {
try {
xChildOfMissingDir.createSymbolicLink(xFile);
fail();
diff --git a/src/test/java/com/google/devtools/build/lib/vfs/UnionFileSystemTest.java b/src/test/java/com/google/devtools/build/lib/vfs/UnionFileSystemTest.java
index 1e877a5255..a330197a99 100644
--- a/src/test/java/com/google/devtools/build/lib/vfs/UnionFileSystemTest.java
+++ b/src/test/java/com/google/devtools/build/lib/vfs/UnionFileSystemTest.java
@@ -54,8 +54,8 @@ public class UnionFileSystemTest extends SymlinkAwareFileSystemTest {
private UnionFileSystem createDefaultUnionFileSystem() {
return new UnionFileSystem(
ImmutableMap.of(
- PathFragment.create("/in"), inDelegate,
- PathFragment.create("/out"), outDelegate),
+ LocalPath.create("/in"), inDelegate,
+ LocalPath.create("/out"), outDelegate),
defaultDelegate);
}
@@ -76,9 +76,9 @@ public class UnionFileSystemTest extends SymlinkAwareFileSystemTest {
@Test
public void testBasicDelegation() throws Exception {
unionfs = createDefaultUnionFileSystem();
- Path fooPath = unionfs.getPath("/foo");
- Path inPath = unionfs.getPath("/in");
- Path outPath = unionfs.getPath("/out/in.txt");
+ LocalPath fooPath = LocalPath.create("/foo");
+ LocalPath inPath = LocalPath.create("/in");
+ LocalPath outPath = LocalPath.create("/out/in.txt");
assertThat(unionfs.getDelegate(inPath)).isSameAs(inDelegate);
assertThat(unionfs.getDelegate(outPath)).isSameAs(outDelegate);
assertThat(unionfs.getDelegate(fooPath)).isSameAs(defaultDelegate);
@@ -101,7 +101,7 @@ public class UnionFileSystemTest extends SymlinkAwareFileSystemTest {
@Test
public void testDefaultFileSystemRequired() throws Exception {
try {
- new UnionFileSystem(ImmutableMap.<PathFragment, FileSystem>of(), null);
+ new UnionFileSystem(ImmutableMap.of(), null);
fail("Able to create a UnionFileSystem with no default!");
} catch (NullPointerException expected) {
// OK - should fail in this case.
@@ -114,16 +114,16 @@ public class UnionFileSystemTest extends SymlinkAwareFileSystemTest {
public void testPrefixDelegation() throws Exception {
unionfs =
new UnionFileSystem(
- ImmutableMap.<PathFragment, FileSystem>of(
- PathFragment.create("/foo"), inDelegate,
- PathFragment.create("/foo/bar"), outDelegate),
+ ImmutableMap.of(
+ LocalPath.create("/foo"), inDelegate,
+ LocalPath.create("/foo/bar"), outDelegate),
defaultDelegate);
- assertThat(unionfs.getDelegate(unionfs.getPath("/foo/foo.txt"))).isSameAs(inDelegate);
- assertThat(unionfs.getDelegate(unionfs.getPath("/foo/bar/foo.txt"))).isSameAs(outDelegate);
- assertThat(unionfs.getDelegate(unionfs.getPath("/foo/bar/../foo.txt"))).isSameAs(inDelegate);
- assertThat(unionfs.getDelegate(unionfs.getPath("/bar/foo.txt"))).isSameAs(defaultDelegate);
- assertThat(unionfs.getDelegate(unionfs.getPath("/foo/bar/../.."))).isSameAs(defaultDelegate);
+ assertThat(unionfs.getDelegate(LocalPath.create("/foo/foo.txt"))).isSameAs(inDelegate);
+ assertThat(unionfs.getDelegate(LocalPath.create("/foo/bar/foo.txt"))).isSameAs(outDelegate);
+ assertThat(unionfs.getDelegate(LocalPath.create("/foo/bar/../foo.txt"))).isSameAs(inDelegate);
+ assertThat(unionfs.getDelegate(LocalPath.create("/bar/foo.txt"))).isSameAs(defaultDelegate);
+ assertThat(unionfs.getDelegate(LocalPath.create("/foo/bar/../.."))).isSameAs(defaultDelegate);
}
// Checks that files cannot be modified when the filesystem is created
@@ -133,17 +133,17 @@ public class UnionFileSystemTest extends SymlinkAwareFileSystemTest {
unionfs =
new UnionFileSystem(
ImmutableMap.of(
- PathFragment.create("/rw"), new XAttrInMemoryFs(BlazeClock.instance()),
- PathFragment.create("/ro"),
+ LocalPath.create("/rw"), new XAttrInMemoryFs(BlazeClock.instance()),
+ LocalPath.create("/ro"),
new XAttrInMemoryFs(BlazeClock.instance()) {
@Override
- public boolean supportsModifications(Path path) {
+ public boolean supportsModifications(LocalPath path) {
return false;
}
}),
defaultDelegate);
- Path rwPath = unionfs.getPath("/rw/foo.txt");
- Path roPath = unionfs.getPath("/ro/foo.txt");
+ LocalPath rwPath = LocalPath.create("/rw/foo.txt");
+ LocalPath roPath = LocalPath.create("/ro/foo.txt");
assertThat(unionfs.supportsModifications(rwPath)).isTrue();
assertThat(unionfs.supportsModifications(roPath)).isFalse();
}
@@ -152,18 +152,18 @@ public class UnionFileSystemTest extends SymlinkAwareFileSystemTest {
// delegate filesystems; i.e. they can be seen from the filesystem of the parent.
@Test
public void testDelegateRootDirectoryCreation() throws Exception {
- Path foo = unionfs.getPath("/foo");
- Path bar = unionfs.getPath("/bar");
- Path out = unionfs.getPath("/out");
+ LocalPath foo = LocalPath.create("/foo");
+ LocalPath bar = LocalPath.create("/bar");
+ LocalPath out = LocalPath.create("/out");
assertThat(unionfs.createDirectory(foo)).isTrue();
assertThat(unionfs.createDirectory(bar)).isTrue();
assertThat(unionfs.createDirectory(out)).isTrue();
- Path outFile = unionfs.getPath("/out/in");
- FileSystemUtils.writeContentAsLatin1(outFile, "Out");
+ LocalPath outFile = LocalPath.create("/out/in");
+ FileSystemUtils.writeContentAsLatin1(unionfs, outFile, "Out");
// FileSystemTest.setUp() silently creates the test root on the filesystem...
Path testDirUnderRoot = unionfs.getPath(workingDir.asFragment().subFragment(0, 1));
- assertThat(unionfs.getDirectoryEntries(unionfs.getRootDirectory()))
+ assertThat(unionfs.getDirectoryEntries(LocalPath.create("/")))
.containsExactly(
foo.getBaseName(),
bar.getBaseName(),
@@ -172,31 +172,30 @@ public class UnionFileSystemTest extends SymlinkAwareFileSystemTest {
assertThat(unionfs.getDirectoryEntries(out)).containsExactly(outFile.getBaseName());
assertThat(defaultDelegate).isSameAs(unionfs.getDelegate(foo));
- assertThat(unionfs.adjustPath(foo, defaultDelegate).asFragment()).isEqualTo(foo.asFragment());
+ assertThat(unionfs.adjustPath(foo, defaultDelegate)).isEqualTo(foo);
assertThat(defaultDelegate).isSameAs(unionfs.getDelegate(bar));
assertThat(outDelegate).isSameAs(unionfs.getDelegate(outFile));
assertThat(outDelegate).isSameAs(unionfs.getDelegate(out));
// As a fragment (i.e. without filesystem or root info), the path name should be preserved.
- assertThat(unionfs.adjustPath(outFile, outDelegate).asFragment())
- .isEqualTo(outFile.asFragment());
+ assertThat(unionfs.adjustPath(outFile, outDelegate)).isEqualTo(outFile);
}
// Ensure that the right filesystem is still chosen when paths contain "..".
@Test
public void testDelegationOfUpLevelReferences() throws Exception {
- assertThat(unionfs.getDelegate(unionfs.getPath("/in/../foo.txt"))).isSameAs(defaultDelegate);
- assertThat(unionfs.getDelegate(unionfs.getPath("/out/../in"))).isSameAs(inDelegate);
- assertThat(unionfs.getDelegate(unionfs.getPath("/out/../in/../out/foo.txt")))
+ assertThat(unionfs.getDelegate(LocalPath.create("/in/../foo.txt"))).isSameAs(defaultDelegate);
+ assertThat(unionfs.getDelegate(LocalPath.create("/out/../in"))).isSameAs(inDelegate);
+ assertThat(unionfs.getDelegate(LocalPath.create("/out/../in/../out/foo.txt")))
.isSameAs(outDelegate);
- assertThat(unionfs.getDelegate(unionfs.getPath("/in/./foo.txt"))).isSameAs(inDelegate);
+ assertThat(unionfs.getDelegate(LocalPath.create("/in/./foo.txt"))).isSameAs(inDelegate);
}
// Basic *explicit* cross-filesystem symlink check.
// Note: This does not work implicitly yet, as the next test illustrates.
@Test
public void testCrossDeviceSymlinks() throws Exception {
- assertThat(unionfs.createDirectory(unionfs.getPath("/out"))).isTrue();
+ assertThat(unionfs.createDirectory(LocalPath.create("/out"))).isTrue();
// Create an "/in" directory directly on the output delegate to bypass the
// UnionFileSystem's mapping.
@@ -205,8 +204,8 @@ public class UnionFileSystemTest extends SymlinkAwareFileSystemTest {
outStream.write('i');
outStream.close();
- Path outFoo = unionfs.getPath("/out/foo");
- unionfs.createSymbolicLink(outFoo, PathFragment.create("../in/bar.txt"));
+ LocalPath outFoo = LocalPath.create("/out/foo");
+ unionfs.createSymbolicLink(outFoo, "../in/bar.txt");
assertThat(unionfs.stat(outFoo, false).isSymbolicLink()).isTrue();
try {
@@ -216,24 +215,13 @@ public class UnionFileSystemTest extends SymlinkAwareFileSystemTest {
// OK
}
- Path resolved = unionfs.resolveSymbolicLinks(outFoo);
- assertThat(resolved.getFileSystem()).isSameAs(unionfs);
- InputStream barInput = resolved.getInputStream();
+ LocalPath resolved = unionfs.resolveSymbolicLinks(outFoo);
+ InputStream barInput = unionfs.getInputStream(resolved);
int barChar = barInput.read();
barInput.close();
assertThat(barChar).isEqualTo('i');
}
- @Test
- public void testNoDelegateLeakage() throws Exception {
- assertThat(unionfs.getPath("/in/foo.txt").getFileSystem()).isSameAs(unionfs);
- assertThat(unionfs.getPath("/in/foo/bar").getParentDirectory().getFileSystem())
- .isSameAs(unionfs);
- unionfs.createDirectory(unionfs.getPath("/out"));
- unionfs.createDirectory(unionfs.getPath("/out/foo"));
- unionfs.createDirectory(unionfs.getPath("/out/foo/bar"));
- }
-
// Write using the VFS through a UnionFileSystem and check that the file can
// be read back in the same location using standard Java IO.
// There is a similar test in UnixFileSystem, but this is essential to ensure
@@ -242,12 +230,11 @@ public class UnionFileSystemTest extends SymlinkAwareFileSystemTest {
public void testDelegateOperationsReflectOnLocalFilesystem() throws Exception {
unionfs =
new UnionFileSystem(
- ImmutableMap.<PathFragment, FileSystem>of(
- workingDir.getParentDirectory().asFragment(), new UnixFileSystem()),
+ ImmutableMap.of(workingDir.getLocalPath().getParentDirectory(), new UnixFileSystem()),
defaultDelegate);
// This is a child of the current tmpdir, and doesn't exist on its own.
// It would be created in setup(), but of course, that didn't use a UnixFileSystem.
- unionfs.createDirectory(workingDir);
+ unionfs.createDirectory(workingDir.getLocalPath());
Path testFile = unionfs.getPath(workingDir.getRelative("test_file").asFragment());
assertThat(testFile.asFragment().startsWith(workingDir.asFragment())).isTrue();
String testString = "This is a test file";
@@ -256,7 +243,7 @@ public class UnionFileSystemTest extends SymlinkAwareFileSystemTest {
assertThat(new String(FileSystemUtils.readContentAsLatin1(testFile))).isEqualTo(testString);
} finally {
testFile.delete();
- assertThat(unionfs.delete(workingDir)).isTrue();
+ assertThat(unionfs.delete(workingDir.getLocalPath())).isTrue();
}
}
@@ -265,8 +252,7 @@ public class UnionFileSystemTest extends SymlinkAwareFileSystemTest {
public void testCreateParentsAcrossMapping() throws Exception {
unionfs =
new UnionFileSystem(
- ImmutableMap.<PathFragment, FileSystem>of(PathFragment.create("/out/dir"), outDelegate),
- defaultDelegate);
+ ImmutableMap.of(LocalPath.create("/out/dir"), outDelegate), defaultDelegate);
Path outDir = unionfs.getPath("/out/dir/biz/bang");
FileSystemUtils.createDirectoryAndParents(outDir);
assertThat(outDir.isDirectory()).isTrue();
@@ -278,8 +264,7 @@ public class UnionFileSystemTest extends SymlinkAwareFileSystemTest {
}
@Override
- public byte[] getxattr(Path path, String name) {
- assertThat(path.getFileSystem()).isSameAs(this);
+ public byte[] getxattr(LocalPath path, String name) {
return (name.equals(XATTR_KEY)) ? XATTR_VAL.getBytes(UTF_8) : null;
}
}
diff --git a/src/test/java/com/google/devtools/build/lib/vfs/UnixLocalPathTest.java b/src/test/java/com/google/devtools/build/lib/vfs/UnixLocalPathTest.java
index 2cdb4014ae..16ae52cc4c 100644
--- a/src/test/java/com/google/devtools/build/lib/vfs/UnixLocalPathTest.java
+++ b/src/test/java/com/google/devtools/build/lib/vfs/UnixLocalPathTest.java
@@ -162,6 +162,17 @@ public class UnixLocalPathTest extends LocalPathAbstractTest {
assertThat(create("/..")).isEqualTo(create("/.."));
}
+ @Test
+ public void testRootsUnix() {
+ assertThat(create("/").getDrive().getPathString()).isEqualTo("/");
+ assertThat(create("/usr").getDrive().getPathString()).isEqualTo("/");
+ assertThrows(IllegalArgumentException.class, () -> create("").getDrive());
+
+ assertThat(create("/").isRoot()).isTrue();
+ assertThat(create("/usr").isRoot()).isFalse();
+ assertThat(create("").isRoot()).isFalse();
+ }
+
@Override
protected OsPathPolicy getFilePathOs() {
return new UnixOsPathPolicy();
diff --git a/src/test/java/com/google/devtools/build/lib/vfs/WindowsLocalPathTest.java b/src/test/java/com/google/devtools/build/lib/vfs/WindowsLocalPathTest.java
index ac5acef1f4..88c7b6f248 100644
--- a/src/test/java/com/google/devtools/build/lib/vfs/WindowsLocalPathTest.java
+++ b/src/test/java/com/google/devtools/build/lib/vfs/WindowsLocalPathTest.java
@@ -14,9 +14,9 @@
package com.google.devtools.build.lib.vfs;
import static com.google.common.truth.Truth.assertThat;
+import static com.google.devtools.build.lib.testutil.MoreAsserts.assertThrows;
import com.google.common.testing.EqualsTester;
-import com.google.devtools.build.lib.testutil.MoreAsserts;
import com.google.devtools.build.lib.vfs.LocalPath.OsPathPolicy;
import com.google.devtools.build.lib.vfs.LocalPath.WindowsOsPathPolicy;
import com.google.devtools.build.lib.vfs.LocalPath.WindowsOsPathPolicy.ShortPathResolver;
@@ -101,8 +101,14 @@ public class WindowsLocalPathTest extends LocalPathAbstractTest {
@Test
public void testisAbsoluteWindows() {
assertThat(create("C:/").isAbsolute()).isTrue();
- // test that msys paths turn into absolute paths
+ }
+
+ // We support unix paths to make test sharing easier
+ @Test
+ public void testUnixPathSupport() {
assertThat(create("/").isAbsolute()).isTrue();
+ assertThat(create("/foo").isAbsolute()).isTrue();
+ assertThat(create("/foo").getParentDirectory().getPathString()).isEqualTo("/");
}
@Test
@@ -110,22 +116,7 @@ public class WindowsLocalPathTest extends LocalPathAbstractTest {
assertThat(create("C:/foo").relativeTo(create("C:/"))).isEqualTo(create("foo"));
// Case insensitivity test
assertThat(create("C:/foo/bar").relativeTo(create("C:/FOO"))).isEqualTo(create("bar"));
- MoreAsserts.assertThrows(
- IllegalArgumentException.class, () -> create("D:/foo").relativeTo(create("C:/")));
- }
-
- @Test
- public void testAbsoluteUnixPathIsRelativeToWindowsUnixRoot() {
- assertThat(create("/").getPathString()).isEqualTo("C:/fake/msys");
- assertThat(create("/foo/bar").getPathString()).isEqualTo("C:/fake/msys/foo/bar");
- assertThat(create("/foo/bar").getPathString()).isEqualTo("C:/fake/msys/foo/bar");
- }
-
- @Test
- public void testAbsoluteUnixPathReferringToDriveIsRecognized() {
- assertThat(create("/c/foo").getPathString()).isEqualTo("C:/foo");
- assertThat(create("/c/foo").getPathString()).isEqualTo("C:/foo");
- assertThat(create("/c:").getPathString()).isNotEqualTo("C:/foo");
+ assertThrows(IllegalArgumentException.class, () -> create("D:/foo").relativeTo(create("C:/")));
}
@Test
@@ -161,4 +152,16 @@ public class WindowsLocalPathTest extends LocalPathAbstractTest {
// Assert relative paths that look like short paths are untouched
assertThat(create("progra~1").getPathString()).isEqualTo("progra~1");
}
+
+ @Test
+ public void testRootsWindows() {
+ assertThat(create("C:/").getDrive().getPathString()).isEqualTo("C:/");
+ assertThat(create("C:/usr").getDrive().getPathString()).isEqualTo("C:/");
+ assertThrows(IllegalArgumentException.class, () -> create("").getDrive());
+
+ assertThat(create("C:/").isRoot()).isFalse();
+ assertThat(create("C:/usr").isRoot()).isFalse();
+ assertThat(create("/").isRoot()).isTrue();
+ assertThat(create("").isRoot()).isFalse();
+ }
}
diff --git a/src/test/java/com/google/devtools/build/lib/windows/WindowsFileSystemTest.java b/src/test/java/com/google/devtools/build/lib/windows/WindowsFileSystemTest.java
index 8937c453a7..d50b243f5f 100644
--- a/src/test/java/com/google/devtools/build/lib/windows/WindowsFileSystemTest.java
+++ b/src/test/java/com/google/devtools/build/lib/windows/WindowsFileSystemTest.java
@@ -25,7 +25,6 @@ import com.google.common.collect.Iterables;
import com.google.devtools.build.lib.testutil.TestSpec;
import com.google.devtools.build.lib.util.OS;
import com.google.devtools.build.lib.vfs.Path;
-import com.google.devtools.build.lib.vfs.PathFragment;
import com.google.devtools.build.lib.vfs.Symlinks;
import com.google.devtools.build.lib.windows.WindowsFileSystem.WindowsPath;
import com.google.devtools.build.lib.windows.jni.WindowsFileOperations;
@@ -100,9 +99,9 @@ public class WindowsFileSystemTest {
assertThat(juncBadPath.exists(Symlinks.NOFOLLOW)).isTrue();
// TODO(bazel-team): fix https://github.com/bazelbuild/bazel/issues/1690 and uncomment the
// assertion below.
- //assertThat(fs.isSymbolicLink(juncBadPath)).isTrue();
- assertThat(fs.isDirectory(juncBadPath, /* followSymlinks */ true)).isFalse();
- assertThat(fs.isDirectory(juncBadPath, /* followSymlinks */ false)).isFalse();
+ // assertThat(fs.isSymbolicLink(juncBadPath)).isTrue();
+ assertThat(fs.isDirectory(juncBadPath.getLocalPath(), /* followSymlinks */ true)).isFalse();
+ assertThat(fs.isDirectory(juncBadPath.getLocalPath(), /* followSymlinks */ false)).isFalse();
// Test deleting a dangling junction.
assertThat(juncBadPath.delete()).isTrue();
@@ -333,19 +332,21 @@ public class WindowsFileSystemTest {
assertThat(fs.getPath(scratchRoot).createDirectory()).isTrue();
// Create symlink with directory target, relative path.
Path link1 = fs.getPath(scratchRoot).getRelative("link1");
- fs.createSymbolicLink(link1, PathFragment.create(".."));
+ fs.createSymbolicLink(link1.getLocalPath(), "..");
// Create symlink with directory target, absolute path.
Path link2 = fs.getPath(scratchRoot).getRelative("link2");
- fs.createSymbolicLink(link2, fs.getPath(scratchRoot).getRelative("link1").asFragment());
+ fs.createSymbolicLink(
+ link2.getLocalPath(), fs.getPath(scratchRoot).getRelative("link1").getPathString());
// Create scratch files that'll be symlink targets.
testUtil.scratchFile("foo.txt", "hello");
testUtil.scratchFile("bar.txt", "hello");
// Create symlink with file target, relative path.
Path link3 = fs.getPath(scratchRoot).getRelative("link3");
- fs.createSymbolicLink(link3, PathFragment.create("foo.txt"));
+ fs.createSymbolicLink(link3.getLocalPath(), "foo.txt");
// Create symlink with file target, absolute path.
Path link4 = fs.getPath(scratchRoot).getRelative("link4");
- fs.createSymbolicLink(link4, fs.getPath(scratchRoot).getRelative("bar.txt").asFragment());
+ fs.createSymbolicLink(
+ link4.getLocalPath(), fs.getPath(scratchRoot).getRelative("bar.txt").getPathString());
// Assert that link1 and link2 are true junctions and have the right contents.
for (Path p : ImmutableList.of(link1, link2)) {
assertThat(WindowsFileOperations.isJunction(p.getPathString())).isTrue();