Search in sources :

Example 1 with UnixFileSystem

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);
}
Also used : JavaIoFileSystem(com.google.devtools.build.lib.vfs.JavaIoFileSystem) File(java.io.File) UnixFileSystem(com.google.devtools.build.lib.unix.UnixFileSystem) Before(org.junit.Before)

Example 2 with UnixFileSystem

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));
    }
}
Also used : UnixFileSystem(com.google.devtools.build.lib.unix.UnixFileSystem) InMemoryFileSystem(com.google.devtools.build.lib.vfs.inmemoryfs.InMemoryFileSystem) UnixFileSystem(com.google.devtools.build.lib.unix.UnixFileSystem) Test(org.junit.Test)

Aggregations

UnixFileSystem (com.google.devtools.build.lib.unix.UnixFileSystem)2 JavaIoFileSystem (com.google.devtools.build.lib.vfs.JavaIoFileSystem)1 InMemoryFileSystem (com.google.devtools.build.lib.vfs.inmemoryfs.InMemoryFileSystem)1 File (java.io.File)1 Before (org.junit.Before)1 Test (org.junit.Test)1