use of com.facebook.buck.testutil.TestConsole in project buck by facebook.
the class AaptStepTest method createTestExecutionContext.
/**
* Create an execution context with the given verbosity level. The execution context
* will yield fake values relative to the base path for all target queries.
* The mock context returned has not been replayed, so the calling code
* may add additional expectations, and is responsible for calling replay().
*/
private ExecutionContext createTestExecutionContext(Verbosity verbosity) {
final AndroidPlatformTarget androidPlatformTarget = createMock(AndroidPlatformTarget.class);
expect(androidPlatformTarget.getAaptExecutable()).andReturn(basePath.resolve("mock_aapt_bin"));
expect(androidPlatformTarget.getAndroidJar()).andReturn(basePath.resolve("mock_android.jar"));
replay(androidPlatformTarget);
ExecutionContext executionContext = TestExecutionContext.newBuilder().setConsole(new TestConsole(verbosity)).setAndroidPlatformTargetSupplier(Suppliers.ofInstance(androidPlatformTarget)).build();
return executionContext;
}
use of com.facebook.buck.testutil.TestConsole in project buck by facebook.
the class AdbHelperTest method testNonQuietShowsOutput.
@Test
public void testNonQuietShowsOutput() throws InterruptedException {
final File apk = new File("/some/file.apk");
final AtomicReference<String> apkPath = new AtomicReference<>();
TestDevice device = new TestDevice() {
@Override
public void installPackage(String s, boolean b, String... strings) throws InstallException {
apkPath.set(s);
}
};
device.setSerialNumber("serial#1");
device.setName("testDevice");
final List<IDevice> deviceList = Lists.newArrayList((IDevice) device);
TestConsole console = new TestConsole();
BuckEventBus eventBus = BuckEventBusFactory.newInstance();
AdbHelper adbHelper = new AdbHelper(new AdbOptions(), new TargetDeviceOptions(), TestExecutionContext.newInstance(), console, eventBus, true) {
@Override
protected boolean isDeviceTempWritable(IDevice device, String name) {
return true;
}
@Override
public List<IDevice> getDevices(boolean quiet) {
return deviceList;
}
};
boolean success = adbHelper.adbCall(new AdbHelper.AdbCallable() {
@Override
public boolean call(IDevice device) throws Exception {
return basicAdbHelper.installApkOnDevice(device, apk, false, false);
}
@Override
public String toString() {
return "install apk";
}
}, false);
assertTrue(success);
assertEquals(apk.getAbsolutePath(), apkPath.get());
assertEquals("", console.getTextWrittenToStdOut());
assertEquals("Successfully ran install apk on 1 device(s)\n", console.getTextWrittenToStdErr());
}
use of com.facebook.buck.testutil.TestConsole in project buck by facebook.
the class BuiltinApplePackageIntegrationTest method packageSupportsFatBinaries.
@Test
public void packageSupportsFatBinaries() throws IOException, InterruptedException {
assumeTrue(Platform.detect() == Platform.MACOS);
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "simple_application_bundle_no_debug", tmp);
workspace.setUp();
BuildTarget packageTarget = BuildTargetFactory.newInstance("//:DemoAppPackage#iphonesimulator-i386,iphonesimulator-x86_64");
workspace.runBuckCommand("build", packageTarget.getFullyQualifiedName()).assertSuccess();
Unzip.extractZipFile(workspace.getPath(BuildTargets.getGenPath(filesystem, packageTarget, "%s.ipa")), workspace.getDestPath(), Unzip.ExistingFileMode.OVERWRITE_AND_CLEAN_DIRECTORIES);
ProcessExecutor executor = new DefaultProcessExecutor(new TestConsole());
ProcessExecutorParams processExecutorParams = ProcessExecutorParams.builder().setCommand(ImmutableList.of("lipo", "-info", workspace.getDestPath().resolve("Payload/DemoApp.app/DemoApp").toString())).build();
// Specify that stdout is expected, or else output may be wrapped in Ansi escape chars.
Set<ProcessExecutor.Option> options = EnumSet.of(ProcessExecutor.Option.EXPECTING_STD_OUT, ProcessExecutor.Option.IS_SILENT);
ProcessExecutor.Result result = executor.launchAndExecute(processExecutorParams, options, /* stdin */
Optional.empty(), /* timeOutMs */
Optional.empty(), /* timeOutHandler */
Optional.empty());
assertEquals(result.getExitCode(), 0);
assertTrue(result.getStdout().isPresent());
String output = result.getStdout().get();
assertTrue(output.contains("i386"));
assertTrue(output.contains("x86_64"));
}
use of com.facebook.buck.testutil.TestConsole in project buck by facebook.
the class AppleNativeIntegrationTestUtils method discoverSystemSdkPaths.
private static ImmutableMap<AppleSdk, AppleSdkPaths> discoverSystemSdkPaths(BuckConfig buckConfig) {
AppleConfig appleConfig = new AppleConfig(buckConfig);
ProcessExecutor executor = new DefaultProcessExecutor(new TestConsole());
return appleConfig.getAppleSdkPaths(executor);
}
use of com.facebook.buck.testutil.TestConsole in project buck by facebook.
the class ProvisioningProfileCopyStepTest method testFailsWithNoSuitableProfilesFound.
@Test
public void testFailsWithNoSuitableProfilesFound() throws Exception {
assumeTrue(Platform.detect() == Platform.MACOS);
thrown.expect(HumanReadableException.class);
thrown.expectMessage("No valid non-expired provisioning profiles match for *.com.example.TestApp");
Path emptyDir = TestDataHelper.getTestDataDirectory(this).resolve("provisioning_profiles_empty");
ProvisioningProfileCopyStep step = new ProvisioningProfileCopyStep(projectFilesystem, testdataDir.resolve("Info.plist"), ApplePlatform.IPHONEOS, Optional.empty(), Optional.empty(), ProvisioningProfileStore.fromSearchPath(new DefaultProcessExecutor(new TestConsole()), ProvisioningProfileStore.DEFAULT_READ_COMMAND, emptyDir), outputFile, xcentFile, codeSignIdentityStore, Optional.empty());
step.execute(executionContext);
}
Aggregations