use of com.facebook.buck.timing.SettableFakeClock in project buck by facebook.
the class ProjectGeneratorTest method setUp.
@Before
public void setUp() throws InterruptedException, IOException {
assumeTrue(Platform.detect() == Platform.MACOS || Platform.detect() == Platform.LINUX);
clock = new SettableFakeClock(0, 0);
fakeProjectFilesystem = new FakeProjectFilesystem(clock);
projectCell = (new TestCellBuilder()).setFilesystem(fakeProjectFilesystem).build();
projectFilesystem = projectCell.getFilesystem();
rootPath = projectFilesystem.getRootPath();
// Add files and directories used to test resources.
projectFilesystem.createParentDirs(Paths.get("foodir", "foo.png"));
projectFilesystem.writeContentsToPath("", Paths.get("foodir", "foo.png"));
projectFilesystem.writeContentsToPath("", Paths.get("bar.png"));
fakeProjectFilesystem.touch(Paths.get("Base.lproj", "Bar.storyboard"));
halideBuckConfig = HalideLibraryBuilder.createDefaultHalideConfig(fakeProjectFilesystem);
ImmutableMap<String, ImmutableMap<String, String>> sections = ImmutableMap.of("cxx", ImmutableMap.of("cflags", "-Wno-deprecated -Wno-conversion", "cxxflags", "-Wundeclared-selector -Wno-objc-designated-initializers"), "apple", ImmutableMap.of("force_dsym_mode_in_build_with_buck", "false"), "swift", ImmutableMap.of("version", "1.23"));
BuckConfig config = FakeBuckConfig.builder().setSections(sections).build();
cxxBuckConfig = new CxxBuckConfig(config);
appleConfig = new AppleConfig(config);
swiftBuckConfig = new SwiftBuckConfig(config);
}
use of com.facebook.buck.timing.SettableFakeClock in project buck by facebook.
the class PathHashingTest method sameContentsSameNameHaveSameHash.
@Test
public void sameContentsSameNameHaveSameHash() 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, fileHashCache, filesystem2, Paths.get("foo"));
assertThat(hasher1.hash(), equalTo(hasher2.hash()));
}
use of com.facebook.buck.timing.SettableFakeClock 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.timing.SettableFakeClock 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.timing.SettableFakeClock 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()));
}
Aggregations