use of com.google.devtools.build.lib.vfs.Path in project bazel by bazelbuild.
the class ArtifactTest method testRootPrefixedExecPath_noRoot.
@Test
public void testRootPrefixedExecPath_noRoot() throws IOException {
Path f1 = scratch.file("/exec/dir/file.ext");
Artifact a1 = new Artifact(f1.relativeTo(execDir), Root.asDerivedRoot(execDir));
assertEquals(":dir/file.ext", Artifact.asRootPrefixedExecPath(a1));
}
use of com.google.devtools.build.lib.vfs.Path in project bazel by bazelbuild.
the class ArtifactTest method testRootPrefixedExecPath_nullRootDir.
@Test
public void testRootPrefixedExecPath_nullRootDir() throws IOException {
Path f1 = scratch.file("/exec/dir/file.ext");
try {
new Artifact(f1, null, f1.relativeTo(execDir));
fail("Expected IllegalArgumentException creating artifact with null root");
} catch (IllegalArgumentException expected) {
}
}
use of com.google.devtools.build.lib.vfs.Path in project bazel by bazelbuild.
the class Scratch method overwriteFile.
/**
* Like {@code scratch.file}, but the file is first deleted if it already
* exists.
*/
public Path overwriteFile(String pathName, Charset charset, String... lines) throws IOException {
Path oldFile = resolve(pathName);
long newMTime = oldFile.exists() ? oldFile.getLastModifiedTime() + 1 : -1;
oldFile.delete();
Path newFile = file(pathName, charset, lines);
newFile.setLastModifiedTime(newMTime);
return newFile;
}
use of com.google.devtools.build.lib.vfs.Path in project bazel by bazelbuild.
the class Scratch method newFile.
/** Creates a new scratch file, ensuring parents exist. */
private Path newFile(String pathName) throws IOException {
Path file = resolve(pathName);
Path parentDir = file.getParentDirectory();
if (!parentDir.exists()) {
FileSystemUtils.createDirectoryAndParents(parentDir);
}
if (file.exists()) {
throw new IOException("Could not create scratch file (file exists) " + pathName);
}
return file;
}
use of com.google.devtools.build.lib.vfs.Path in project bazel by bazelbuild.
the class TestFileOutErr method newInMemoryFile.
private static Path newInMemoryFile(File root, String name) {
InMemoryFileSystem inMemFS = new InMemoryFileSystem();
Path directory = inMemFS.getPath(root.getPath());
try {
FileSystemUtils.createDirectoryAndParents(directory);
} catch (IOException e) {
throw new IllegalStateException(e);
}
return directory.getRelative(name);
}
Aggregations