Search in sources :

Example 16 with SettableFakeClock

use of com.facebook.buck.timing.SettableFakeClock in project buck by facebook.

the class SchemeGeneratorTest method setUp.

@Before
public void setUp() throws IOException {
    clock = new SettableFakeClock(0, 0);
    projectFilesystem = new FakeProjectFilesystem(clock);
}
Also used : FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) SettableFakeClock(com.facebook.buck.timing.SettableFakeClock) Before(org.junit.Before)

Example 17 with SettableFakeClock

use of com.facebook.buck.timing.SettableFakeClock in project buck by facebook.

the class WatchmanTest method shouldReturnEmptyWatchmanIfVersionCheckFails.

@Test
public void shouldReturnEmptyWatchmanIfVersionCheckFails() throws InterruptedException, IOException {
    SettableFakeClock clock = new SettableFakeClock(0, 0);
    FakeListeningProcessExecutor executor = new FakeListeningProcessExecutor(ImmutableMultimap.<ProcessExecutorParams, FakeListeningProcessState>builder().putAll(ProcessExecutorParams.ofCommand(exe, "--output-encoding=bser", "get-sockname"), FakeListeningProcessState.ofExit(1)).build(), clock);
    Watchman watchman = Watchman.build(executor, NULL_WATCHMAN_CONNECTOR, rootPaths, env, finder, new TestConsole(), clock, Optional.empty());
    assertEquals(Watchman.NULL_WATCHMAN, watchman);
}
Also used : FakeListeningProcessExecutor(com.facebook.buck.util.FakeListeningProcessExecutor) SettableFakeClock(com.facebook.buck.timing.SettableFakeClock) TestConsole(com.facebook.buck.testutil.TestConsole) Test(org.junit.Test)

Example 18 with SettableFakeClock

use of com.facebook.buck.timing.SettableFakeClock in project buck by facebook.

the class WatchmanTest method shouldReturnNullWatchmanIfExtendedVersionCheckMissing.

@Test
public void shouldReturnNullWatchmanIfExtendedVersionCheckMissing() throws InterruptedException, IOException {
    SettableFakeClock clock = new SettableFakeClock(0, 0);
    FakeListeningProcessExecutor executor = new FakeListeningProcessExecutor(ImmutableMultimap.<ProcessExecutorParams, FakeListeningProcessState>builder().putAll(ProcessExecutorParams.ofCommand(exe, "--output-encoding=bser", "get-sockname"), FakeListeningProcessState.ofStdoutBytes(bserSerialized(ImmutableMap.of("version", "3.7.9", "sockname", "/path/to/sock"))), FakeListeningProcessState.ofExit(0)).build(), clock);
    Watchman watchman = Watchman.build(executor, fakeWatchmanConnector(Paths.get("/path/to/sock"), 0, ImmutableMap.of(VERSION_QUERY, ImmutableMap.of("version", "3.7.9"), ImmutableList.of("watch", root), ImmutableMap.of("version", "3.7.9", "watch", root))), rootPaths, env, finder, new TestConsole(), clock, Optional.empty());
    assertEquals(Watchman.NULL_WATCHMAN, watchman);
}
Also used : FakeListeningProcessExecutor(com.facebook.buck.util.FakeListeningProcessExecutor) SettableFakeClock(com.facebook.buck.timing.SettableFakeClock) TestConsole(com.facebook.buck.testutil.TestConsole) Test(org.junit.Test)

Example 19 with SettableFakeClock

use of com.facebook.buck.timing.SettableFakeClock in project buck by facebook.

the class WatchmanTest method emptyClockQueryShouldReturnNullClock.

@Test
public void emptyClockQueryShouldReturnNullClock() throws InterruptedException, IOException {
    SettableFakeClock clock = new SettableFakeClock(0, 0);
    FakeListeningProcessExecutor executor = new FakeListeningProcessExecutor(ImmutableMultimap.<ProcessExecutorParams, FakeListeningProcessState>builder().putAll(ProcessExecutorParams.ofCommand(exe, "--output-encoding=bser", "get-sockname"), FakeListeningProcessState.ofStdoutBytes(bserSerialized(ImmutableMap.of("version", "4.7.0", "sockname", "/path/to/sock"))), FakeListeningProcessState.ofExit(0)).build(), clock);
    Watchman watchman = Watchman.build(executor, fakeWatchmanConnector(Paths.get("/path/to/sock"), 0, ImmutableMap.of(VERSION_QUERY, ImmutableMap.of("version", "4.7.0", "capabilities", ImmutableMap.<String, Boolean>builder().put("term-dirname", true).put("cmd-watch-project", true).put("wildmatch", true).put("wildmatch_multislash", true).put("glob_generator", true).put("clock-sync-timeout", true).build()), ImmutableList.of("watch-project", root), ImmutableMap.of("version", "4.7.0", "watch", root), ImmutableList.of("clock", root, ImmutableMap.of("sync_timeout", 100)), ImmutableMap.<String, Object>of())), rootPaths, env, finder, new TestConsole(), clock, Optional.empty());
    assertEquals(ImmutableMap.of(), watchman.getClockIds());
}
Also used : FakeListeningProcessExecutor(com.facebook.buck.util.FakeListeningProcessExecutor) SettableFakeClock(com.facebook.buck.timing.SettableFakeClock) TestConsole(com.facebook.buck.testutil.TestConsole) Test(org.junit.Test)

Example 20 with SettableFakeClock

use of com.facebook.buck.timing.SettableFakeClock in project buck by facebook.

the class WorkspaceGeneratorTest method setUp.

@Before
public void setUp() {
    assumeTrue(Platform.detect() == Platform.MACOS || Platform.detect() == Platform.LINUX);
    clock = new SettableFakeClock(0, 0);
    projectFilesystem = new FakeProjectFilesystem(clock);
    generator = new WorkspaceGenerator(projectFilesystem, "ws", Paths.get("."));
}
Also used : FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) SettableFakeClock(com.facebook.buck.timing.SettableFakeClock) Before(org.junit.Before)

Aggregations

SettableFakeClock (com.facebook.buck.timing.SettableFakeClock)24 Test (org.junit.Test)21 FakeProjectFilesystem (com.facebook.buck.testutil.FakeProjectFilesystem)9 TestConsole (com.facebook.buck.testutil.TestConsole)8 FakeListeningProcessExecutor (com.facebook.buck.util.FakeListeningProcessExecutor)8 Hasher (com.google.common.hash.Hasher)4 Before (org.junit.Before)3 Path (java.nio.file.Path)2 NSString (com.dd.plist.NSString)1 AppleConfig (com.facebook.buck.apple.AppleConfig)1 BuckConfig (com.facebook.buck.cli.BuckConfig)1 FakeBuckConfig (com.facebook.buck.cli.FakeBuckConfig)1 CxxBuckConfig (com.facebook.buck.cxx.CxxBuckConfig)1 HalideBuckConfig (com.facebook.buck.halide.HalideBuckConfig)1 ReactNativeBuckConfig (com.facebook.buck.js.ReactNativeBuckConfig)1 TestCellBuilder (com.facebook.buck.rules.TestCellBuilder)1 SwiftBuckConfig (com.facebook.buck.swift.SwiftBuckConfig)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1