use of com.google.devtools.build.lib.unix.UnixFileSystem in project bazel by bazelbuild.
the class CompressedTarFunctionTest method setUpFs.
@Before
public void setUpFs() throws Exception {
testFS = OS.getCurrent() == OS.WINDOWS ? new JavaIoFileSystem() : new UnixFileSystem();
tarballPath = testFS.getPath(BlazeTestUtils.runfilesDir()).getRelative(TestConstants.JAVATESTS_ROOT + PATH_TO_TEST_ARCHIVE + ARCHIVE_NAME);
workingDir = testFS.getPath(new File(TestUtils.tmpDir()).getCanonicalPath());
outDir = workingDir.getRelative("out");
descriptorBuilder = DecompressorDescriptor.builder().setDecompressor(TarGzFunction.INSTANCE).setRepositoryPath(outDir).setArchivePath(tarballPath);
}
use of com.google.devtools.build.lib.unix.UnixFileSystem in project bazel by bazelbuild.
the class UnionFileSystemTest method testDelegateOperationsReflectOnLocalFilesystem.
// 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
// that paths aren't being remapped in some nasty way on the underlying FS.
@Test
public void testDelegateOperationsReflectOnLocalFilesystem() throws Exception {
unionfs = new UnionFileSystem(ImmutableMap.<PathFragment, FileSystem>of(workingDir.getParentDirectory().asFragment(), new UnixFileSystem()), defaultDelegate, false);
// 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);
Path testFile = unionfs.getPath(workingDir.getRelative("test_file").asFragment());
assertTrue(testFile.asFragment().startsWith(workingDir.asFragment()));
String testString = "This is a test file";
FileSystemUtils.writeContentAsLatin1(testFile, testString);
try {
assertEquals(testString, new String(FileSystemUtils.readContentAsLatin1(testFile)));
} finally {
testFile.delete();
assertTrue(unionfs.delete(workingDir));
}
}
Aggregations