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)));
}
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();
}
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")));
}
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);
}
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();
}
Aggregations