Search in sources :

Example 16 with InMemoryFileSystem

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

the class IncrementalLoadingTest method createTester.

@Before
public final void createTester() throws Exception {
    ManualClock clock = new ManualClock();
    FileSystem fs = new InMemoryFileSystem(clock) {

        @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);
        }

        @Nullable
        @Override
        public FileStatus stat(Path path, boolean followSymlinks) throws IOException {
            if (path.equals(throwOnStat)) {
                throw new IOException("bork " + path.getPathString());
            }
            return super.stat(path, followSymlinks);
        }
    };
    tester = createTester(fs, clock);
}
Also used : Path(com.google.devtools.build.lib.vfs.Path) ManualClock(com.google.devtools.build.lib.testutil.ManualClock) FileSystem(com.google.devtools.build.lib.vfs.FileSystem) InMemoryFileSystem(com.google.devtools.build.lib.vfs.inmemoryfs.InMemoryFileSystem) InMemoryFileSystem(com.google.devtools.build.lib.vfs.inmemoryfs.InMemoryFileSystem) Dirent(com.google.devtools.build.lib.vfs.Dirent) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) Before(org.junit.Before)

Example 17 with InMemoryFileSystem

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

the class PackageFactoryTestBase method initializeFileSystem.

@Before
public final void initializeFileSystem() throws Exception {
    FileSystem 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);
        }
    };
    Path tmpPath = fs.getPath("/tmp");
    scratch = new Scratch(tmpPath);
}
Also used : Path(com.google.devtools.build.lib.vfs.Path) Scratch(com.google.devtools.build.lib.testutil.Scratch) InMemoryFileSystem(com.google.devtools.build.lib.vfs.inmemoryfs.InMemoryFileSystem) FileSystem(com.google.devtools.build.lib.vfs.FileSystem) InMemoryFileSystem(com.google.devtools.build.lib.vfs.inmemoryfs.InMemoryFileSystem) Dirent(com.google.devtools.build.lib.vfs.Dirent) FileNotFoundException(java.io.FileNotFoundException) Before(org.junit.Before)

Example 18 with InMemoryFileSystem

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

the class FileSymlinkCycleUniquenessFunctionTest method testHashCodeAndEqualsContract.

@Test
public void testHashCodeAndEqualsContract() throws Exception {
    Path root = new InMemoryFileSystem().getRootDirectory().getRelative("root");
    RootedPath p1 = RootedPath.toRootedPath(root, new PathFragment("p1"));
    RootedPath p2 = RootedPath.toRootedPath(root, new PathFragment("p2"));
    RootedPath p3 = RootedPath.toRootedPath(root, new PathFragment("p3"));
    ImmutableList<RootedPath> cycleA1 = ImmutableList.of(p1);
    ImmutableList<RootedPath> cycleB1 = ImmutableList.of(p2);
    ImmutableList<RootedPath> cycleC1 = ImmutableList.of(p1, p2, p3);
    ImmutableList<RootedPath> cycleC2 = ImmutableList.of(p2, p3, p1);
    ImmutableList<RootedPath> cycleC3 = ImmutableList.of(p3, p1, p2);
    new EqualsTester().addEqualityGroup(FileSymlinkCycleUniquenessFunction.key(cycleA1)).addEqualityGroup(FileSymlinkCycleUniquenessFunction.key(cycleB1)).addEqualityGroup(FileSymlinkCycleUniquenessFunction.key(cycleC1), FileSymlinkCycleUniquenessFunction.key(cycleC2), FileSymlinkCycleUniquenessFunction.key(cycleC3)).testEquals();
}
Also used : RootedPath(com.google.devtools.build.lib.vfs.RootedPath) Path(com.google.devtools.build.lib.vfs.Path) EqualsTester(com.google.common.testing.EqualsTester) InMemoryFileSystem(com.google.devtools.build.lib.vfs.inmemoryfs.InMemoryFileSystem) PathFragment(com.google.devtools.build.lib.vfs.PathFragment) RootedPath(com.google.devtools.build.lib.vfs.RootedPath) Test(org.junit.Test)

Example 19 with InMemoryFileSystem

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

the class MapBasedActionGraphTest method testSmoke.

@Test
public void testSmoke() throws Exception {
    MutableActionGraph actionGraph = new MapBasedActionGraph();
    FileSystem fileSystem = new InMemoryFileSystem(BlazeClock.instance());
    Path path = fileSystem.getPath("/root/foo");
    Artifact output = new Artifact(path, Root.asDerivedRoot(path));
    Action action = new TestAction(TestAction.NO_EFFECT, ImmutableSet.<Artifact>of(), ImmutableSet.of(output));
    actionGraph.registerAction(action);
    actionGraph.unregisterAction(action);
    path = fileSystem.getPath("/root/bar");
    output = new Artifact(path, Root.asDerivedRoot(path));
    Action action2 = new TestAction(TestAction.NO_EFFECT, ImmutableSet.<Artifact>of(), ImmutableSet.of(output));
    actionGraph.registerAction(action);
    actionGraph.registerAction(action2);
    actionGraph.unregisterAction(action);
}
Also used : Path(com.google.devtools.build.lib.vfs.Path) TestAction(com.google.devtools.build.lib.actions.util.TestAction) InMemoryFileSystem(com.google.devtools.build.lib.vfs.inmemoryfs.InMemoryFileSystem) FileSystem(com.google.devtools.build.lib.vfs.FileSystem) InMemoryFileSystem(com.google.devtools.build.lib.vfs.inmemoryfs.InMemoryFileSystem) TestAction(com.google.devtools.build.lib.actions.util.TestAction) Test(org.junit.Test)

Example 20 with InMemoryFileSystem

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

the class MapBasedActionGraphTest method testNoActionConflictWhenUnregisteringSharedAction.

@Test
public void testNoActionConflictWhenUnregisteringSharedAction() throws Exception {
    MutableActionGraph actionGraph = new MapBasedActionGraph();
    FileSystem fileSystem = new InMemoryFileSystem(BlazeClock.instance());
    Path path = fileSystem.getPath("/root/foo");
    Artifact output = new Artifact(path, Root.asDerivedRoot(path));
    Action action = new TestAction(TestAction.NO_EFFECT, ImmutableSet.<Artifact>of(), ImmutableSet.of(output));
    actionGraph.registerAction(action);
    Action otherAction = new TestAction(TestAction.NO_EFFECT, ImmutableSet.<Artifact>of(), ImmutableSet.of(output));
    actionGraph.registerAction(otherAction);
    actionGraph.unregisterAction(action);
}
Also used : Path(com.google.devtools.build.lib.vfs.Path) TestAction(com.google.devtools.build.lib.actions.util.TestAction) InMemoryFileSystem(com.google.devtools.build.lib.vfs.inmemoryfs.InMemoryFileSystem) FileSystem(com.google.devtools.build.lib.vfs.FileSystem) InMemoryFileSystem(com.google.devtools.build.lib.vfs.inmemoryfs.InMemoryFileSystem) TestAction(com.google.devtools.build.lib.actions.util.TestAction) Test(org.junit.Test)

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