use of com.facebook.buck.testutil.FakeProjectFilesystem in project buck by facebook.
the class PlistProcessStepTest method testFailsWithInvalidInput.
@Test
public void testFailsWithInvalidInput() throws Exception {
FakeProjectFilesystem projectFilesystem = new FakeProjectFilesystem();
PlistProcessStep plistProcessStep = new PlistProcessStep(projectFilesystem, INPUT_PATH, Optional.empty(), OUTPUT_PATH, ImmutableMap.of(), ImmutableMap.of(), PlistProcessStep.OutputFormat.XML);
projectFilesystem.writeContentsToPath("<html>not a <b>plist</b></html>", INPUT_PATH);
ExecutionContext executionContext = TestExecutionContext.newBuilder().build();
int errorCode = plistProcessStep.execute(executionContext).getExitCode();
assertThat(errorCode, equalTo(1));
}
use of com.facebook.buck.testutil.FakeProjectFilesystem in project buck by facebook.
the class PlistProcessStepTest method testMergeFromFileReplacesExistingKey.
@Test
public void testMergeFromFileReplacesExistingKey() throws Exception {
FakeProjectFilesystem projectFilesystem = new FakeProjectFilesystem();
PlistProcessStep plistProcessStep = new PlistProcessStep(projectFilesystem, INPUT_PATH, Optional.of(MERGE_PATH), OUTPUT_PATH, ImmutableMap.of(), ImmutableMap.of(), PlistProcessStep.OutputFormat.XML);
NSDictionary dict = new NSDictionary();
dict.put("Key1", "Value1");
dict.put("Key2", "Value2");
projectFilesystem.writeContentsToPath(dict.toXMLPropertyList(), INPUT_PATH);
NSDictionary overrideDict = new NSDictionary();
overrideDict.put("Key1", "OverrideValue");
projectFilesystem.writeContentsToPath(overrideDict.toXMLPropertyList(), MERGE_PATH);
ExecutionContext executionContext = TestExecutionContext.newInstance();
int errorCode = plistProcessStep.execute(executionContext).getExitCode();
assertThat(errorCode, equalTo(0));
dict.put("Key1", "OverrideValue");
assertThat(projectFilesystem.readFileIfItExists(OUTPUT_PATH), equalTo(Optional.of(dict.toXMLPropertyList())));
}
use of com.facebook.buck.testutil.FakeProjectFilesystem in project buck by facebook.
the class PlistProcessStepTest method testAdditionDoesNotReplaceExistingKey.
@Test
public void testAdditionDoesNotReplaceExistingKey() throws Exception {
FakeProjectFilesystem projectFilesystem = new FakeProjectFilesystem();
PlistProcessStep plistProcessStep = new PlistProcessStep(projectFilesystem, INPUT_PATH, Optional.empty(), OUTPUT_PATH, ImmutableMap.of("Key1", new NSString("OverrideValue")), ImmutableMap.of(), PlistProcessStep.OutputFormat.XML);
NSDictionary dict = new NSDictionary();
dict.put("Key1", "Value1");
dict.put("Key2", "Value2");
projectFilesystem.writeContentsToPath(dict.toXMLPropertyList(), INPUT_PATH);
ExecutionContext executionContext = TestExecutionContext.newInstance();
int errorCode = plistProcessStep.execute(executionContext).getExitCode();
assertThat(errorCode, equalTo(0));
assertThat(projectFilesystem.readFileIfItExists(OUTPUT_PATH), equalTo(Optional.of(dict.toXMLPropertyList())));
}
use of com.facebook.buck.testutil.FakeProjectFilesystem in project buck by facebook.
the class PlistProcessStepTest method testHandlesNonDictionaryPlists.
@Test
public void testHandlesNonDictionaryPlists() throws Exception {
FakeProjectFilesystem projectFilesystem = new FakeProjectFilesystem();
PlistProcessStep plistProcessStep = new PlistProcessStep(projectFilesystem, INPUT_PATH, Optional.empty(), OUTPUT_PATH, ImmutableMap.of(), ImmutableMap.of("Key1", new NSString("OverrideValue")), PlistProcessStep.OutputFormat.XML);
NSArray array = new NSArray(new NSString("Value1"), new NSString("Value2"));
projectFilesystem.writeContentsToPath(array.toXMLPropertyList(), INPUT_PATH);
ExecutionContext executionContext = TestExecutionContext.newInstance();
int errorCode = plistProcessStep.execute(executionContext).getExitCode();
assertThat(errorCode, equalTo(0));
assertThat(projectFilesystem.readFileIfItExists(OUTPUT_PATH), equalTo(Optional.of(array.toXMLPropertyList())));
}
use of com.facebook.buck.testutil.FakeProjectFilesystem in project buck by facebook.
the class XctoolRunTestsStepTest method xctoolCommandWithOnlyLogicTests.
@Test
public void xctoolCommandWithOnlyLogicTests() 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 fakeXctoolSuccess = new FakeProcess(0, "", "");
FakeProcessExecutor processExecutor = new FakeProcessExecutor(ImmutableMap.of(xctoolParams, fakeXctoolSuccess));
ExecutionContext executionContext = TestExecutionContext.newBuilder().setProcessExecutor(processExecutor).setEnvironment(ImmutableMap.of()).build();
assertThat(step.execute(executionContext).getExitCode(), equalTo(0));
}
Aggregations