Search in sources :

Example 1 with FakeListeningProcessExecutor

use of com.facebook.buck.util.FakeListeningProcessExecutor in project buck by facebook.

the class WatchmanTest method watchmanWatchProjectTakingThirtySecondsReturnsEmpty.

@Test
public void watchmanWatchProjectTakingThirtySecondsReturnsEmpty() 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.8.0", "sockname", "/path/to/sock")))).build(), clock);
    Watchman watchman = Watchman.build(executor, fakeWatchmanConnector(Paths.get("/path/to/sock"), TimeUnit.SECONDS.toNanos(30), ImmutableMap.of(VERSION_QUERY, ImmutableMap.of("version", "3.8.0", "capabilities", ImmutableMap.<String, Boolean>builder().put("term-dirname", true).put("cmd-watch-project", false).put("wildmatch", false).put("wildmatch_multislash", false).put("glob_generator", false).put("clock-sync-timeout", false).build()), ImmutableList.of("watch-project", root), ImmutableMap.of("version", "3.8.0", "watch", root))), rootPaths, env, finder, new TestConsole(), clock, Optional.of(TimeUnit.SECONDS.toMillis(5)));
    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 2 with FakeListeningProcessExecutor

use of com.facebook.buck.util.FakeListeningProcessExecutor in project buck by facebook.

the class WatchmanTest method watchmanVersionTakingThirtySecondsReturnsEmpty.

@Test
public void watchmanVersionTakingThirtySecondsReturnsEmpty() 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.ofWaitNanos(TimeUnit.SECONDS.toNanos(30)), FakeListeningProcessState.ofStdoutBytes(bserSerialized(ImmutableMap.of("version", "3.8.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", "3.8.0", "capabilities", ImmutableMap.of("term-dirname", true, "cmd-watch-project", false, "wildmatch", false, "wildmatch_multislash", false, "glob_generator", false)), ImmutableList.of("watch-project", root), ImmutableMap.of("version", "3.8.0", "watch", root))), rootPaths, env, finder, new TestConsole(), clock, Optional.of(TimeUnit.SECONDS.toMillis(5)));
    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 3 with FakeListeningProcessExecutor

use of com.facebook.buck.util.FakeListeningProcessExecutor in project buck by facebook.

the class WatchmanTest method capabilitiesDetectedForVersion47AndLater.

@Test
public void capabilitiesDetectedForVersion47AndLater() 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.of("version", "4.7.0", "clock", "c:0:0:1"))), rootPaths, env, finder, new TestConsole(), clock, Optional.empty());
    assertEquals(ImmutableSet.of(Watchman.Capability.DIRNAME, Watchman.Capability.SUPPORTS_PROJECT_WATCH, Watchman.Capability.WILDMATCH_GLOB, Watchman.Capability.WILDMATCH_MULTISLASH, Watchman.Capability.GLOB_GENERATOR, Watchman.Capability.CLOCK_SYNC_TIMEOUT), watchman.getCapabilities());
    assertEquals(ImmutableMap.of(Paths.get(root), "c:0:0:1"), 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 4 with FakeListeningProcessExecutor

use of com.facebook.buck.util.FakeListeningProcessExecutor in project buck by facebook.

the class WatchmanTest method shouldFailIfWatchProjectNotAvailable.

@Test
public void shouldFailIfWatchProjectNotAvailable() 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.8.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", "3.8.0", "capabilities", ImmutableMap.of("term-dirname", true, "cmd-watch-project", false, "wildmatch", false, "wildmatch_multislash", false, "glob_generator", false), "error", "client required capabilty `cmd-watch-project` is not supported by this " + "server"))), 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 5 with FakeListeningProcessExecutor

use of com.facebook.buck.util.FakeListeningProcessExecutor in project buck by facebook.

the class WatchmanTest method capabilitiesDetectedForVersion38AndLater.

@Test
public void capabilitiesDetectedForVersion38AndLater() 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.8.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", "3.8.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", false).put("clock-sync-timeout", false).build()), ImmutableList.of("watch-project", root), ImmutableMap.of("version", "3.8.0", "watch", root), ImmutableList.of("clock", root, ImmutableMap.of()), ImmutableMap.of("version", "3.8.0", "clock", "c:0:0:1"))), rootPaths, env, finder, new TestConsole(), clock, Optional.empty());
    assertEquals(ImmutableSet.of(Watchman.Capability.DIRNAME, Watchman.Capability.SUPPORTS_PROJECT_WATCH, Watchman.Capability.WILDMATCH_GLOB, Watchman.Capability.WILDMATCH_MULTISLASH), watchman.getCapabilities());
    assertEquals(ImmutableMap.of(Paths.get(root), "c:0:0:1"), 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)

Aggregations

TestConsole (com.facebook.buck.testutil.TestConsole)8 SettableFakeClock (com.facebook.buck.timing.SettableFakeClock)8 FakeListeningProcessExecutor (com.facebook.buck.util.FakeListeningProcessExecutor)8 Test (org.junit.Test)8