Search in sources :

Example 11 with ZipInspector

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

the class AndroidResourceFilterIntegrationTest method testAsset.

@Test
public void testAsset() throws IOException {
    workspace.enableDirCache();
    String target = "//apps/sample:app";
    workspace.runBuckBuild(target).assertSuccess();
    Path apkFile = workspace.getPath(BuildTargets.getGenPath(filesystem, BuildTargetFactory.newInstance(target), "%s.apk"));
    ZipInspector zipInspector = new ZipInspector(apkFile);
    long firstCrc = zipInspector.getCrc("assets/asset_file.txt");
    workspace.replaceFileContents("res/com/sample/asset_only/assets/asset_file.txt", "Hello", "Bye");
    workspace.runBuckBuild(target).assertSuccess();
    apkFile = workspace.getPath(BuildTargets.getGenPath(filesystem, BuildTargetFactory.newInstance(target), "%s.apk"));
    zipInspector = new ZipInspector(apkFile);
    long secondCrc = zipInspector.getCrc("assets/asset_file.txt");
    assertNotEquals("Rebuilt APK file must include the new asset file.", firstCrc, secondCrc);
}
Also used : Path(java.nio.file.Path) ZipInspector(com.facebook.buck.testutil.integration.ZipInspector) Test(org.junit.Test)

Example 12 with ZipInspector

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

the class BuiltinApplePackageIntegrationTest method packageHasProperStructure.

@Test
public void packageHasProperStructure() throws IOException, InterruptedException {
    assumeTrue(Platform.detect() == Platform.MACOS);
    ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "simple_application_bundle_no_debug", tmp);
    workspace.setUp();
    workspace.enableDirCache();
    BuildTarget appTarget = BuildTargetFactory.newInstance("//:DemoApp#no-debug,no-include-frameworks");
    workspace.runBuckCommand("build", appTarget.getUnflavoredBuildTarget().getFullyQualifiedName()).assertSuccess();
    workspace.getBuildLog().assertTargetBuiltLocally(appTarget.getFullyQualifiedName());
    workspace.runBuckCommand("clean").assertSuccess();
    BuildTarget packageTarget = BuildTargetFactory.newInstance("//:DemoAppPackage");
    workspace.runBuckCommand("build", packageTarget.getFullyQualifiedName()).assertSuccess();
    workspace.getBuildLog().assertTargetWasFetchedFromCache(appTarget.getFullyQualifiedName());
    workspace.getBuildLog().assertTargetBuiltLocally(packageTarget.getFullyQualifiedName());
    Path templateDir = TestDataHelper.getTestDataScenario(this, "simple_application_bundle_no_debug");
    ZipInspector zipInspector = new ZipInspector(workspace.getPath(BuildTargets.getGenPath(filesystem, packageTarget, "%s.ipa")));
    zipInspector.assertFileExists("Payload/DemoApp.app/DemoApp");
    zipInspector.assertFileDoesNotExist("WatchKitSupport");
    zipInspector.assertFileDoesNotExist("WatchKitSupport2");
    zipInspector.assertFileContents("Payload/DemoApp.app/PkgInfo", new String(Files.readAllBytes(templateDir.resolve("DemoApp_output.expected/DemoApp.app/PkgInfo.expected")), UTF_8));
}
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) Test(org.junit.Test)

Example 13 with ZipInspector

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

the class BuildCommandIntegrationTest method buckBuildAndCopyOutputFileWithBuildTargetThatSupportsIt.

@Test
public void buckBuildAndCopyOutputFileWithBuildTargetThatSupportsIt() throws IOException {
    ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "build_into", tmp);
    workspace.setUp();
    Path externalOutputs = tmp.newFolder("into-output");
    Path output = externalOutputs.resolve("the_example.jar");
    assertFalse(output.toFile().exists());
    workspace.runBuckBuild("//:example", "--out", output.toString()).assertSuccess();
    assertTrue(output.toFile().exists());
    ZipInspector zipInspector = new ZipInspector(output);
    zipInspector.assertFileExists("com/example/Example.class");
}
Also used : Path(java.nio.file.Path) ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) ZipInspector(com.facebook.buck.testutil.integration.ZipInspector) Test(org.junit.Test)

Example 14 with ZipInspector

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

the class GwtBinaryIntegrationTest method shouldBeAbleToBuildAGwtBinary.

@Test(timeout = (2 * 60 * 1000))
public void shouldBeAbleToBuildAGwtBinary() throws IOException {
    ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "gwt_binary", tmp);
    workspace.setUp();
    ProjectWorkspace.ProcessResult result = workspace.runBuckBuild("//:binary");
    result.assertSuccess();
    Path zip = workspace.buildAndReturnOutput("//:binary");
    ZipInspector inspector = new ZipInspector(zip);
    inspector.assertFileExists("a/a.devmode.js");
    inspector.assertFileExists("a/a.nocache.js");
    inspector.assertFileExists("a/clear.cache.gif");
    inspector.assertFileExists("a/compilation-mappings.txt");
}
Also used : Path(java.nio.file.Path) ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) ZipInspector(com.facebook.buck.testutil.integration.ZipInspector) Test(org.junit.Test)

Example 15 with ZipInspector

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

the class AndroidReactNativeLibraryIntegrationTest method testAaptPackageDependsOnReactNativeBundle.

@Test
public void testAaptPackageDependsOnReactNativeBundle() throws IOException {
    workspace.enableDirCache();
    BuildTarget target = BuildTargetFactory.newInstance("//apps/sample:app-without-rn-res");
    workspace.runBuckBuild(target.getFullyQualifiedName()).assertSuccess();
    ZipInspector zipInspector = new ZipInspector(workspace.getPath(BuildTargets.getGenPath(filesystem, target, "%s.apk")));
    zipInspector.assertFileExists("assets/SampleBundle.js");
    workspace.runBuckCommand("clean");
    workspace.replaceFileContents("apps/sample/BUCK", "#REPLACE_ME_WITH_ANOTHER_RES", "'//res/com/sample/unused:unused'");
    workspace.runBuckBuild(target.getFullyQualifiedName()).assertSuccess();
    zipInspector = new ZipInspector(workspace.getPath(BuildTargets.getGenPath(filesystem, target, "%s.apk")));
    zipInspector.assertFileExists("assets/SampleBundle.js");
}
Also used : BuildTarget(com.facebook.buck.model.BuildTarget) ZipInspector(com.facebook.buck.testutil.integration.ZipInspector) 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