Search in sources :

Example 1 with FakeProcessExecutor

use of com.facebook.buck.util.FakeProcessExecutor in project buck by facebook.

the class CodeSignIdentityStoreTest method testInvalidIdentitiesAreIgnored.

@Test
public void testInvalidIdentitiesAreIgnored() throws Exception {
    ProcessExecutorParams processExecutorParams = ProcessExecutorParams.builder().addCommand("unused").build();
    FakeProcess process = new FakeProcess(0, "  1) AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA " + "\"iPhone Developer: Foo Bar (ABCDE12345)\" (CSSMERR_TP_CERT_REVOKED)\n" + "  2) AAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBB " + "\"iPhone Developer: Foo Bar (12345ABCDE)\" (CSSMERR_TP_CERT_EXPIRED)\n" + "  3) BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB " + "\"iPhone Developer: Foo Bar (54321EDCBA)\"\n" + "     3 valid identities found\n", "");
    FakeProcessExecutor processExecutor = new FakeProcessExecutor(ImmutableMap.of(processExecutorParams, process));
    CodeSignIdentityStore store = CodeSignIdentityStore.fromSystem(processExecutor, ImmutableList.of("unused"));
    ImmutableList<CodeSignIdentity> expected = ImmutableList.of(CodeSignIdentity.builder().setFingerprint(CodeSignIdentity.toFingerprint("BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB")).setSubjectCommonName("iPhone Developer: Foo Bar (54321EDCBA)").build());
    assertThat(store.getIdentities(), equalTo(expected));
}
Also used : ProcessExecutorParams(com.facebook.buck.util.ProcessExecutorParams) FakeProcessExecutor(com.facebook.buck.util.FakeProcessExecutor) FakeProcess(com.facebook.buck.util.FakeProcess) Test(org.junit.Test)

Example 2 with FakeProcessExecutor

use of com.facebook.buck.util.FakeProcessExecutor in project buck by facebook.

the class AppleConfigTest method getXcodeSelectDetectedAppleDeveloperDirectorySupplier.

@Test
public void getXcodeSelectDetectedAppleDeveloperDirectorySupplier() {
    BuckConfig buckConfig = FakeBuckConfig.builder().build();
    AppleConfig config = new AppleConfig(buckConfig);
    ProcessExecutorParams xcodeSelectParams = ProcessExecutorParams.builder().setCommand(ImmutableList.of("xcode-select", "--print-path")).build();
    FakeProcess fakeXcodeSelect = new FakeProcess(0, "/path/to/another/place", "");
    FakeProcessExecutor processExecutor = new FakeProcessExecutor(ImmutableMap.of(xcodeSelectParams, fakeXcodeSelect));
    Supplier<Optional<Path>> supplier = config.getAppleDeveloperDirectorySupplier(processExecutor);
    assertNotNull(supplier);
    assertEquals(Optional.of(Paths.get("/path/to/another/place")), supplier.get());
}
Also used : ProcessExecutorParams(com.facebook.buck.util.ProcessExecutorParams) FakeBuckConfig(com.facebook.buck.cli.FakeBuckConfig) BuckConfig(com.facebook.buck.cli.BuckConfig) Optional(java.util.Optional) FakeProcessExecutor(com.facebook.buck.util.FakeProcessExecutor) FakeProcess(com.facebook.buck.util.FakeProcess) Test(org.junit.Test)

Example 3 with FakeProcessExecutor

use of com.facebook.buck.util.FakeProcessExecutor in project buck by facebook.

the class AppleConfigTest method getUnspecifiedAppleDeveloperDirectorySupplier.

@Test
public void getUnspecifiedAppleDeveloperDirectorySupplier() {
    BuckConfig buckConfig = FakeBuckConfig.builder().build();
    AppleConfig config = new AppleConfig(buckConfig);
    assertNotNull(config.getAppleDeveloperDirectorySupplier(new FakeProcessExecutor()));
}
Also used : FakeBuckConfig(com.facebook.buck.cli.FakeBuckConfig) BuckConfig(com.facebook.buck.cli.BuckConfig) FakeProcessExecutor(com.facebook.buck.util.FakeProcessExecutor) Test(org.junit.Test)

Example 4 with FakeProcessExecutor

use of com.facebook.buck.util.FakeProcessExecutor in project buck by facebook.

the class AppleConfigTest method getSpecifiedAppleDeveloperDirectorySupplier.

@Test
public void getSpecifiedAppleDeveloperDirectorySupplier() {
    BuckConfig buckConfig = FakeBuckConfig.builder().setSections(ImmutableMap.of("apple", ImmutableMap.of("xcode_developer_dir", "/path/to/somewhere"))).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());
    // Developer directory for tests should fall back to developer dir if not separately specified.
    Supplier<Optional<Path>> supplierForTests = config.getAppleDeveloperDirectorySupplierForTests(new FakeProcessExecutor());
    assertNotNull(supplierForTests);
    assertEquals(Optional.of(Paths.get("/path/to/somewhere")), supplierForTests.get());
}
Also used : FakeBuckConfig(com.facebook.buck.cli.FakeBuckConfig) BuckConfig(com.facebook.buck.cli.BuckConfig) Optional(java.util.Optional) FakeProcessExecutor(com.facebook.buck.util.FakeProcessExecutor) Test(org.junit.Test)

Example 5 with FakeProcessExecutor

use of com.facebook.buck.util.FakeProcessExecutor 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)));
}
Also used : ProcessExecutorParams(com.facebook.buck.util.ProcessExecutorParams) ExecutionContext(com.facebook.buck.step.ExecutionContext) TestExecutionContext(com.facebook.buck.step.TestExecutionContext) FakeProcessExecutor(com.facebook.buck.util.FakeProcessExecutor) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) FakeProcess(com.facebook.buck.util.FakeProcess) Test(org.junit.Test)

Aggregations

FakeProcessExecutor (com.facebook.buck.util.FakeProcessExecutor)47 Test (org.junit.Test)42 FakeProcess (com.facebook.buck.util.FakeProcess)35 ProcessExecutorParams (com.facebook.buck.util.ProcessExecutorParams)21 ExecutionContext (com.facebook.buck.step.ExecutionContext)19 TestExecutionContext (com.facebook.buck.step.TestExecutionContext)19 FakeProjectFilesystem (com.facebook.buck.testutil.FakeProjectFilesystem)17 ImmutableList (com.google.common.collect.ImmutableList)9 SimpleImmutableEntry (java.util.AbstractMap.SimpleImmutableEntry)9 TestConsole (com.facebook.buck.testutil.TestConsole)8 Path (java.nio.file.Path)6 BuckConfig (com.facebook.buck.cli.BuckConfig)5 FakeBuckConfig (com.facebook.buck.cli.FakeBuckConfig)5 ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)5 BuckEventBusFactory (com.facebook.buck.event.BuckEventBusFactory)4 BuildRuleResolver (com.facebook.buck.rules.BuildRuleResolver)4 DefaultTargetNodeToBuildRuleTransformer (com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer)4 SourcePathResolver (com.facebook.buck.rules.SourcePathResolver)4 SourcePathRuleFinder (com.facebook.buck.rules.SourcePathRuleFinder)4 StepExecutionResult (com.facebook.buck.step.StepExecutionResult)4