use of com.facebook.buck.testutil.integration.ProjectWorkspace in project buck by facebook.
the class AppleLibraryIntegrationTest method testAppleDynamicLibraryWithDsym.
@Test
public void testAppleDynamicLibraryWithDsym() throws Exception {
assumeTrue(Platform.detect() == Platform.MACOS);
assumeTrue(AppleNativeIntegrationTestUtils.isApplePlatformAvailable(ApplePlatform.MACOSX));
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "apple_library_shared", tmp);
workspace.setUp();
ProjectFilesystem filesystem = new ProjectFilesystem(workspace.getDestPath());
BuildTarget target = BuildTargetFactory.newInstance("//Libraries/TestLibrary:TestLibrary").withAppendedFlavors(CxxDescriptionEnhancer.SHARED_FLAVOR, AppleDebugFormat.DWARF_AND_DSYM.getFlavor(), InternalFlavor.of("macosx-x86_64"));
ProjectWorkspace.ProcessResult result = workspace.runBuckCommand("build", target.getFullyQualifiedName(), "--config", "cxx.cflags=-g");
result.assertSuccess();
BuildTarget implicitTarget = target.withAppendedFlavors(CxxStrip.RULE_FLAVOR, StripStyle.NON_GLOBAL_SYMBOLS.getFlavor());
Path outputPath = workspace.getPath(BuildTargets.getGenPath(filesystem, implicitTarget, "%s"));
assertThat(Files.exists(outputPath), is(true));
Path dsymPath = tmp.getRoot().resolve(filesystem.getBuckPaths().getGenDir()).resolve("Libraries/TestLibrary").resolve("TestLibrary#apple-dsym,macosx-x86_64,shared.dSYM");
assertThat(Files.exists(dsymPath), is(true));
AppleDsymTestUtil.checkDsymFileHasDebugSymbol("+[TestClass answer]", workspace, dsymPath);
}
use of com.facebook.buck.testutil.integration.ProjectWorkspace in project buck by facebook.
the class AppleLibraryIntegrationTest method appleLibraryBuildsMultiarchFramework.
@Test
public void appleLibraryBuildsMultiarchFramework() throws Exception {
assumeTrue(Platform.detect() == Platform.MACOS);
assumeTrue(AppleNativeIntegrationTestUtils.isApplePlatformAvailable(ApplePlatform.MACOSX));
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "apple_library_builds_something", tmp);
workspace.setUp();
ProjectFilesystem filesystem = new ProjectFilesystem(workspace.getDestPath());
BuildTarget target = BuildTargetFactory.newInstance("//Libraries/TestLibrary:TestLibrary#macosx-x86_64,macosx-i386").withAppendedFlavors(AppleDescriptions.FRAMEWORK_FLAVOR, AppleDebugFormat.NONE.getFlavor());
ProjectWorkspace.ProcessResult result = workspace.runBuckCommand("build", target.getFullyQualifiedName());
result.assertSuccess();
Path frameworkPath = workspace.getPath(BuildTargets.getGenPath(filesystem, BuildTarget.builder(target).addFlavors(AppleDescriptions.INCLUDE_FRAMEWORKS_FLAVOR).build(), "%s").resolve("TestLibrary.framework"));
Path libraryPath = frameworkPath.resolve("TestLibrary");
assertThat(Files.exists(libraryPath), is(true));
ProcessExecutor.Result lipoVerifyResult = workspace.runCommand("lipo", libraryPath.toString(), "-verify_arch", "i386", "x86_64");
assertEquals(lipoVerifyResult.getStderr().orElse(""), 0, lipoVerifyResult.getExitCode());
assertThat(workspace.runCommand("file", libraryPath.toString()).getStdout().get(), containsString("dynamically linked shared library"));
}
use of com.facebook.buck.testutil.integration.ProjectWorkspace in project buck by facebook.
the class AppleTestIntegrationTest method shouldRefuseToRunAppleTestIfXctestNotPresent.
@Test
public void shouldRefuseToRunAppleTestIfXctestNotPresent() throws IOException {
assumeTrue(Platform.detect() == Platform.MACOS);
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "apple_test_xctest", tmp);
workspace.setUp();
thrown.expect(HumanReadableException.class);
thrown.expectMessage(containsString("Set xctool_path = /path/to/xctool or xctool_zip_target = //path/to:xctool-zip in the " + "[apple] section of .buckconfig to run this test"));
workspace.runBuckCommand("test", "//:foo");
}
use of com.facebook.buck.testutil.integration.ProjectWorkspace in project buck by facebook.
the class AppleTestIntegrationTest method testLinkedAsMachOBundleWithNoDylibDeps.
@Test
public void testLinkedAsMachOBundleWithNoDylibDeps() throws Exception {
assumeTrue(Platform.detect() == Platform.MACOS);
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "apple_test_with_deps", tmp);
workspace.setUp();
BuildTarget buildTarget = workspace.newBuildTarget("//:foo");
workspace.runBuckCommand("build", buildTarget.getFullyQualifiedName()).assertSuccess();
workspace.verify(Paths.get("foo_output.expected"), BuildTargets.getGenPath(filesystem, BuildTarget.builder(buildTarget).addFlavors(AppleDebugFormat.DWARF.getFlavor()).addFlavors(AppleTestDescription.BUNDLE_FLAVOR).addFlavors(LinkerMapMode.NO_LINKER_MAP.getFlavor()).addFlavors(AppleDescriptions.NO_INCLUDE_FRAMEWORKS_FLAVOR).build(), "%s"));
Path projectRoot = Paths.get(tmp.getRoot().toFile().getCanonicalPath());
BuildTarget appleTestBundleFlavoredBuildTarget = buildTarget.withFlavors(InternalFlavor.of("apple-test-bundle"), AppleDebugFormat.DWARF.getFlavor(), LinkerMapMode.NO_LINKER_MAP.getFlavor(), AppleDescriptions.NO_INCLUDE_FRAMEWORKS_FLAVOR);
Path outputPath = projectRoot.resolve(BuildTargets.getGenPath(filesystem, appleTestBundleFlavoredBuildTarget, "%s"));
Path bundlePath = outputPath.resolve("foo.xctest");
Path testBinaryPath = bundlePath.resolve("foo");
ProcessExecutor.Result binaryFileTypeResult = workspace.runCommand("file", "-b", testBinaryPath.toString());
assertEquals(0, binaryFileTypeResult.getExitCode());
assertThat(binaryFileTypeResult.getStdout().orElse(""), containsString("Mach-O 64-bit bundle x86_64"));
ProcessExecutor.Result otoolResult = workspace.runCommand("otool", "-L", testBinaryPath.toString());
assertEquals(0, otoolResult.getExitCode());
assertThat(otoolResult.getStdout().orElse(""), containsString("foo"));
assertThat(otoolResult.getStdout().orElse(""), not(containsString("bar.dylib")));
ProcessExecutor.Result nmResult = workspace.runCommand("nm", "-j", testBinaryPath.toString());
assertEquals(0, nmResult.getExitCode());
assertThat(nmResult.getStdout().orElse(""), containsString("_OBJC_CLASS_$_Foo"));
assertThat(nmResult.getStdout().orElse(""), containsString("_OBJC_CLASS_$_Bar"));
}
use of com.facebook.buck.testutil.integration.ProjectWorkspace in project buck by facebook.
the class AppleTestIntegrationTest method successOnAppTestPassing.
@Test(timeout = 180000)
public void successOnAppTestPassing() throws IOException {
assumeTrue(Platform.detect() == Platform.MACOS);
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "apple_test_with_host_app", tmp);
workspace.setUp();
workspace.copyRecursively(TestDataHelper.getTestDataDirectory(this).resolve("fbxctest"), Paths.get("fbxctest"));
workspace.addBuckConfigLocalOption("apple", "xctool_path", "fbxctest/bin/fbxctest");
ProjectWorkspace.ProcessResult result = workspace.runBuckCommand("test", "//:AppTest");
result.assertSuccess();
assertThat(result.getStderr(), containsString("1 Passed 0 Skipped 0 Failed AppTest"));
}
Aggregations