Search in sources :

Example 96 with FakeProjectFilesystem

use of com.facebook.buck.testutil.FakeProjectFilesystem in project buck by facebook.

the class PathHashingTest method sameContentsDifferentNameHaveDifferentHashes.

@Test
public void sameContentsDifferentNameHaveDifferentHashes() throws IOException {
    SettableFakeClock clock = new SettableFakeClock(1000, 0);
    FakeProjectFilesystem filesystem1 = new FakeProjectFilesystem(clock);
    filesystem1.touch(Paths.get("foo/bar.txt"));
    FakeProjectFilesystem filesystem2 = new FakeProjectFilesystem(clock);
    filesystem2.touch(Paths.get("foo/baz.txt"));
    Hasher hasher1 = Hashing.sha1().newHasher();
    PathHashing.hashPath(hasher1, fileHashCache, filesystem1, Paths.get("foo"));
    Hasher hasher2 = Hashing.sha1().newHasher();
    PathHashing.hashPath(hasher2, fileHashCache, filesystem2, Paths.get("foo"));
    assertThat(hasher1.hash(), not(equalTo(hasher2.hash())));
}
Also used : Hasher(com.google.common.hash.Hasher) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) SettableFakeClock(com.facebook.buck.timing.SettableFakeClock) Test(org.junit.Test)

Example 97 with FakeProjectFilesystem

use of com.facebook.buck.testutil.FakeProjectFilesystem in project buck by facebook.

the class PathHashingTest method sameNameDifferentContentsHaveDifferentHashes.

@Test
public void sameNameDifferentContentsHaveDifferentHashes() throws IOException {
    SettableFakeClock clock = new SettableFakeClock(1000, 0);
    FakeProjectFilesystem filesystem1 = new FakeProjectFilesystem(clock);
    filesystem1.touch(Paths.get("foo/bar.txt"));
    FakeProjectFilesystem filesystem2 = new FakeProjectFilesystem(clock);
    filesystem2.touch(Paths.get("foo/bar.txt"));
    Hasher hasher1 = Hashing.sha1().newHasher();
    PathHashing.hashPath(hasher1, fileHashCache, filesystem1, Paths.get("foo"));
    Hasher hasher2 = Hashing.sha1().newHasher();
    PathHashing.hashPath(hasher2, modifiedFileHashCache, filesystem2, Paths.get("foo"));
    assertThat(hasher1.hash(), not(equalTo(hasher2.hash())));
}
Also used : Hasher(com.google.common.hash.Hasher) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) SettableFakeClock(com.facebook.buck.timing.SettableFakeClock) Test(org.junit.Test)

Example 98 with FakeProjectFilesystem

use of com.facebook.buck.testutil.FakeProjectFilesystem in project buck by facebook.

the class PathHashingTest method hashDoesNotDependOnFilesystemIterationOrder.

@Test
public void hashDoesNotDependOnFilesystemIterationOrder() throws IOException {
    SettableFakeClock clock = new SettableFakeClock(1000, 0);
    FakeProjectFilesystem filesystem1 = new FakeProjectFilesystem(clock);
    filesystem1.touch(Paths.get("foo/foo.txt"));
    filesystem1.touch(Paths.get("foo/bar.txt"));
    filesystem1.touch(Paths.get("foo/baz.txt"));
    FakeProjectFilesystem filesystem2 = new FakeProjectFilesystem(clock);
    filesystem2.touch(Paths.get("foo/bar.txt"));
    filesystem2.touch(Paths.get("foo/baz.txt"));
    filesystem2.touch(Paths.get("foo/foo.txt"));
    Hasher hasher1 = Hashing.sha1().newHasher();
    PathHashing.hashPath(hasher1, fileHashCache, filesystem1, Paths.get("foo"));
    Hasher hasher2 = Hashing.sha1().newHasher();
    PathHashing.hashPath(hasher2, fileHashCache, filesystem2, Paths.get("foo"));
    assertThat(hasher1.hash(), equalTo(hasher2.hash()));
}
Also used : Hasher(com.google.common.hash.Hasher) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) SettableFakeClock(com.facebook.buck.timing.SettableFakeClock) Test(org.junit.Test)

Example 99 with FakeProjectFilesystem

use of com.facebook.buck.testutil.FakeProjectFilesystem in project buck by facebook.

the class RemoteFileDescriptionTest method setUp.

@Before
public void setUp() {
    downloader = new ExplodingDownloader();
    description = new RemoteFileDescription(downloader);
    filesystem = new FakeProjectFilesystem();
    ruleResolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
}
Also used : FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) Before(org.junit.Before)

Example 100 with FakeProjectFilesystem

use of com.facebook.buck.testutil.FakeProjectFilesystem in project buck by facebook.

the class HaskellPrebuiltLibraryDescriptionTest method staticLibraries.

@Test
public void staticLibraries() throws Exception {
    PathSourcePath lib = new FakeSourcePath("libfoo.a");
    BuildTarget target = BuildTargetFactory.newInstance("//:rule");
    PrebuiltHaskellLibraryBuilder builder = new PrebuiltHaskellLibraryBuilder(target).setVersion("1.0.0").setDb(new FakeSourcePath("package.conf.d")).setStaticLibs(ImmutableList.of(lib));
    TargetGraph targetGraph = TargetGraphFactory.newInstance(builder.build());
    ProjectFilesystem filesystem = new FakeProjectFilesystem();
    BuildRuleResolver resolver = new BuildRuleResolver(targetGraph, new DefaultTargetNodeToBuildRuleTransformer());
    PrebuiltHaskellLibrary library = builder.build(resolver, filesystem, targetGraph);
    NativeLinkableInput input = library.getNativeLinkableInput(CxxPlatformUtils.DEFAULT_PLATFORM, Linker.LinkableDepType.STATIC);
    assertThat(RichStream.from(input.getArgs()).flatMap(a -> a.getInputs().stream()).toImmutableSet(), Matchers.contains(lib));
}
Also used : FakeSourcePath(com.facebook.buck.rules.FakeSourcePath) NativeLinkableInput(com.facebook.buck.cxx.NativeLinkableInput) BuildTarget(com.facebook.buck.model.BuildTarget) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) PathSourcePath(com.facebook.buck.rules.PathSourcePath) TargetGraph(com.facebook.buck.rules.TargetGraph) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) Test(org.junit.Test)

Aggregations

FakeProjectFilesystem (com.facebook.buck.testutil.FakeProjectFilesystem)438 Test (org.junit.Test)384 ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)268 BuildRuleResolver (com.facebook.buck.rules.BuildRuleResolver)189 DefaultTargetNodeToBuildRuleTransformer (com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer)186 Path (java.nio.file.Path)169 BuildTarget (com.facebook.buck.model.BuildTarget)138 SourcePathRuleFinder (com.facebook.buck.rules.SourcePathRuleFinder)111 TargetGraph (com.facebook.buck.rules.TargetGraph)107 SourcePathResolver (com.facebook.buck.rules.SourcePathResolver)103 FakeSourcePath (com.facebook.buck.rules.FakeSourcePath)85 PathSourcePath (com.facebook.buck.rules.PathSourcePath)68 BuildRule (com.facebook.buck.rules.BuildRule)61 SourcePath (com.facebook.buck.rules.SourcePath)56 RuleKey (com.facebook.buck.rules.RuleKey)42 AllExistingProjectFilesystem (com.facebook.buck.testutil.AllExistingProjectFilesystem)40 TestExecutionContext (com.facebook.buck.step.TestExecutionContext)39 ExecutionContext (com.facebook.buck.step.ExecutionContext)38 Before (org.junit.Before)30 FakeFileHashCache (com.facebook.buck.testutil.FakeFileHashCache)29