Search in sources :

Example 11 with InMemoryFileSystem

use of com.google.devtools.build.lib.vfs.inmemoryfs.InMemoryFileSystem in project bazel by bazelbuild.

the class FingerprintTest method addPath.

@Test
public void addPath() throws Exception {
    PathFragment pf = new PathFragment("/etc/pwd");
    assertThat(new Fingerprint().addPath(pf).hexDigestAndReset()).isEqualTo("63ab5c47c117635407a1af6377e216bc");
    Path p = new InMemoryFileSystem(BlazeClock.instance()).getPath(pf);
    assertThat(new Fingerprint().addPath(p).hexDigestAndReset()).isEqualTo("63ab5c47c117635407a1af6377e216bc");
}
Also used : Path(com.google.devtools.build.lib.vfs.Path) InMemoryFileSystem(com.google.devtools.build.lib.vfs.inmemoryfs.InMemoryFileSystem) PathFragment(com.google.devtools.build.lib.vfs.PathFragment) Test(org.junit.Test)

Example 12 with InMemoryFileSystem

use of com.google.devtools.build.lib.vfs.inmemoryfs.InMemoryFileSystem in project bazel by bazelbuild.

the class RootedPathTest method initializeFileSystem.

@Before
public final void initializeFileSystem() throws Exception {
    filesystem = new InMemoryFileSystem(BlazeClock.instance());
    root = filesystem.getRootDirectory();
}
Also used : InMemoryFileSystem(com.google.devtools.build.lib.vfs.inmemoryfs.InMemoryFileSystem) Before(org.junit.Before)

Example 13 with InMemoryFileSystem

use of com.google.devtools.build.lib.vfs.inmemoryfs.InMemoryFileSystem in project bazel by bazelbuild.

the class SymlinkForestTest method initializeFileSystem.

@Before
public final void initializeFileSystem() throws Exception {
    ManualClock clock = new ManualClock();
    fileSystem = new InMemoryFileSystem(clock);
    linkRoot = fileSystem.getPath("/linkRoot");
    createDirectoryAndParents(linkRoot);
}
Also used : ManualClock(com.google.devtools.build.lib.testutil.ManualClock) InMemoryFileSystem(com.google.devtools.build.lib.vfs.inmemoryfs.InMemoryFileSystem) Before(org.junit.Before)

Example 14 with InMemoryFileSystem

use of com.google.devtools.build.lib.vfs.inmemoryfs.InMemoryFileSystem in project bazel by bazelbuild.

the class BlazeExecutorTest method setUpDirectoriesAndTools.

@Before
public final void setUpDirectoriesAndTools() throws Exception {
    InMemoryFileSystem fs = new InMemoryFileSystem();
    directories = new BlazeDirectories(fs.getPath("/install"), fs.getPath("/base"), fs.getPath("/workspace"), "mock-product-name");
    binTools = BinTools.empty(directories);
}
Also used : BlazeDirectories(com.google.devtools.build.lib.analysis.BlazeDirectories) InMemoryFileSystem(com.google.devtools.build.lib.vfs.inmemoryfs.InMemoryFileSystem) Before(org.junit.Before)

Example 15 with InMemoryFileSystem

use of com.google.devtools.build.lib.vfs.inmemoryfs.InMemoryFileSystem in project bazel by bazelbuild.

the class SingleBuildFileCacheTest method setUp.

@Before
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[] getMD5Digest(Path path) throws IOException {
            byte[] override = md5Overrides.get(path.getPathString());
            return override != null ? override : super.getMD5Digest(path);
        }
    };
    underTest = new SingleBuildFileCache("/", fs);
    Path root = fs.getRootDirectory();
    Path file = root.getChild("empty");
    file.getOutputStream().close();
}
Also used : Path(com.google.devtools.build.lib.vfs.Path) InputStream(java.io.InputStream) InMemoryFileSystem(com.google.devtools.build.lib.vfs.inmemoryfs.InMemoryFileSystem) IOException(java.io.IOException) Before(org.junit.Before)

Aggregations

InMemoryFileSystem (com.google.devtools.build.lib.vfs.inmemoryfs.InMemoryFileSystem)26 Path (com.google.devtools.build.lib.vfs.Path)14 Before (org.junit.Before)14 FileSystem (com.google.devtools.build.lib.vfs.FileSystem)8 Test (org.junit.Test)8 IOException (java.io.IOException)7 TestAction (com.google.devtools.build.lib.actions.util.TestAction)3 ManualClock (com.google.devtools.build.lib.testutil.ManualClock)3 HashFunction (com.google.devtools.build.lib.vfs.FileSystem.HashFunction)3 FileNotFoundException (java.io.FileNotFoundException)3 EqualsTester (com.google.common.testing.EqualsTester)2 Dirent (com.google.devtools.build.lib.vfs.Dirent)2 PathFragment (com.google.devtools.build.lib.vfs.PathFragment)2 File (java.io.File)2 Artifact (com.google.devtools.build.lib.actions.Artifact)1 BuildFailedException (com.google.devtools.build.lib.actions.BuildFailedException)1 BlazeDirectories (com.google.devtools.build.lib.analysis.BlazeDirectories)1 Scratch (com.google.devtools.build.lib.testutil.Scratch)1 TestThread (com.google.devtools.build.lib.testutil.TestThread)1 FileStatus (com.google.devtools.build.lib.vfs.FileStatus)1