use of com.facebook.buck.testutil.FakeProjectFilesystem in project buck by facebook.
the class MultiarchFileTest method descriptionWithMultiplePlatformArgsShouldGenerateMultiarchFile.
@SuppressWarnings({ "unchecked" })
@Test
public void descriptionWithMultiplePlatformArgsShouldGenerateMultiarchFile() throws Exception {
BuildTarget target = BuildTargetFactory.newInstance("//foo:thing#iphoneos-i386,iphoneos-x86_64");
BuildTarget sandboxTarget = BuildTargetFactory.newInstance("//foo:thing#iphoneos-i386,iphoneos-x86_64,sandbox");
BuildRuleResolver resolver = new BuildRuleResolver(TargetGraphFactory.newInstance(new AppleLibraryBuilder(sandboxTarget).build()), new DefaultTargetNodeToBuildRuleTransformer());
SourcePathResolver pathResolver = new SourcePathResolver(new SourcePathRuleFinder(resolver));
ProjectFilesystem filesystem = new FakeProjectFilesystem();
BuildRule multiarchRule = nodeBuilderFactory.getNodeBuilder(target).build(resolver, filesystem);
assertThat(multiarchRule, instanceOf(MultiarchFile.class));
ImmutableList<Step> steps = multiarchRule.getBuildSteps(FakeBuildContext.withSourcePathResolver(pathResolver), new FakeBuildableContext());
ShellStep step = Iterables.getLast(Iterables.filter(steps, ShellStep.class));
ExecutionContext executionContext = TestExecutionContext.newInstance();
ImmutableList<String> command = step.getShellCommand(executionContext);
assertThat(command, Matchers.contains(endsWith("lipo"), equalTo("-create"), equalTo("-output"), containsString("foo/thing#"), containsString("/thing#"), containsString("/thing#")));
}
use of com.facebook.buck.testutil.FakeProjectFilesystem in project buck by facebook.
the class AppleCxxPlatformsTest method setUp.
@Before
public void setUp() {
assumeTrue(Platform.detect() == Platform.MACOS || Platform.detect() == Platform.LINUX);
projectFilesystem = new FakeProjectFilesystem();
}
use of com.facebook.buck.testutil.FakeProjectFilesystem in project buck by facebook.
the class XctoolRunTestsStepTest method xctoolCommandWhichReturnsExitCode400FailsStep.
@Test
public void xctoolCommandWhichReturnsExitCode400FailsStep() throws Exception {
FakeProjectFilesystem projectFilesystem = new FakeProjectFilesystem();
XctoolRunTestsStep step = new XctoolRunTestsStep(projectFilesystem, Paths.get("/path/to/xctool"), ImmutableMap.of(), Optional.empty(), "iphonesimulator", Optional.empty(), ImmutableSet.of(Paths.get("/path/to/Foo.xctest")), ImmutableMap.of(), Paths.get("/path/to/output.json"), Optional.empty(), Suppliers.ofInstance(Optional.of(Paths.get("/path/to/developer/dir"))), TestSelectorList.EMPTY, false, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty());
ProcessExecutorParams xctoolParams = ProcessExecutorParams.builder().setCommand(ImmutableList.of("/path/to/xctool", "-reporter", "json-stream", "-sdk", "iphonesimulator", "run-tests", "-logicTest", "/path/to/Foo.xctest")).setEnvironment(ImmutableMap.of("DEVELOPER_DIR", "/path/to/developer/dir")).setDirectory(projectFilesystem.getRootPath().toAbsolutePath()).setRedirectOutput(ProcessBuilder.Redirect.PIPE).build();
FakeProcess fakeXctoolFailure = new FakeProcess(400, "", "");
FakeProcessExecutor processExecutor = new FakeProcessExecutor(ImmutableMap.of(xctoolParams, fakeXctoolFailure));
ExecutionContext executionContext = TestExecutionContext.newBuilder().setProcessExecutor(processExecutor).setEnvironment(ImmutableMap.of()).build();
assertThat(step.execute(executionContext).getExitCode(), not(equalTo(0)));
}
use of com.facebook.buck.testutil.FakeProjectFilesystem in project buck by facebook.
the class XctoolRunTestsStepTest method xctoolCommandWithTestSelectorFailsIfListTestsOnlyFails.
@Test
public void xctoolCommandWithTestSelectorFailsIfListTestsOnlyFails() throws Exception {
FakeProjectFilesystem projectFilesystem = new FakeProjectFilesystem();
XctoolRunTestsStep step = new XctoolRunTestsStep(projectFilesystem, Paths.get("/path/to/xctool"), ImmutableMap.of(), Optional.empty(), "iphonesimulator", Optional.empty(), ImmutableSet.of(Paths.get("/path/to/FooTest.xctest"), Paths.get("/path/to/BarTest.xctest")), ImmutableMap.of(), Paths.get("/path/to/output.json"), Optional.empty(), Suppliers.ofInstance(Optional.of(Paths.get("/path/to/developer/dir"))), TestSelectorList.builder().addRawSelectors("#.*Magic.*").build(), false, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty());
ProcessExecutorParams xctoolListOnlyParams = ProcessExecutorParams.builder().setCommand(ImmutableList.of("/path/to/xctool", "-reporter", "json-stream", "-sdk", "iphonesimulator", "run-tests", "-logicTest", "/path/to/FooTest.xctest", "-logicTest", "/path/to/BarTest.xctest", "-listTestsOnly")).setEnvironment(ImmutableMap.of("DEVELOPER_DIR", "/path/to/developer/dir")).setDirectory(projectFilesystem.getRootPath().toAbsolutePath()).setRedirectOutput(ProcessBuilder.Redirect.PIPE).build();
FakeProcess fakeXctoolListTestsFailureProcess = new FakeProcess(42, "", "Chopper Dave, we have Uh-Oh");
FakeProcessExecutor processExecutor = new FakeProcessExecutor(ImmutableMap.of(xctoolListOnlyParams, fakeXctoolListTestsFailureProcess));
TestConsole testConsole = new TestConsole();
ExecutionContext executionContext = TestExecutionContext.newBuilder().setProcessExecutor(processExecutor).setEnvironment(ImmutableMap.of()).setConsole(testConsole).build();
assertThat(step.execute(executionContext).getExitCode(), equalTo(42));
assertThat(testConsole.getTextWrittenToStdErr(), allOf(containsString("xctool failed with exit code 42: Chopper Dave, we have Uh-Oh"), containsString("Failed to query tests with xctool")));
}
use of com.facebook.buck.testutil.FakeProjectFilesystem in project buck by facebook.
the class XctoolRunTestsStepTest method xctoolCommandWhichReturnsExitCode1DoesNotFailStep.
@Test
public void xctoolCommandWhichReturnsExitCode1DoesNotFailStep() throws Exception {
FakeProjectFilesystem projectFilesystem = new FakeProjectFilesystem();
XctoolRunTestsStep step = new XctoolRunTestsStep(projectFilesystem, Paths.get("/path/to/xctool"), ImmutableMap.of(), Optional.empty(), "iphonesimulator", Optional.empty(), ImmutableSet.of(Paths.get("/path/to/Foo.xctest")), ImmutableMap.of(), Paths.get("/path/to/output.json"), Optional.empty(), Suppliers.ofInstance(Optional.of(Paths.get("/path/to/developer/dir"))), TestSelectorList.EMPTY, false, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty());
ProcessExecutorParams xctoolParams = ProcessExecutorParams.builder().setCommand(ImmutableList.of("/path/to/xctool", "-reporter", "json-stream", "-sdk", "iphonesimulator", "run-tests", "-logicTest", "/path/to/Foo.xctest")).setEnvironment(ImmutableMap.of("DEVELOPER_DIR", "/path/to/developer/dir")).setDirectory(projectFilesystem.getRootPath().toAbsolutePath()).setRedirectOutput(ProcessBuilder.Redirect.PIPE).build();
// Test failure is indicated by xctool exiting with exit code 1, so it shouldn't
// fail the step.
FakeProcess fakeXctoolTestFailure = new FakeProcess(1, "", "");
FakeProcessExecutor processExecutor = new FakeProcessExecutor(ImmutableMap.of(xctoolParams, fakeXctoolTestFailure));
ExecutionContext executionContext = TestExecutionContext.newBuilder().setProcessExecutor(processExecutor).setEnvironment(ImmutableMap.of()).build();
assertThat(step.execute(executionContext).getExitCode(), equalTo(0));
}
Aggregations