Search in sources :

Example 46 with TestConsole

use of com.facebook.buck.testutil.TestConsole in project buck by facebook.

the class PythonBuckConfigTest method testDefaultPythonLibrary.

@Test
public void testDefaultPythonLibrary() throws InterruptedException {
    BuildTarget library = BuildTargetFactory.newInstance("//:library");
    PythonBuckConfig config = new PythonBuckConfig(FakeBuckConfig.builder().setSections(ImmutableMap.of("python", ImmutableMap.of("library", library.toString()))).build(), new AlwaysFoundExecutableFinder());
    assertThat(config.getDefaultPythonPlatform(new FakeProcessExecutor(Functions.constant(new FakeProcess(0, "CPython 2 7", "")), new TestConsole())).getCxxLibrary(), Matchers.equalTo(Optional.of(library)));
}
Also used : FakeProcessExecutor(com.facebook.buck.util.FakeProcessExecutor) BuildTarget(com.facebook.buck.model.BuildTarget) FakeProcess(com.facebook.buck.util.FakeProcess) TestConsole(com.facebook.buck.testutil.TestConsole) AlwaysFoundExecutableFinder(com.facebook.buck.io.AlwaysFoundExecutableFinder) Test(org.junit.Test)

Example 47 with TestConsole

use of com.facebook.buck.testutil.TestConsole in project buck by facebook.

the class InteractiveReportIntegrationTest method createDefectReport.

private static DefectSubmitResult createDefectReport(ProjectWorkspace workspace, ByteArrayInputStream inputStream) throws IOException, InterruptedException {
    ProjectFilesystem filesystem = workspace.asCell().getFilesystem();
    ObjectMapper objectMapper = ObjectMappers.newDefaultInstance();
    RageConfig rageConfig = RageConfig.of(workspace.asCell().getBuckConfig());
    Clock clock = new DefaultClock();
    ExtraInfoCollector extraInfoCollector = Optional::empty;
    TestConsole console = new TestConsole();
    DefectReporter defectReporter = new DefaultDefectReporter(filesystem, objectMapper, rageConfig, BuckEventBusFactory.newInstance(clock), clock);
    WatchmanDiagReportCollector watchmanDiagReportCollector = new WatchmanDiagReportCollector(filesystem, WATCHMAN_DIAG_COMMAND, createFakeWatchmanDiagProcessExecutor(console));
    InteractiveReport interactiveReport = new InteractiveReport(defectReporter, filesystem, objectMapper, console, inputStream, TestBuildEnvironmentDescription.INSTANCE, VcsInfoCollector.create(new NoOpCmdLineInterface()), rageConfig, extraInfoCollector, Optional.of(watchmanDiagReportCollector));
    return interactiveReport.collectAndSubmitResult().get();
}
Also used : DefaultClock(com.facebook.buck.timing.DefaultClock) NoOpCmdLineInterface(com.facebook.buck.util.versioncontrol.NoOpCmdLineInterface) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) DefaultClock(com.facebook.buck.timing.DefaultClock) Clock(com.facebook.buck.timing.Clock) TestConsole(com.facebook.buck.testutil.TestConsole) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 48 with TestConsole

use of com.facebook.buck.testutil.TestConsole in project buck by facebook.

the class RageCommandIntegrationTest method testExtraInfo.

@Test
public void testExtraInfo() throws Exception {
    ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "interactive_report", temporaryFolder);
    workspace.setUp();
    RageConfig rageConfig = createRageConfig(0, "python, extra.py", RageProtocolVersion.SIMPLE);
    ProjectFilesystem filesystem = new ProjectFilesystem(temporaryFolder.getRoot());
    Console console = new TestConsole();
    CapturingDefectReporter defectReporter = new CapturingDefectReporter();
    AutomatedReport automatedReport = new AutomatedReport(defectReporter, filesystem, ObjectMappers.newDefaultInstance(), new TestConsole(), TestBuildEnvironmentDescription.INSTANCE, VcsInfoCollector.create(new NoOpCmdLineInterface()), rageConfig, new DefaultExtraInfoCollector(rageConfig, filesystem, new DefaultProcessExecutor(console)));
    automatedReport.collectAndSubmitResult();
    DefectReport defectReport = defectReporter.getDefectReport();
    assertThat(defectReport.getExtraInfo(), Matchers.equalTo(Optional.of("Extra\n")));
    assertThat(FluentIterable.from(defectReport.getIncludedPaths()).transform(Object::toString), Matchers.hasItem(Matchers.endsWith("extra.txt")));
}
Also used : ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) DefaultProcessExecutor(com.facebook.buck.util.DefaultProcessExecutor) NoOpCmdLineInterface(com.facebook.buck.util.versioncontrol.NoOpCmdLineInterface) Console(com.facebook.buck.util.Console) TestConsole(com.facebook.buck.testutil.TestConsole) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) TestConsole(com.facebook.buck.testutil.TestConsole) Test(org.junit.Test)

Example 49 with TestConsole

use of com.facebook.buck.testutil.TestConsole in project buck by facebook.

the class PythonTestIntegrationTest method assumePythonVersionIsAtLeast.

private void assumePythonVersionIsAtLeast(String expectedVersion, String message) throws InterruptedException {
    PythonVersion actualVersion = new PythonBuckConfig(FakeBuckConfig.builder().build(), new ExecutableFinder()).getPythonEnvironment(new DefaultProcessExecutor(new TestConsole())).getPythonVersion();
    assumeTrue(String.format("Needs at least Python-%s, but found Python-%s: %s", expectedVersion, actualVersion, message), new VersionStringComparator().compare(actualVersion.getVersionString(), expectedVersion) >= 0);
}
Also used : ExecutableFinder(com.facebook.buck.io.ExecutableFinder) DefaultProcessExecutor(com.facebook.buck.util.DefaultProcessExecutor) VersionStringComparator(com.facebook.buck.util.VersionStringComparator) TestConsole(com.facebook.buck.testutil.TestConsole)

Example 50 with TestConsole

use of com.facebook.buck.testutil.TestConsole in project buck by facebook.

the class TestCellBuilder method build.

public Cell build() throws IOException, InterruptedException {
    ProcessExecutor executor = new DefaultProcessExecutor(new TestConsole());
    BuckConfig config = buckConfig == null ? FakeBuckConfig.builder().setFilesystem(filesystem).build() : buckConfig;
    KnownBuildRuleTypesFactory typesFactory = new KnownBuildRuleTypesFactory(executor, androidDirectoryResolver);
    if (parserFactory == null) {
        return CellProvider.createForLocalBuild(filesystem, watchman, config, cellConfig, typesFactory).getCellByPath(filesystem.getRootPath());
    }
    // The constructor for `Cell` is private, and it's in such a central location I don't really
    // want to make it public. Brace yourselves.
    Enhancer enhancer = new Enhancer();
    enhancer.setSuperclass(Cell.class);
    enhancer.setCallback((MethodInterceptor) (obj, method, args, proxy) -> {
        if ("createBuildFileParserFactory".equals(method.getName())) {
            return parserFactory;
        }
        return proxy.invokeSuper(obj, args);
    });
    return (Cell) enhancer.create();
}
Also used : MethodInterceptor(net.sf.cglib.proxy.MethodInterceptor) FakeAndroidDirectoryResolver(com.facebook.buck.android.FakeAndroidDirectoryResolver) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) IOException(java.io.IOException) ProjectBuildFileParserFactory(com.facebook.buck.json.ProjectBuildFileParserFactory) Watchman(com.facebook.buck.io.Watchman) NULL_WATCHMAN(com.facebook.buck.io.Watchman.NULL_WATCHMAN) FakeBuckConfig(com.facebook.buck.cli.FakeBuckConfig) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) BuckConfig(com.facebook.buck.cli.BuckConfig) CellConfig(com.facebook.buck.config.CellConfig) TestConsole(com.facebook.buck.testutil.TestConsole) ProcessExecutor(com.facebook.buck.util.ProcessExecutor) AndroidDirectoryResolver(com.facebook.buck.android.AndroidDirectoryResolver) Enhancer(net.sf.cglib.proxy.Enhancer) DefaultProcessExecutor(com.facebook.buck.util.DefaultProcessExecutor) Nullable(javax.annotation.Nullable) DefaultProcessExecutor(com.facebook.buck.util.DefaultProcessExecutor) FakeBuckConfig(com.facebook.buck.cli.FakeBuckConfig) BuckConfig(com.facebook.buck.cli.BuckConfig) Enhancer(net.sf.cglib.proxy.Enhancer) ProcessExecutor(com.facebook.buck.util.ProcessExecutor) DefaultProcessExecutor(com.facebook.buck.util.DefaultProcessExecutor) TestConsole(com.facebook.buck.testutil.TestConsole)

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