Search in sources :

Example 61 with ProjectWorkspace

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

Example 62 with ProjectWorkspace

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

Example 63 with ProjectWorkspace

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

Example 64 with ProjectWorkspace

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

the class AppleTestIntegrationTest method successOnOsxLogicTestPassing.

@Test
public void successOnOsxLogicTestPassing() throws IOException {
    assumeTrue(Platform.detect() == Platform.MACOS);
    ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "apple_osx_logic_test", tmp);
    workspace.setUp();
    workspace.copyRecursively(TestDataHelper.getTestDataDirectory(this).resolve("fbxctest"), Paths.get("fbxctest"));
    ProjectWorkspace.ProcessResult result = workspace.runBuckCommand("test", "--config", "apple.xctool_path=fbxctest/bin/fbxctest", "//:LibTest");
    result.assertSuccess();
    assertThat(result.getStderr(), containsString("1 Passed   0 Skipped   0 Failed   LibTest"));
}
Also used : ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) Test(org.junit.Test)

Example 65 with ProjectWorkspace

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

the class AppleTestIntegrationTest method appleTestWithTestHostShouldSupportMultiarch.

@Test(timeout = 180000)
public void appleTestWithTestHostShouldSupportMultiarch() throws Exception {
    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"));
    BuildTarget target = BuildTargetFactory.newInstance("//:AppTest#iphonesimulator-i386,iphonesimulator-x86_64");
    ProjectWorkspace.ProcessResult result = workspace.runBuckCommand("test", "--config", "apple.xctool_path=fbxctest/bin/fbxctest", target.getFullyQualifiedName());
    result.assertSuccess();
    assertThat(result.getStderr(), containsString("1 Passed   0 Skipped   0 Failed   AppTest"));
    result = workspace.runBuckCommand("targets", "--show-output", target.getFullyQualifiedName());
    result.assertSuccess();
    Path output = workspace.getDestPath().resolve(Iterables.getLast(Splitter.on(' ').limit(2).split(result.getStdout().trim())));
    // check result is actually multiarch.
    ProcessExecutor.Result lipoVerifyResult = workspace.runCommand("lipo", output.resolve("AppTest").toString(), "-verify_arch", "i386", "x86_64");
    assertEquals(lipoVerifyResult.getStderr().orElse(""), 0, lipoVerifyResult.getExitCode());
}
Also used : Path(java.nio.file.Path) ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) BuildTarget(com.facebook.buck.model.BuildTarget) ProcessExecutor(com.facebook.buck.util.ProcessExecutor) 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