use of com.facebook.buck.testutil.TestConsole 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);
}
use of com.facebook.buck.testutil.TestConsole 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());
}
use of com.facebook.buck.testutil.TestConsole in project buck by facebook.
the class ResolverIntegrationTest method createParser.
@BeforeClass
public static void createParser() {
ProjectFilesystem filesystem = new FakeProjectFilesystem();
BuckConfig buckConfig = FakeBuckConfig.builder().build();
ParserConfig parserConfig = buckConfig.getView(ParserConfig.class);
PythonBuckConfig pythonBuckConfig = new PythonBuckConfig(buckConfig, new ExecutableFinder());
ImmutableSet<Description<?>> descriptions = ImmutableSet.of(new RemoteFileDescription(new ExplodingDownloader()), new PrebuiltJarDescription());
DefaultProjectBuildFileParserFactory parserFactory = new DefaultProjectBuildFileParserFactory(ProjectBuildFileParserOptions.builder().setProjectRoot(filesystem.getRootPath()).setPythonInterpreter(pythonBuckConfig.getPythonInterpreter()).setAllowEmptyGlobs(parserConfig.getAllowEmptyGlobs()).setIgnorePaths(filesystem.getIgnorePaths()).setBuildFileName(parserConfig.getBuildFileName()).setDefaultIncludes(parserConfig.getDefaultIncludes()).setDescriptions(descriptions).setBuildFileImportWhitelist(parserConfig.getBuildFileImportWhitelist()).build());
buildFileParser = parserFactory.createParser(new ConstructorArgMarshaller(new DefaultTypeCoercerFactory(ObjectMappers.newDefaultInstance())), new TestConsole(), ImmutableMap.of(), BuckEventBusFactory.newInstance(), /* ignoreBuckAutodepsFiles */
false);
}
use of com.facebook.buck.testutil.TestConsole in project buck by facebook.
the class AuditClasspathCommandTest method setUp.
@Before
public void setUp() throws IOException, InterruptedException {
console = new TestConsole();
auditClasspathCommand = new AuditClasspathCommand();
params = CommandRunnerParamsForTesting.builder().setConsole(console).build();
}
use of com.facebook.buck.testutil.TestConsole in project buck by facebook.
the class SimpleConsoleEventBusListenerTest method testBuildTimeDoesNotDisplayNegativeOffset.
@Test
public void testBuildTimeDoesNotDisplayNegativeOffset() {
Clock fakeClock = new IncrementingFakeClock(TimeUnit.SECONDS.toNanos(1));
BuckEventBus eventBus = BuckEventBusFactory.newInstance(fakeClock);
TestConsole console = new TestConsole();
BuildTarget fakeTarget = BuildTargetFactory.newInstance("//banana:stand");
ImmutableSet<BuildTarget> buildTargets = ImmutableSet.of(fakeTarget);
Iterable<String> buildArgs = Iterables.transform(buildTargets, Object::toString);
SimpleConsoleEventBusListener listener = new SimpleConsoleEventBusListener(console, fakeClock, TestResultSummaryVerbosity.of(false, false), Locale.US, logPath, new DefaultExecutionEnvironment(ImmutableMap.copyOf(System.getenv()), System.getProperties()));
eventBus.register(listener);
// Do a full parse and action graph cycle before the build event starts
// This sequencing occurs when running `buck project`
ParseEvent.Started parseStarted = ParseEvent.started(buildTargets);
eventBus.postWithoutConfiguring(configureTestEventAtTime(parseStarted, 100L, TimeUnit.MILLISECONDS, /* threadId */
0L));
eventBus.postWithoutConfiguring(configureTestEventAtTime(ParseEvent.finished(parseStarted, Optional.empty()), 300L, TimeUnit.MILLISECONDS, /* threadId */
0L));
String expectedOutput = "[-] PARSING BUCK FILES...FINISHED 0.2s\n";
assertOutput(expectedOutput, console);
ActionGraphEvent.Started actionGraphStarted = ActionGraphEvent.started();
eventBus.postWithoutConfiguring(configureTestEventAtTime(actionGraphStarted, 300L, TimeUnit.MILLISECONDS, /* threadId */
0L));
eventBus.postWithoutConfiguring(configureTestEventAtTime(ActionGraphEvent.finished(actionGraphStarted), 500L, TimeUnit.MILLISECONDS, /* threadId */
0L));
BuildEvent.Started buildEventStarted = BuildEvent.started(buildArgs);
eventBus.postWithoutConfiguring(configureTestEventAtTime(buildEventStarted, 500L, TimeUnit.MILLISECONDS, /* threadId */
0L));
eventBus.postWithoutConfiguring(configureTestEventAtTime(BuildEvent.finished(buildEventStarted, 0), 600L, TimeUnit.MILLISECONDS, /* threadId */
0L));
expectedOutput += "[-] BUILDING...FINISHED 0.1s\n";
assertOutput(expectedOutput, console);
}
Aggregations