use of com.facebook.buck.util.DefaultProcessExecutor 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.util.DefaultProcessExecutor 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.util.DefaultProcessExecutor 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();
}
use of com.facebook.buck.util.DefaultProcessExecutor in project buck by facebook.
the class WorkerProcessTest method testDoesNotBlockOnLargeStderr.
@Test(timeout = 20 * 1000)
public void testDoesNotBlockOnLargeStderr() throws IOException {
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "worker_process", temporaryPaths);
workspace.setUp();
ProjectFilesystem projectFilesystem = new ProjectFilesystem(workspace.getDestPath());
Console console = new Console(Verbosity.ALL, System.out, System.err, Ansi.withoutTty());
String script;
if (Platform.detect() == Platform.WINDOWS) {
script = workspace.getDestPath().resolve("script.bat").toString();
} else {
script = "./script.py";
}
WorkerProcess workerProcess = new WorkerProcess(new DefaultProcessExecutor(console), ProcessExecutorParams.builder().setCommand(ImmutableList.of(script)).setDirectory(workspace.getDestPath()).build(), projectFilesystem, temporaryPaths.newFolder());
try {
workerProcess.ensureLaunchAndHandshake();
fail("Handshake should have failed");
} catch (HumanReadableException e) {
// Check that all of the process's stderr was reported.
assertThat(e.getMessage().length(), is(greaterThan(1024 * 1024)));
}
}
use of com.facebook.buck.util.DefaultProcessExecutor in project buck by facebook.
the class SymlinkFileStepTest method testReplaceMalformedSymlink.
@Test
public void testReplaceMalformedSymlink() throws IOException, InterruptedException {
assumeTrue(Platform.detect() != Platform.WINDOWS);
// Run `ln -s /path/that/does/not/exist dummy` in /tmp.
ProcessExecutorParams params = ProcessExecutorParams.builder().setCommand(ImmutableList.of("ln", "-s", "/path/that/does/not/exist", "my_symlink")).setDirectory(tmpDir.getRoot().toPath()).build();
ProcessExecutor executor = new DefaultProcessExecutor(Console.createNullConsole());
executor.launchAndExecute(params);
// Verify that the symlink points to a non-existent file.
Path symlink = Paths.get(tmpDir.getRoot().getAbsolutePath(), "my_symlink");
assertFalse("exists() should reflect the existence of what the symlink points to", symlink.toFile().exists());
assertTrue("even though exists() is false, isSymbolicLink should be true", java.nio.file.Files.isSymbolicLink(symlink));
// Create an ExecutionContext to return the ProjectFilesystem.
ProjectFilesystem projectFilesystem = new ProjectFilesystem(tmpDir.getRoot().toPath());
ExecutionContext executionContext = TestExecutionContext.newInstance();
tmpDir.newFile("dummy");
SymlinkFileStep symlinkStep = new SymlinkFileStep(projectFilesystem, /* source */
Paths.get("dummy"), /* target */
Paths.get("my_symlink"), /* useAbsolutePaths*/
true);
int exitCode = symlinkStep.execute(executionContext).getExitCode();
assertEquals(0, exitCode);
assertTrue(java.nio.file.Files.isSymbolicLink(symlink));
assertTrue(symlink.toFile().exists());
}
Aggregations