Search in sources :

Example 31 with ProjectWorkspace

use of com.facebook.buck.testutil.integration.ProjectWorkspace in project buck by facebook.

the class AppleSdkDiscoveryTest method overrideToolchains.

@Test
public void overrideToolchains() throws IOException {
    ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "sdk-discovery-minimal", temp);
    workspace.setUp();
    Path root = workspace.getPath("");
    String toolchainName1 = "toolchainoverride.1";
    String toolchainPath1 = "Toolchains/" + toolchainName1;
    AppleToolchain overrideToolchain1 = AppleToolchain.builder().setIdentifier(toolchainName1).setPath(root.resolve(toolchainPath1)).setVersion("1").build();
    String toolchainName2 = "toolchainoverride.2";
    String toolchainPath2 = "Toolchains/" + toolchainName2;
    AppleToolchain overrideToolchain2 = AppleToolchain.builder().setIdentifier(toolchainName2).setPath(root.resolve(toolchainPath2)).setVersion("1").build();
    ImmutableMap<String, AppleToolchain> allToolchains = ImmutableMap.of("com.apple.dt.toolchain.XcodeDefault", getDefaultToolchain(root), toolchainName1, overrideToolchain1, toolchainName2, overrideToolchain2);
    AppleSdk macosx109Sdk = AppleSdk.builder().setName("macosx10.9").setVersion("10.9").setApplePlatform(ApplePlatform.MACOSX).addArchitectures("i386", "x86_64").addAllToolchains(ImmutableList.of(overrideToolchain1, overrideToolchain2)).build();
    AppleSdkPaths macosx109Paths = AppleSdkPaths.builder().setDeveloperPath(root).addToolchainPaths(root.resolve(toolchainPath1), root.resolve(toolchainPath2)).setPlatformPath(root.resolve("Platforms/MacOSX.platform")).setSdkPath(root.resolve("Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk")).build();
    ImmutableMap<AppleSdk, AppleSdkPaths> expected = ImmutableMap.<AppleSdk, AppleSdkPaths>builder().put(macosx109Sdk, macosx109Paths).put(macosx109Sdk.withName("macosx"), macosx109Paths).build();
    AppleConfig fakeAppleConfig = new AppleConfig(FakeBuckConfig.builder().setSections("[apple]", "  macosx10.9_toolchains_override = " + toolchainName1 + "," + toolchainName2, "  macosx_toolchains_override = " + toolchainName1 + "," + toolchainName2).build());
    assertThat(AppleSdkDiscovery.discoverAppleSdkPaths(Optional.of(root), ImmutableList.of(root), allToolchains, fakeAppleConfig), equalTo(expected));
}
Also used : Path(java.nio.file.Path) ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) Test(org.junit.Test)

Example 32 with ProjectWorkspace

use of com.facebook.buck.testutil.integration.ProjectWorkspace in project buck by facebook.

the class AppleSdkDiscoveryTest method appleSdkPathsBuiltFromDirectory.

@Test
public void appleSdkPathsBuiltFromDirectory() throws Exception {
    ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "sdk-discovery", temp);
    workspace.setUp();
    Path root = workspace.getPath("");
    createSymLinkIosSdks(root, "8.0");
    createSymLinkWatchosSdks(root, "2.0");
    createSymLinkAppletvosSdks(root, "9.1");
    AppleSdk macosx109Sdk = AppleSdk.builder().setName("macosx10.9").setVersion("10.9").setApplePlatform(ApplePlatform.MACOSX).addArchitectures("i386", "x86_64").addToolchains(getDefaultToolchain(root)).build();
    AppleSdkPaths macosx109Paths = AppleSdkPaths.builder().setDeveloperPath(root).addToolchainPaths(root.resolve("Toolchains/XcodeDefault.xctoolchain")).setPlatformPath(root.resolve("Platforms/MacOSX.platform")).setSdkPath(root.resolve("Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk")).build();
    AppleSdk iphoneos80Sdk = AppleSdk.builder().setName("iphoneos8.0").setVersion("8.0").setApplePlatform(ApplePlatform.IPHONEOS).addArchitectures("armv7", "arm64").addToolchains(getDefaultToolchain(root)).build();
    AppleSdkPaths iphoneos80Paths = AppleSdkPaths.builder().setDeveloperPath(root).addToolchainPaths(root.resolve("Toolchains/XcodeDefault.xctoolchain")).setPlatformPath(root.resolve("Platforms/iPhoneOS.platform")).setSdkPath(root.resolve("Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk")).build();
    AppleSdk iphonesimulator80Sdk = AppleSdk.builder().setName("iphonesimulator8.0").setVersion("8.0").setApplePlatform(ApplePlatform.IPHONESIMULATOR).addArchitectures("i386", "x86_64").addToolchains(getDefaultToolchain(root)).build();
    AppleSdkPaths iphonesimulator80Paths = AppleSdkPaths.builder().setDeveloperPath(root).addToolchainPaths(root.resolve("Toolchains/XcodeDefault.xctoolchain")).setPlatformPath(root.resolve("Platforms/iPhoneSimulator.platform")).setSdkPath(root.resolve("Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk")).build();
    AppleSdk watchos20Sdk = AppleSdk.builder().setName("watchos2.0").setVersion("2.0").setApplePlatform(ApplePlatform.WATCHOS).addArchitectures("armv7k").addToolchains(getDefaultToolchain(root)).build();
    AppleSdkPaths watchos20Paths = AppleSdkPaths.builder().setDeveloperPath(root).addToolchainPaths(root.resolve("Toolchains/XcodeDefault.xctoolchain")).setPlatformPath(root.resolve("Platforms/WatchOS.platform")).setSdkPath(root.resolve("Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk")).build();
    AppleSdk watchsimulator20Sdk = AppleSdk.builder().setName("watchsimulator2.0").setVersion("2.0").setApplePlatform(ApplePlatform.WATCHSIMULATOR).addArchitectures("i386").addToolchains(getDefaultToolchain(root)).build();
    AppleSdkPaths watchsimulator20Paths = AppleSdkPaths.builder().setDeveloperPath(root).addToolchainPaths(root.resolve("Toolchains/XcodeDefault.xctoolchain")).setPlatformPath(root.resolve("Platforms/WatchSimulator.platform")).setSdkPath(root.resolve("Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator.sdk")).build();
    AppleSdk appletvos91Sdk = AppleSdk.builder().setName("appletvos9.1").setVersion("9.1").setApplePlatform(ApplePlatform.APPLETVOS).addArchitectures("arm64").addToolchains(getDefaultToolchain(root)).build();
    AppleSdkPaths appletvos91Paths = AppleSdkPaths.builder().setDeveloperPath(root).addToolchainPaths(root.resolve("Toolchains/XcodeDefault.xctoolchain")).setPlatformPath(root.resolve("Platforms/AppleTVOS.platform")).setSdkPath(root.resolve("Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk")).build();
    AppleSdk appletvsimulator91Sdk = AppleSdk.builder().setName("appletvsimulator9.1").setVersion("9.1").setApplePlatform(ApplePlatform.APPLETVSIMULATOR).addArchitectures("x86_64").addToolchains(getDefaultToolchain(root)).build();
    AppleSdkPaths appletvsimulator91Paths = AppleSdkPaths.builder().setDeveloperPath(root).addToolchainPaths(root.resolve("Toolchains/XcodeDefault.xctoolchain")).setPlatformPath(root.resolve("Platforms/AppleTVSimulator.platform")).setSdkPath(root.resolve("Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator.sdk")).build();
    ImmutableMap<String, AppleToolchain> toolchains = ImmutableMap.of("com.apple.dt.toolchain.XcodeDefault", getDefaultToolchain(root));
    ImmutableMap<AppleSdk, AppleSdkPaths> expected = ImmutableMap.<AppleSdk, AppleSdkPaths>builder().put(macosx109Sdk, macosx109Paths).put(macosx109Sdk.withName("macosx"), macosx109Paths).put(iphoneos80Sdk, iphoneos80Paths).put(iphoneos80Sdk.withName("iphoneos"), iphoneos80Paths).put(iphonesimulator80Sdk, iphonesimulator80Paths).put(iphonesimulator80Sdk.withName("iphonesimulator"), iphonesimulator80Paths).put(watchos20Sdk, watchos20Paths).put(watchos20Sdk.withName("watchos"), watchos20Paths).put(watchsimulator20Sdk, watchsimulator20Paths).put(watchsimulator20Sdk.withName("watchsimulator"), watchsimulator20Paths).put(appletvos91Sdk, appletvos91Paths).put(appletvos91Sdk.withName("appletvos"), appletvos91Paths).put(appletvsimulator91Sdk, appletvsimulator91Paths).put(appletvsimulator91Sdk.withName("appletvsimulator"), appletvsimulator91Paths).build();
    assertThat(AppleSdkDiscovery.discoverAppleSdkPaths(Optional.of(root), ImmutableList.of(), toolchains, new FakeAppleConfig()), equalTo(expected));
}
Also used : Path(java.nio.file.Path) ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) Test(org.junit.Test)

Example 33 with ProjectWorkspace

use of com.facebook.buck.testutil.integration.ProjectWorkspace in project buck by facebook.

the class AppleSdkDiscoveryTest method ignoresInvalidExtraPlatformDirectories.

@Test
public void ignoresInvalidExtraPlatformDirectories() throws IOException {
    ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "sdk-discovery-minimal", temp);
    workspace.setUp();
    Path root = workspace.getPath("");
    Path path = Paths.get("invalid");
    ImmutableMap<String, AppleToolchain> toolchains = ImmutableMap.of("com.apple.dt.toolchain.XcodeDefault", getDefaultToolchain(root));
    AppleSdk macosx109Sdk = AppleSdk.builder().setName("macosx10.9").setVersion("10.9").setApplePlatform(ApplePlatform.MACOSX).addArchitectures("i386", "x86_64").addAllToolchains(toolchains.values()).build();
    AppleSdkPaths macosx109Paths = AppleSdkPaths.builder().setDeveloperPath(root).addToolchainPaths(root.resolve("Toolchains/XcodeDefault.xctoolchain")).setPlatformPath(root.resolve("Platforms/MacOSX.platform")).setSdkPath(root.resolve("Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk")).build();
    ImmutableMap<AppleSdk, AppleSdkPaths> expected = ImmutableMap.<AppleSdk, AppleSdkPaths>builder().put(macosx109Sdk, macosx109Paths).put(macosx109Sdk.withName("macosx"), macosx109Paths).build();
    assertThat(AppleSdkDiscovery.discoverAppleSdkPaths(Optional.of(root), ImmutableList.of(path), toolchains, new FakeAppleConfig()), equalTo(expected));
}
Also used : Path(java.nio.file.Path) ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) Test(org.junit.Test)

Example 34 with ProjectWorkspace

use of com.facebook.buck.testutil.integration.ProjectWorkspace in project buck by facebook.

the class AppleSdkDiscoveryTest method noAppleSdksFoundIfDefaultPlatformMissing.

@Test
public void noAppleSdksFoundIfDefaultPlatformMissing() throws Exception {
    ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "sdk-discovery", temp);
    workspace.setUp();
    Path root = workspace.getPath("");
    ImmutableMap<String, AppleToolchain> toolchains = ImmutableMap.of();
    assertThat(AppleSdkDiscovery.discoverAppleSdkPaths(Optional.of(root), ImmutableList.of(), toolchains, new FakeAppleConfig()).entrySet(), empty());
}
Also used : Path(java.nio.file.Path) ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) Test(org.junit.Test)

Example 35 with ProjectWorkspace

use of com.facebook.buck.testutil.integration.ProjectWorkspace in project buck by facebook.

the class AppleSdkDiscoveryTest method shouldDiscoverRealSdkThroughAbsoluteSymlink.

@Test
public void shouldDiscoverRealSdkThroughAbsoluteSymlink() throws IOException {
    ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "sdk-discovery-symlink", temp);
    workspace.setUp();
    Path root = workspace.getPath("");
    Path actualSdkPath = root.resolve("MacOSX10.9.sdk");
    Path sdksDir = root.resolve("Platforms/MacOSX.platform/Developer/SDKs");
    Files.createDirectories(sdksDir);
    Files.createSymbolicLink(sdksDir.resolve("MacOSX10.9.sdk"), actualSdkPath);
    ImmutableMap<String, AppleToolchain> toolchains = ImmutableMap.of("com.apple.dt.toolchain.XcodeDefault", getDefaultToolchain(root));
    AppleSdk macosx109Sdk = AppleSdk.builder().setName("macosx10.9").setVersion("10.9").setApplePlatform(ApplePlatform.MACOSX).addArchitectures("i386", "x86_64").addAllToolchains(toolchains.values()).build();
    AppleSdkPaths macosx109Paths = AppleSdkPaths.builder().setDeveloperPath(root).addToolchainPaths(root.resolve("Toolchains/XcodeDefault.xctoolchain")).setPlatformPath(root.resolve("Platforms/MacOSX.platform")).setSdkPath(actualSdkPath).build();
    ImmutableMap<AppleSdk, AppleSdkPaths> expected = ImmutableMap.<AppleSdk, AppleSdkPaths>builder().put(macosx109Sdk, macosx109Paths).put(macosx109Sdk.withName("macosx"), macosx109Paths).build();
    assertThat(AppleSdkDiscovery.discoverAppleSdkPaths(Optional.of(root), ImmutableList.of(root), toolchains, new FakeAppleConfig()), equalTo(expected));
}
Also used : Path(java.nio.file.Path) ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) Test(org.junit.Test)

Aggregations

ProjectWorkspace (com.facebook.buck.testutil.integration.ProjectWorkspace)747 Test (org.junit.Test)726 Path (java.nio.file.Path)219 BuildTarget (com.facebook.buck.model.BuildTarget)177 ProcessResult (com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult)127 ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)89 Matchers.containsString (org.hamcrest.Matchers.containsString)50 BuckBuildLog (com.facebook.buck.testutil.integration.BuckBuildLog)47 ProcessExecutor (com.facebook.buck.util.ProcessExecutor)35 ZipInspector (com.facebook.buck.testutil.integration.ZipInspector)21 HumanReadableException (com.facebook.buck.util.HumanReadableException)14 OcamlRuleBuilder.createStaticLibraryBuildTarget (com.facebook.buck.ocaml.OcamlRuleBuilder.createStaticLibraryBuildTarget)13 TestConsole (com.facebook.buck.testutil.TestConsole)12 FakeProjectFilesystem (com.facebook.buck.testutil.FakeProjectFilesystem)10 DefaultProcessExecutor (com.facebook.buck.util.DefaultProcessExecutor)10 Cell (com.facebook.buck.rules.Cell)9 TestContext (com.facebook.buck.testutil.integration.TestContext)9 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)9 MappedByteBuffer (java.nio.MappedByteBuffer)9 FileChannel (java.nio.channels.FileChannel)9