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())));
}
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())));
}
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()));
}
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());
}
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));
}
Aggregations