use of com.facebook.buck.util.FakeProcess in project buck by facebook.
the class JavacStepTest method successfulCompileDoesNotSendStdoutAndStderrToConsole.
@Test
public void successfulCompileDoesNotSendStdoutAndStderrToConsole() throws Exception {
FakeJavac fakeJavac = new FakeJavac();
BuildRuleResolver buildRuleResolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(buildRuleResolver);
SourcePathResolver sourcePathResolver = new SourcePathResolver(ruleFinder);
ProjectFilesystem fakeFilesystem = FakeProjectFilesystem.createJavaOnlyFilesystem();
JavacOptions javacOptions = JavacOptions.builder().setSourceLevel("8.0").setTargetLevel("8.0").build();
ClasspathChecker classpathChecker = new ClasspathChecker("/", ":", Paths::get, dir -> false, file -> false, (path, glob) -> ImmutableSet.of());
JavacStep step = new JavacStep(Paths.get("output"), NoOpClassUsageFileWriter.instance(), Optional.empty(), ImmutableSortedSet.of(), Paths.get("pathToSrcsList"), ImmutableSortedSet.of(), fakeJavac, javacOptions, BuildTargetFactory.newInstance("//foo:bar"), Optional.empty(), sourcePathResolver, ruleFinder, fakeFilesystem, classpathChecker, Optional.empty());
FakeProcess fakeJavacProcess = new FakeProcess(0, "javac stdout\n", "javac stderr\n");
ExecutionContext executionContext = TestExecutionContext.newBuilder().setProcessExecutor(new FakeProcessExecutor(Functions.constant(fakeJavacProcess), new TestConsole())).build();
BuckEventBusFactory.CapturingConsoleEventListener listener = new BuckEventBusFactory.CapturingConsoleEventListener();
executionContext.getBuckEventBus().register(listener);
StepExecutionResult result = step.execute(executionContext);
// Note that we don't include stderr in the step result on success.
assertThat(result, equalTo(StepExecutionResult.SUCCESS));
assertThat(listener.getLogMessages(), empty());
}
use of com.facebook.buck.util.FakeProcess in project buck by facebook.
the class JavacStepTest method missingBootclasspathDirFailsWithError.
@Test
public void missingBootclasspathDirFailsWithError() throws Exception {
FakeJavac fakeJavac = new FakeJavac();
BuildRuleResolver buildRuleResolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(buildRuleResolver);
SourcePathResolver sourcePathResolver = new SourcePathResolver(ruleFinder);
ProjectFilesystem fakeFilesystem = FakeProjectFilesystem.createJavaOnlyFilesystem();
JavacOptions javacOptions = JavacOptions.builder().setSourceLevel("8.0").setTargetLevel("8.0").setBootclasspath("/no-such-dir").build();
ClasspathChecker classpathChecker = new ClasspathChecker("/", ":", Paths::get, dir -> false, file -> false, (path, glob) -> ImmutableSet.of());
JavacStep step = new JavacStep(Paths.get("output"), NoOpClassUsageFileWriter.instance(), Optional.empty(), ImmutableSortedSet.of(), Paths.get("pathToSrcsList"), ImmutableSortedSet.of(), fakeJavac, javacOptions, BuildTargetFactory.newInstance("//foo:bar"), Optional.empty(), sourcePathResolver, ruleFinder, fakeFilesystem, classpathChecker, Optional.empty());
FakeProcess fakeJavacProcess = new FakeProcess(1, "javac stdout\n", "javac stderr\n");
ExecutionContext executionContext = TestExecutionContext.newBuilder().setProcessExecutor(new FakeProcessExecutor(Functions.constant(fakeJavacProcess), new TestConsole())).build();
BuckEventBusFactory.CapturingConsoleEventListener listener = new BuckEventBusFactory.CapturingConsoleEventListener();
executionContext.getBuckEventBus().register(listener);
StepExecutionResult result = step.execute(executionContext);
assertThat(result, equalTo(StepExecutionResult.ERROR));
assertThat(listener.getLogMessages(), equalTo(ImmutableList.of("Invalid Java compiler options: Bootstrap classpath /no-such-dir " + "contains no valid entries")));
}
use of com.facebook.buck.util.FakeProcess 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.util.FakeProcess in project buck by facebook.
the class KnownBuildRuleTypesTest method addXcodeSelectProcess.
private static void addXcodeSelectProcess(Map<ProcessExecutorParams, FakeProcess> processMap, String xcodeSelectPath) {
FakeProcess xcodeSelectOutputProcess = new FakeProcess(0, xcodeSelectPath, "");
ProcessExecutorParams xcodeSelectParams = ProcessExecutorParams.builder().setCommand(ImmutableList.of("xcode-select", "--print-path")).build();
processMap.put(xcodeSelectParams, xcodeSelectOutputProcess);
}
use of com.facebook.buck.util.FakeProcess in project buck by facebook.
the class ShellStepTest method testStdErrNotPrintedOnSuccessIfNotShouldPrintStdErr.
@Test
public void testStdErrNotPrintedOnSuccessIfNotShouldPrintStdErr() throws Exception {
ShellStep command = createCommand(/*shouldPrintStdErr*/
false, /*shouldPrintStdOut*/
false);
ProcessExecutorParams params = createParams();
FakeProcess process = new FakeProcess(EXIT_SUCCESS, OUTPUT_MSG, ERROR_MSG);
TestConsole console = new TestConsole(Verbosity.STANDARD_INFORMATION);
ExecutionContext context = createContext(ImmutableMap.of(params, process), console);
command.launchAndInteractWithProcess(context, params);
assertEquals("", console.getTextWrittenToStdErr());
}
Aggregations