use of com.facebook.buck.testutil.integration.ProjectWorkspace in project buck by facebook.
the class AppleSdkDiscoveryTest method shouldScanRealDirectoryOnlyOnce.
@Test
public void shouldScanRealDirectoryOnlyOnce() throws IOException {
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "sdk-discovery-symlink", temp);
workspace.setUp();
Path root = workspace.getPath("");
FileSystem fileSystem = root.getFileSystem();
Path actualSdkPath = root.resolve("MacOSX10.9.sdk");
Path sdksDir = root.resolve("Platforms/MacOSX.platform/Developer/SDKs");
Files.createDirectories(sdksDir);
// create relative symlink
Files.createSymbolicLink(sdksDir.resolve("MacOSX10.9.sdk"), fileSystem.getPath("MacOSX.sdk"));
// create absolute symlink
Files.createSymbolicLink(sdksDir.resolve("MacOSX.sdk"), actualSdkPath);
ImmutableMap<String, AppleToolchain> toolchains = ImmutableMap.of("com.apple.dt.toolchain.XcodeDefault", getDefaultToolchain(root));
ImmutableMap<AppleSdk, AppleSdkPaths> actual = AppleSdkDiscovery.discoverAppleSdkPaths(Optional.of(root), ImmutableList.of(root), toolchains, new FakeAppleConfig());
// if both symlinks were to be visited, exception would have been thrown during discovery
assertThat(actual.size(), is(2));
}
use of com.facebook.buck.testutil.integration.ProjectWorkspace in project buck by facebook.
the class AppleSdkDiscoveryTest method shouldReturnAnEmptyMapIfNoPlatformsFound.
@Test
public void shouldReturnAnEmptyMapIfNoPlatformsFound() throws IOException {
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "sdk-discovery-empty", temp);
workspace.setUp();
Path path = workspace.getPath("");
ImmutableMap<String, AppleToolchain> toolchains = ImmutableMap.of("com.apple.dt.toolchain.XcodeDefault", getDefaultToolchain(path));
ImmutableMap<AppleSdk, AppleSdkPaths> sdks = AppleSdkDiscovery.discoverAppleSdkPaths(Optional.of(path), ImmutableList.of(), toolchains, new FakeAppleConfig());
assertEquals(0, sdks.size());
}
use of com.facebook.buck.testutil.integration.ProjectWorkspace in project buck by facebook.
the class AppleLibraryIntegrationTest method testAppleLibraryBuildsFrameworkIOS.
@Test
public void testAppleLibraryBuildsFrameworkIOS() throws Exception {
assumeTrue(Platform.detect() == Platform.MACOS);
assumeTrue(AppleNativeIntegrationTestUtils.isApplePlatformAvailable(ApplePlatform.IPHONESIMULATOR));
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#framework,iphonesimulator-x86_64,no-debug");
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"));
assertThat(Files.exists(frameworkPath), is(true));
assertThat(Files.exists(frameworkPath.resolve("Info.plist")), is(true));
Path libraryPath = frameworkPath.resolve("TestLibrary");
assertThat(Files.exists(libraryPath), is(true));
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 AppleLibraryIntegrationTest method frameworkContainsFrameworkDependencies.
@Test
public void frameworkContainsFrameworkDependencies() throws Exception {
assumeTrue(Platform.detect() == Platform.MACOS);
assumeTrue(AppleNativeIntegrationTestUtils.isApplePlatformAvailable(ApplePlatform.MACOSX));
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "apple_library_with_library_dependencies", tmp);
workspace.setUp();
ProjectFilesystem filesystem = new ProjectFilesystem(workspace.getDestPath());
BuildTarget target = BuildTargetFactory.newInstance("//Libraries/TestLibrary:TestLibrary#framework,macosx-x86_64");
ProjectWorkspace.ProcessResult result = workspace.runBuckCommand("build", target.getFullyQualifiedName());
result.assertSuccess();
Path frameworkPath = workspace.getPath(BuildTargets.getGenPath(filesystem, BuildTarget.builder(target).addFlavors(AppleDebugFormat.DWARF.getFlavor()).addFlavors(AppleDescriptions.INCLUDE_FRAMEWORKS_FLAVOR).build(), "%s").resolve("TestLibrary.framework"));
assertThat(Files.exists(frameworkPath), is(true));
Path frameworksPath = frameworkPath.resolve("Frameworks");
assertThat(Files.exists(frameworksPath), is(true));
Path depPath = frameworksPath.resolve("TestLibraryDep.framework/TestLibraryDep");
assertThat(Files.exists(depPath), is(true));
assertThat(workspace.runCommand("file", depPath.toString()).getStdout().get(), containsString("dynamically linked shared library"));
Path transitiveDepPath = frameworksPath.resolve("TestLibraryTransitiveDep.framework/TestLibraryTransitiveDep");
assertThat(Files.exists(transitiveDepPath), is(true));
assertThat(workspace.runCommand("file", transitiveDepPath.toString()).getStdout().get(), containsString("dynamically linked shared library"));
}
use of com.facebook.buck.testutil.integration.ProjectWorkspace in project buck by facebook.
the class AppleLibraryIntegrationTest method testBuildAppleLibraryThatHasSwift.
@Test
public void testBuildAppleLibraryThatHasSwift() throws Exception {
assumeTrue(Platform.detect() == Platform.MACOS);
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "empty_source_targets", tmp);
workspace.setUp();
BuildTarget target = workspace.newBuildTarget("//:none-swift#iphonesimulator-x86_64").withAppendedFlavors(CxxDescriptionEnhancer.SHARED_FLAVOR);
ProjectWorkspace.ProcessResult result = workspace.runBuckCommand("build", target.getFullyQualifiedName());
result.assertSuccess();
ProjectFilesystem filesystem = new ProjectFilesystem(workspace.getDestPath());
Path binaryOutput = workspace.getPath(BuildTargets.getGenPath(filesystem, target, "%s/libnone-swift.dylib"));
assertThat(Files.exists(binaryOutput), is(true));
assertThat(workspace.runCommand("otool", "-L", binaryOutput.toString()).getStdout().get(), containsString("libswiftCore.dylib"));
}
Aggregations