Search in sources :

Example 76 with TestConsole

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);
}
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 77 with TestConsole

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());
}
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 78 with TestConsole

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);
}
Also used : PythonBuckConfig(com.facebook.buck.python.PythonBuckConfig) ExecutableFinder(com.facebook.buck.io.ExecutableFinder) PrebuiltJarDescription(com.facebook.buck.jvm.java.PrebuiltJarDescription) RemoteFileDescription(com.facebook.buck.file.RemoteFileDescription) Description(com.facebook.buck.rules.Description) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) RemoteFileDescription(com.facebook.buck.file.RemoteFileDescription) DefaultProjectBuildFileParserFactory(com.facebook.buck.json.DefaultProjectBuildFileParserFactory) DefaultTypeCoercerFactory(com.facebook.buck.rules.coercer.DefaultTypeCoercerFactory) ExplodingDownloader(com.facebook.buck.file.ExplodingDownloader) ConstructorArgMarshaller(com.facebook.buck.rules.ConstructorArgMarshaller) BuckConfig(com.facebook.buck.cli.BuckConfig) FakeBuckConfig(com.facebook.buck.cli.FakeBuckConfig) PythonBuckConfig(com.facebook.buck.python.PythonBuckConfig) PrebuiltJarDescription(com.facebook.buck.jvm.java.PrebuiltJarDescription) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) TestConsole(com.facebook.buck.testutil.TestConsole) ParserConfig(com.facebook.buck.parser.ParserConfig) BeforeClass(org.junit.BeforeClass)

Example 79 with TestConsole

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();
}
Also used : TestConsole(com.facebook.buck.testutil.TestConsole) Before(org.junit.Before)

Example 80 with TestConsole

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);
}
Also used : BuckEventBus(com.facebook.buck.event.BuckEventBus) DefaultExecutionEnvironment(com.facebook.buck.util.environment.DefaultExecutionEnvironment) ActionGraphEvent(com.facebook.buck.event.ActionGraphEvent) IncrementingFakeClock(com.facebook.buck.timing.IncrementingFakeClock) Clock(com.facebook.buck.timing.Clock) IncrementingFakeClock(com.facebook.buck.timing.IncrementingFakeClock) BuildTarget(com.facebook.buck.model.BuildTarget) BuildEvent(com.facebook.buck.rules.BuildEvent) ParseEvent(com.facebook.buck.parser.ParseEvent) TestConsole(com.facebook.buck.testutil.TestConsole) Test(org.junit.Test)

Aggregations

TestConsole (com.facebook.buck.testutil.TestConsole)100 Test (org.junit.Test)74 ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)27 DefaultProcessExecutor (com.facebook.buck.util.DefaultProcessExecutor)27 ExecutionContext (com.facebook.buck.step.ExecutionContext)25 TestExecutionContext (com.facebook.buck.step.TestExecutionContext)25 Path (java.nio.file.Path)21 BuildRuleResolver (com.facebook.buck.rules.BuildRuleResolver)16 DefaultTargetNodeToBuildRuleTransformer (com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer)16 SourcePathResolver (com.facebook.buck.rules.SourcePathResolver)16 SourcePathRuleFinder (com.facebook.buck.rules.SourcePathRuleFinder)16 FakeProjectFilesystem (com.facebook.buck.testutil.FakeProjectFilesystem)16 BuckEventBus (com.facebook.buck.event.BuckEventBus)15 FakeProcess (com.facebook.buck.util.FakeProcess)14 ProcessExecutor (com.facebook.buck.util.ProcessExecutor)13 ProcessExecutorParams (com.facebook.buck.util.ProcessExecutorParams)12 ProjectWorkspace (com.facebook.buck.testutil.integration.ProjectWorkspace)11 Clock (com.facebook.buck.timing.Clock)10 FakeProcessExecutor (com.facebook.buck.util.FakeProcessExecutor)9 BuildTarget (com.facebook.buck.model.BuildTarget)8