Search in sources :

Example 11 with ProjectWorkspace

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

the class AppleBinaryIntegrationTest method testAppleXcodeError.

@Test
public void testAppleXcodeError() throws IOException {
    assumeTrue(Platform.detect() == Platform.MACOS);
    String expectedError = "Apps/TestApp/main.c:2:3: error: use of undeclared identifier 'SomeType'\n" + "  SomeType a;\n" + "  ^\n";
    String expectedWarning = "Apps/TestApp/main.c:3:10: warning: implicit conversion from 'double' to 'int' changes " + "value from 0.42 to 0 [-Wliteral-conversion]\n" + "  return 0.42;\n" + "  ~~~~~~ ^~~~\n";
    String expectedSummary = "1 warning and 1 error generated.\n";
    ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "apple_xcode_error", tmp);
    workspace.setUp();
    ProjectWorkspace.ProcessResult buildResult = workspace.runBuckCommand("build", "//Apps/TestApp:TestApp");
    buildResult.assertFailure();
    String stderr = buildResult.getStderr();
    assertTrue(stderr.contains(expectedError) && stderr.contains(expectedWarning) && stderr.contains(expectedSummary));
}
Also used : ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 12 with ProjectWorkspace

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

the class AppleBinaryIntegrationTest method testFlavoredAppleBundleBuildsWithDwarfDebugFormatAndBinaryIsUnstripped.

@Test
public void testFlavoredAppleBundleBuildsWithDwarfDebugFormatAndBinaryIsUnstripped() throws Exception {
    assumeTrue(Platform.detect() == Platform.MACOS);
    ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "simple_application_bundle_dwarf_and_dsym", tmp);
    workspace.setUp();
    BuildTarget target = BuildTargetFactory.newInstance("//:DemoApp#dwarf");
    workspace.runBuckCommand("build", target.getFullyQualifiedName()).assertSuccess();
    BuildTarget appTarget = target.withFlavors(AppleDebugFormat.DWARF.getFlavor(), AppleDescriptions.NO_INCLUDE_FRAMEWORKS_FLAVOR);
    Path output = workspace.getPath(BuildTargets.getGenPath(filesystem, appTarget, "%s").resolve(target.getShortName() + ".app").resolve(target.getShortName()));
    assertThat(Files.exists(output), equalTo(true));
    ProcessExecutor.Result hasSymbol = workspace.runCommand("nm", output.toString());
    String stdout = hasSymbol.getStdout().orElse("");
    assertThat(stdout, containsString("t -[AppDelegate window]"));
    assertThat(stdout, containsString("U _UIApplicationMain"));
}
Also used : Path(java.nio.file.Path) ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) BuildTarget(com.facebook.buck.model.BuildTarget) Matchers.containsString(org.hamcrest.Matchers.containsString) ProcessExecutor(com.facebook.buck.util.ProcessExecutor) Test(org.junit.Test)

Example 13 with ProjectWorkspace

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

the class AppleBinaryIntegrationTest method testAppleBinaryUsesDefaultsFromArgs.

@Test
public void testAppleBinaryUsesDefaultsFromArgs() throws Exception {
    assumeTrue(Platform.detect() == Platform.MACOS);
    ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "apple_binary_with_platform", tmp);
    workspace.setUp();
    BuildTarget target = BuildTargetFactory.newInstance("//Apps/TestApp:TestApp").withAppendedFlavors(InternalFlavor.of("iphoneos-arm64"));
    workspace.runBuckCommand("build", target.getFullyQualifiedName()).assertSuccess();
    Path outputPath = workspace.getPath(BuildTargets.getGenPath(filesystem, target, "%s"));
    assertThat(Files.exists(outputPath), is(true));
    assertThat(Files.exists(Paths.get(outputPath.toString() + "-LinkMap.txt")), is(true));
    assertThat(workspace.runCommand("file", outputPath.toString()).getStdout().get(), containsString("executable"));
    assertThat(workspace.runCommand("otool", "-hv", outputPath.toString()).getStdout().get(), containsString("ARM64"));
}
Also used : Path(java.nio.file.Path) ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) BuildTarget(com.facebook.buck.model.BuildTarget) Test(org.junit.Test)

Example 14 with ProjectWorkspace

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

the class AppleBinaryIntegrationTest method testAppleBinaryBuildsBinaryWithoutLinkerMap.

@Test
public void testAppleBinaryBuildsBinaryWithoutLinkerMap() throws Exception {
    assumeTrue(Platform.detect() == Platform.MACOS);
    ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "apple_binary_builds_something", tmp);
    workspace.setUp();
    BuildTarget target = BuildTargetFactory.newInstance("//Apps/TestApp:TestApp").withFlavors(LinkerMapMode.NO_LINKER_MAP.getFlavor());
    workspace.runBuckCommand("build", target.getFullyQualifiedName()).assertSuccess();
    Path outputPath = workspace.getPath(BuildTargets.getGenPath(filesystem, target, "%s"));
    assertThat(Files.exists(outputPath), is(true));
    assertThat(Files.exists(Paths.get(outputPath.toString() + "-LinkMap.txt")), is(false));
    assertThat(workspace.runCommand("file", outputPath.toString()).getStdout().get(), containsString("executable"));
}
Also used : Path(java.nio.file.Path) ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) BuildTarget(com.facebook.buck.model.BuildTarget) Test(org.junit.Test)

Example 15 with ProjectWorkspace

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

the class MultipleBuildConfigIntegrationTest method testAndroidBinarySupportsMultipleBuildConfigs.

/**
   * Regression test for https://github.com/facebook/buck/issues/187.
   */
@Test
public void testAndroidBinarySupportsMultipleBuildConfigs() throws IOException {
    AssumeAndroidPlatform.assumeSdkIsAvailable();
    ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "android_project", tmp);
    workspace.setUp();
    Path outputFile = workspace.buildAndReturnOutput("//java/com/buildconfigs:extract-classes-dex");
    String smali = new String(Files.readAllBytes(outputFile), UTF_8);
    assertThat(smali, containsString(Paths.get("com/example/config1/BuildConfig.smali").toString()));
    assertThat(smali, containsString(Paths.get("com/example/config2/BuildConfig.smali").toString()));
}
Also used : Path(java.nio.file.Path) ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) Matchers.containsString(org.hamcrest.Matchers.containsString) 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