Search in sources :

Example 36 with ProjectWorkspace

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));
}
Also used : Path(java.nio.file.Path) ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) FileSystem(java.nio.file.FileSystem) Test(org.junit.Test)

Example 37 with ProjectWorkspace

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());
}
Also used : Path(java.nio.file.Path) ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) Test(org.junit.Test)

Example 38 with ProjectWorkspace

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"));
}
Also used : Path(java.nio.file.Path) ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) BuildTarget(com.facebook.buck.model.BuildTarget) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) Test(org.junit.Test)

Example 39 with ProjectWorkspace

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"));
}
Also used : Path(java.nio.file.Path) ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) BuildTarget(com.facebook.buck.model.BuildTarget) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) Test(org.junit.Test)

Example 40 with ProjectWorkspace

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"));
}
Also used : Path(java.nio.file.Path) ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) BuildTarget(com.facebook.buck.model.BuildTarget) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) 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