Search in sources :

Example 41 with ProjectWorkspace

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

the class AppleLibraryIntegrationTest method testAppleLibraryBuildsSomething.

@Test
public void testAppleLibraryBuildsSomething() throws IOException {
    assumeTrue(Platform.detect() == Platform.MACOS);
    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#static,default");
    ProjectWorkspace.ProcessResult result = workspace.runBuckCommand("build", target.getFullyQualifiedName());
    result.assertSuccess();
    assertTrue(Files.exists(workspace.getPath(BuildTargets.getGenPath(filesystem, target, "%s"))));
}
Also used : ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) BuildTarget(com.facebook.buck.model.BuildTarget) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) Test(org.junit.Test)

Example 42 with ProjectWorkspace

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

the class AppleLibraryIntegrationTest method testBuildEmptySourceAppleLibrary.

@Test
public void testBuildEmptySourceAppleLibrary() throws Exception {
    assumeTrue(Platform.detect() == Platform.MACOS);
    ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "empty_source_targets", tmp);
    workspace.setUp();
    BuildTarget target = workspace.newBuildTarget("//:real-none#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/libreal-none.dylib"));
    assertThat(Files.exists(binaryOutput), is(true));
}
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 43 with ProjectWorkspace

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

the class AppleTestIntegrationTest method exitCodeIsCorrectOnAppTestFailure.

@Test(timeout = 180000)
public void exitCodeIsCorrectOnAppTestFailure() throws IOException {
    assumeTrue(Platform.detect() == Platform.MACOS);
    ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "apple_test_with_host_app_failure", 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", "--config", "apple.xctool_path=fbxctest/bin/fbxctest", "//:AppTest");
    result.assertSpecialExitCode("test should fail", 42);
    assertThat(result.getStderr(), containsString("0 Passed   0 Skipped   1 Failed   AppTest"));
    assertThat(result.getStderr(), matchesPattern("(?s).*FAILURE AppTest -\\[AppTest testMagicValueShouldFail\\]:.*AppTest\\.m:13.*"));
}
Also used : ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) Test(org.junit.Test)

Example 44 with ProjectWorkspace

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

the class AppleTestIntegrationTest method testWithHostAppWithDsym.

@Test(timeout = 180000)
public void testWithHostAppWithDsym() throws IOException, InterruptedException {
    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", "--config", "cxx.cflags=-g", "--config", "apple.default_debug_info_format_for_binaries=DWARF_AND_DSYM", "--config", "apple.default_debug_info_format_for_libraries=DWARF_AND_DSYM", "--config", "apple.default_debug_info_format_for_tests=DWARF_AND_DSYM");
    result.assertSuccess();
    assertThat(result.getStderr(), containsString("1 Passed   0 Skipped   0 Failed   AppTest"));
    Path appTestDsym = tmp.getRoot().resolve(filesystem.getBuckPaths().getGenDir()).resolve("AppTest#apple-test-bundle,dwarf-and-dsym,no-include-frameworks,no-linkermap").resolve("AppTest.xctest.dSYM");
    AppleDsymTestUtil.checkDsymFileHasDebugSymbol("-[AppTest testMagicValue]", workspace, appTestDsym);
    Path hostAppDsym = tmp.getRoot().resolve(filesystem.getBuckPaths().getGenDir()).resolve("TestHostApp#dwarf-and-dsym,no-include-frameworks").resolve("TestHostApp.app.dSYM");
    AppleDsymTestUtil.checkDsymFileHasDebugSymbol("-[TestHostApp magicValue]", workspace, hostAppDsym);
}
Also used : Path(java.nio.file.Path) ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) Test(org.junit.Test)

Example 45 with ProjectWorkspace

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

the class AppleTestIntegrationTest method appleTestWithoutTestHostMultiarchShouldHaveMultiarchDsym.

@Test
public void appleTestWithoutTestHostMultiarchShouldHaveMultiarchDsym() throws Exception {
    assumeTrue(Platform.detect() == Platform.MACOS);
    ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "apple_test_xctest", tmp);
    workspace.setUp();
    workspace.copyRecursively(TestDataHelper.getTestDataDirectory(this).resolve("fbxctest"), Paths.get("fbxctest"));
    BuildTarget target = BuildTargetFactory.newInstance("//:foo#iphonesimulator-i386,iphonesimulator-x86_64");
    ProjectWorkspace.ProcessResult result = workspace.runBuckCommand("build", "--config", "cxx.cflags=-g", "--config", "apple.xctool_path=fbxctest/bin/fbxctest", "--config", "apple.default_debug_info_format_for_binaries=DWARF_AND_DSYM", "--config", "apple.default_debug_info_format_for_libraries=DWARF_AND_DSYM", "--config", "apple.default_debug_info_format_for_tests=DWARF_AND_DSYM", target.getFullyQualifiedName());
    result.assertSuccess();
    BuildTarget libraryTarget = target.withAppendedFlavors(AppleTestDescription.LIBRARY_FLAVOR, CxxDescriptionEnhancer.MACH_O_BUNDLE_FLAVOR);
    Path output = workspace.getDestPath().resolve(BuildTargets.getGenPath(filesystem, libraryTarget.withAppendedFlavors(AppleDsym.RULE_FLAVOR), "%s.dSYM")).resolve("Contents/Resources/DWARF/" + libraryTarget.getShortName());
    ProcessExecutor.Result lipoVerifyResult = workspace.runCommand("lipo", output.toString(), "-verify_arch", "i386", "x86_64");
    assertEquals(lipoVerifyResult.getStderr().orElse(""), 0, lipoVerifyResult.getExitCode());
    AppleDsymTestUtil.checkDsymFileHasDebugSymbolForConcreteArchitectures("-[FooXCTest testTwoPlusTwoEqualsFour]", workspace, output, Optional.of(ImmutableList.of("i386", "x86_64")));
}
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