use of com.facebook.buck.util.FakeProcessExecutor in project buck by facebook.
the class JavacStepTest method existingBootclasspathDirSucceeds.
@Test
public void existingBootclasspathDirSucceeds() 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("/this-totally-exists").build();
ClasspathChecker classpathChecker = new ClasspathChecker("/", ":", Paths::get, dir -> true, 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);
assertThat(result, equalTo(StepExecutionResult.SUCCESS));
assertThat(listener.getLogMessages(), empty());
}
use of com.facebook.buck.util.FakeProcessExecutor in project buck by facebook.
the class AppleConfigTest method getSpecifiedAppleDeveloperDirectorySupplierForTests.
@Test
public void getSpecifiedAppleDeveloperDirectorySupplierForTests() {
BuckConfig buckConfig = FakeBuckConfig.builder().setSections(ImmutableMap.of("apple", ImmutableMap.of("xcode_developer_dir", "/path/to/somewhere", "xcode_developer_dir_for_tests", "/path/to/somewhere2"))).build();
AppleConfig config = new AppleConfig(buckConfig);
Supplier<Optional<Path>> supplier = config.getAppleDeveloperDirectorySupplier(new FakeProcessExecutor());
assertNotNull(supplier);
assertEquals(Optional.of(Paths.get("/path/to/somewhere")), supplier.get());
Supplier<Optional<Path>> supplierForTests = config.getAppleDeveloperDirectorySupplierForTests(new FakeProcessExecutor());
assertNotNull(supplierForTests);
assertEquals(Optional.of(Paths.get("/path/to/somewhere2")), supplierForTests.get());
}
use of com.facebook.buck.util.FakeProcessExecutor in project buck by facebook.
the class ShellStepTest method testDescriptionWithPath.
@Test
public void testDescriptionWithPath() {
ShellStep command = createCommand(ImmutableMap.of(), ARGS, PATH);
ExecutionContext context = TestExecutionContext.newBuilder().setProcessExecutor(new FakeProcessExecutor()).build();
String template = Platform.detect() == Platform.WINDOWS ? "(cd %s && bash -c \"echo $V1 $V2\")" : "(cd %s && bash -c 'echo $V1 $V2')";
assertEquals(String.format(template, Escaper.escapeAsBashString(PATH)), command.getDescription(context));
}
use of com.facebook.buck.util.FakeProcessExecutor in project buck by facebook.
the class ShellStepTest method testDescriptionWithEnvironment.
@Test
public void testDescriptionWithEnvironment() {
Path workingDirectory = Paths.get(".").toAbsolutePath().normalize();
ShellStep command = createCommand(ENV, ARGS, null);
ExecutionContext context = TestExecutionContext.newBuilder().setProcessExecutor(new FakeProcessExecutor()).build();
String template = Platform.detect() == Platform.WINDOWS ? "(cd %s && V1=\"two words\" V2=$foo'bar' bash -c \"echo $V1 $V2\")" : "(cd %s && V1='two words' V2='$foo'\\''bar'\\''' bash -c 'echo $V1 $V2')";
assertEquals(String.format(template, Escaper.escapeAsBashString(workingDirectory)), command.getDescription(context));
}
use of com.facebook.buck.util.FakeProcessExecutor in project buck by facebook.
the class ShellStepTest method testDescription.
@Test
public void testDescription() {
Path workingDirectory = Paths.get(".").toAbsolutePath().normalize();
ShellStep command = createCommand(ImmutableMap.of(), ARGS, null);
ExecutionContext context = TestExecutionContext.newBuilder().setProcessExecutor(new FakeProcessExecutor()).build();
String expectedDescription = Platform.detect() == Platform.WINDOWS ? "(cd %s && bash -c \"echo $V1 $V2\")" : "(cd %s && bash -c 'echo $V1 $V2')";
assertEquals(String.format(expectedDescription, Escaper.escapeAsBashString(workingDirectory)), command.getDescription(context));
}
Aggregations