Search in sources :

Example 16 with ZipInspector

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

the class AndroidReactNativeLibraryIntegrationTest method testApkContainsJSAssetAndDrawables.

@Test
public void testApkContainsJSAssetAndDrawables() throws IOException {
    BuildTarget target = BuildTargetFactory.newInstance("//apps/sample:app");
    workspace.runBuckBuild(target.getFullyQualifiedName()).assertSuccess();
    ZipInspector zipInspector = new ZipInspector(workspace.getPath(BuildTargets.getGenPath(filesystem, target, "%s.apk")));
    zipInspector.assertFileExists("assets/SampleBundle.js");
    zipInspector.assertFileExists("res/drawable-mdpi-v4/image.png");
    zipInspector.assertFileExists("res/drawable-hdpi-v4/image.png");
    zipInspector.assertFileExists("res/drawable-xhdpi-v4/image.png");
}
Also used : BuildTarget(com.facebook.buck.model.BuildTarget) ZipInspector(com.facebook.buck.testutil.integration.ZipInspector) Test(org.junit.Test)

Example 17 with ZipInspector

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

the class AndroidReactNativeLibraryIntegrationTest method testApkContainsJSAssetAndDrawablesForUnbundle.

@Test
public void testApkContainsJSAssetAndDrawablesForUnbundle() throws IOException {
    BuildTarget target = BuildTargetFactory.newInstance("//apps/sample:app-unbundle");
    workspace.runBuckBuild(target.getFullyQualifiedName()).assertSuccess();
    ZipInspector zipInspector = new ZipInspector(workspace.getPath(BuildTargets.getGenPath(filesystem, target, "%s.apk")));
    zipInspector.assertFileExists("assets/SampleBundle.js");
    zipInspector.assertFileExists("assets/js/helpers.js");
    zipInspector.assertFileExists("res/drawable-mdpi-v4/image.png");
    zipInspector.assertFileExists("res/drawable-hdpi-v4/image.png");
    zipInspector.assertFileExists("res/drawable-xhdpi-v4/image.png");
}
Also used : BuildTarget(com.facebook.buck.model.BuildTarget) ZipInspector(com.facebook.buck.testutil.integration.ZipInspector) Test(org.junit.Test)

Example 18 with ZipInspector

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

the class AndroidReactNativeLibraryIntegrationTest method testApkContainsJSAssetAndDrawablesForIndexedUnbundle.

@Test
public void testApkContainsJSAssetAndDrawablesForIndexedUnbundle() throws IOException {
    BuildTarget target = BuildTargetFactory.newInstance("//apps/sample:app-indexed_unbundle");
    workspace.runBuckBuild(target.getFullyQualifiedName()).assertSuccess();
    ZipInspector zipInspector = new ZipInspector(workspace.getPath(BuildTargets.getGenPath(filesystem, target, "%s.apk")));
    zipInspector.assertFileExists("assets/SampleBundle.js");
    zipInspector.assertFileDoesNotExist("assets/js/helpers.js");
    zipInspector.assertFileExists("res/drawable-mdpi-v4/image.png");
    zipInspector.assertFileExists("res/drawable-hdpi-v4/image.png");
    zipInspector.assertFileExists("res/drawable-xhdpi-v4/image.png");
}
Also used : BuildTarget(com.facebook.buck.model.BuildTarget) ZipInspector(com.facebook.buck.testutil.integration.ZipInspector) Test(org.junit.Test)

Example 19 with ZipInspector

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

the class DefaultJavaLibraryIntegrationTest method testSpoolClassFilesDirectlyToJarWithRemoveClasses.

@Test
public void testSpoolClassFilesDirectlyToJarWithRemoveClasses() throws IOException {
    ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "spool_class_files_directly_to_jar_with_remove_classes", tmp);
    workspace.setUp();
    BuildTarget target = BuildTargetFactory.newInstance("//:a");
    ProcessResult result = workspace.runBuckBuild(target.getFullyQualifiedName());
    result.assertSuccess();
    Path classesDir = workspace.getPath(BuildTargets.getScratchPath(filesystem, target, "lib__%s__classes"));
    assertThat("Classes directory should exist.", Files.exists(classesDir), is(Boolean.TRUE));
    assertThat("No class files should be stored on disk.", ImmutableList.copyOf(classesDir.toFile().listFiles()), hasSize(0));
    Path jarPath = workspace.getPath(BuildTargets.getGenPath(filesystem, target, "lib__%s__output/a.jar"));
    assertTrue(Files.exists(jarPath));
    // Check that normal and member classes were removed as expected.
    ZipInspector zipInspector = new ZipInspector(jarPath);
    zipInspector.assertFileExists("test/pkg/A.class");
    zipInspector.assertFileExists("test/pkg/B.class");
    zipInspector.assertFileExists("test/pkg/C.class");
    zipInspector.assertFileDoesNotExist("test/pkg/RemovableZ.class");
    zipInspector.assertFileDoesNotExist("B$removableB.class");
    zipInspector.assertFileDoesNotExist("C$deletableD.class");
}
Also used : Path(java.nio.file.Path) ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) BuildTarget(com.facebook.buck.model.BuildTarget) ZipInspector(com.facebook.buck.testutil.integration.ZipInspector) ProcessResult(com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult) Test(org.junit.Test)

Example 20 with ZipInspector

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

the class CopyResourcesStepIntegrationTest method testGeneratedResourceIsAlongsideClassFiles.

@Test
public void testGeneratedResourceIsAlongsideClassFiles() throws IOException, InterruptedException {
    ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "generated_resources", temporaryFolder);
    workspace.setUp();
    Path exampleJar = workspace.buildAndReturnOutput("//java/com/example:example");
    ZipInspector exampleInspector = new ZipInspector(exampleJar);
    exampleInspector.assertFileExists("com/example/HelloWorld.class");
    exampleInspector.assertFileExists("com/example/res/helloworld.txt");
    Path helloWorldJar = workspace.buildAndReturnOutput("//java/com/example:HelloWorld");
    ProcessExecutor.Result result = workspace.runJar(helloWorldJar);
    assertEquals("hello world\n", result.getStdout().get());
    assertEquals("", result.getStderr().get());
}
Also used : Path(java.nio.file.Path) ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) ZipInspector(com.facebook.buck.testutil.integration.ZipInspector) ProcessExecutor(com.facebook.buck.util.ProcessExecutor) Test(org.junit.Test)

Aggregations

ZipInspector (com.facebook.buck.testutil.integration.ZipInspector)63 Test (org.junit.Test)62 Path (java.nio.file.Path)34 ProjectWorkspace (com.facebook.buck.testutil.integration.ProjectWorkspace)29 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)15 BuildTarget (com.facebook.buck.model.BuildTarget)10 ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)7 TestConsole (com.facebook.buck.testutil.TestConsole)4 ByteArrayInputStream (java.io.ByteArrayInputStream)4 BuildRuleResolver (com.facebook.buck.rules.BuildRuleResolver)3 DefaultTargetNodeToBuildRuleTransformer (com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer)3 SourcePathResolver (com.facebook.buck.rules.SourcePathResolver)3 SourcePathRuleFinder (com.facebook.buck.rules.SourcePathRuleFinder)3 ProcessResult (com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult)3 Clock (com.facebook.buck.timing.Clock)3 DefaultClock (com.facebook.buck.timing.DefaultClock)3 SymbolGetter (com.facebook.buck.android.AndroidNdkHelper.SymbolGetter)2 SymbolsAndDtNeeded (com.facebook.buck.android.AndroidNdkHelper.SymbolsAndDtNeeded)2 FakeBuildableContext (com.facebook.buck.rules.FakeBuildableContext)2 ExecutionContext (com.facebook.buck.step.ExecutionContext)2