Search in sources :

Example 96 with ProcessResult

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

the class DefaultJavaLibraryIntegrationTest method testClassUsageFileOutputProperly.

@Test
public void testClassUsageFileOutputProperly() throws IOException {
    workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "class_usage_file", tmp);
    workspace.setUp();
    // Run `buck build`.
    BuildTarget bizTarget = BuildTargetFactory.newInstance("//:biz");
    ProcessResult buildResult = workspace.runBuckCommand("build", bizTarget.getFullyQualifiedName());
    buildResult.assertSuccess("Successful build should exit with 0.");
    Path bizClassUsageFilePath = BuildTargets.getGenPath(filesystem, bizTarget, "lib__%s__output/used-classes.json");
    final List<String> lines = Files.readAllLines(workspace.getPath(bizClassUsageFilePath), UTF_8);
    assertEquals("Expected just one line of JSON", 1, lines.size());
    final String utilJarPath = MorePaths.pathWithPlatformSeparators("buck-out/gen/lib__util__output/util.jar");
    final String utilClassPath = MorePaths.pathWithPlatformSeparators("com/example/Util.class");
    ObjectMapper objectMapper = ObjectMappers.newDefaultInstance();
    JsonNode jsonNode = objectMapper.readTree(lines.get(0));
    assertThat(jsonNode, new HasJsonField(objectMapper, utilJarPath, Matchers.equalTo(objectMapper.valueToTree(new String[] { utilClassPath }))));
}
Also used : Path(java.nio.file.Path) BuildTarget(com.facebook.buck.model.BuildTarget) HasJsonField(com.facebook.buck.json.HasJsonField) ProcessResult(com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult) JsonNode(com.fasterxml.jackson.databind.JsonNode) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 97 with ProcessResult

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

the class AndroidBinaryFlavorsIntegrationTest method testPackageStringAssetsFlavorOutput.

@Test
public void testPackageStringAssetsFlavorOutput() throws IOException {
    String target = "//apps/sample:app_comp_str#package_string_assets";
    ProjectFilesystem filesystem = new FakeProjectFilesystem();
    ProcessResult result = workspace.runBuckCommand("targets", "--show-output", target);
    Path path = BuildTargets.getScratchPath(filesystem, BuildTargetFactory.newInstance(target), PackageStringAssets.STRING_ASSETS_DIR_FORMAT);
    result.assertSuccess();
    assertThat(result.getStdout().trim().split(" ")[1], equalTo(path.toString()));
}
Also used : Path(java.nio.file.Path) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) ProcessResult(com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) Test(org.junit.Test)

Example 98 with ProcessResult

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

the class AndroidBinaryFlavorsIntegrationTest method testPackageStringsOnlyFlavorOutput.

@Test
public void testPackageStringsOnlyFlavorOutput() throws IOException {
    String target = "//apps/sample:app_str#package_string_assets";
    ProjectFilesystem filesystem = new FakeProjectFilesystem();
    ProcessResult result = workspace.runBuckCommand("targets", "--show-output", target);
    Path path = BuildTargets.getScratchPath(filesystem, BuildTargetFactory.newInstance(target), PackageStringAssets.STRING_ASSETS_DIR_FORMAT);
    result.assertSuccess();
    assertThat(result.getStdout().trim().split(" ")[1], equalTo(path.toString()));
}
Also used : Path(java.nio.file.Path) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) ProcessResult(com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) Test(org.junit.Test)

Example 99 with ProcessResult

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

the class AndroidLibraryIntegrationTest method testAndroidKotlinBinaryDoesNotUseTransitiveResources.

@Test
public void testAndroidKotlinBinaryDoesNotUseTransitiveResources() throws IOException {
    AssumeAndroidPlatform.assumeSdkIsAvailable();
    KotlinTestAssumptions.assumeCompilerAvailable();
    ProcessResult result = workspace.runBuckBuild("//kotlin/com/sample/lib:lib_using_transitive_empty_res");
    result.assertFailure();
    assertTrue(result.getStderr().contains("unresolved reference: R"));
}
Also used : ProcessResult(com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult) Test(org.junit.Test)

Example 100 with ProcessResult

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

the class AndroidLibraryIntegrationTest method testAndroidScalaLibraryDoesNotUseTransitiveResources.

@Test(timeout = (3 * 60 * 1000))
public void testAndroidScalaLibraryDoesNotUseTransitiveResources() throws IOException {
    AssumeAndroidPlatform.assumeSdkIsAvailable();
    ProcessResult result = workspace.runBuckBuild("//scala/com/sample/lib:lib_using_transitive_empty_res");
    result.assertFailure();
    assertTrue(result.getStderr().contains("not found: value R"));
}
Also used : ProcessResult(com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult) Test(org.junit.Test)

Aggregations

ProcessResult (com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult)175 Test (org.junit.Test)174 ProjectWorkspace (com.facebook.buck.testutil.integration.ProjectWorkspace)127 Path (java.nio.file.Path)21 Matchers.containsString (org.hamcrest.Matchers.containsString)20 BuildTarget (com.facebook.buck.model.BuildTarget)17 JsonNode (com.fasterxml.jackson.databind.JsonNode)8 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)8 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)6 TestContext (com.facebook.buck.testutil.integration.TestContext)4 ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)3 ZipInspector (com.facebook.buck.testutil.integration.ZipInspector)3 ZipFile (java.util.zip.ZipFile)3 FakeProjectFilesystem (com.facebook.buck.testutil.FakeProjectFilesystem)2 DelegatingInputStream (com.facebook.buck.testutil.integration.DelegatingInputStream)2 CapturingPrintStream (com.facebook.buck.util.CapturingPrintStream)2 File (java.io.File)2 Charset (java.nio.charset.Charset)2 FileTime (java.nio.file.attribute.FileTime)2 ArtifactCache (com.facebook.buck.artifact_cache.ArtifactCache)1