Search in sources :

Example 31 with ZipInspector

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

the class AndroidBinaryIntegrationTest method testCompressAssetLibsNoPackageModular.

@Test
public void testCompressAssetLibsNoPackageModular() throws IOException {
    String target = "//apps/sample:app_cxx_lib_asset_no_package_modular";
    workspace.runBuckCommand("build", target).assertSuccess();
    ZipInspector zipInspector = new ZipInspector(workspace.getPath(BuildTargets.getGenPath(filesystem, BuildTargetFactory.newInstance(target), "%s.apk")));
    zipInspector.assertFileExists("assets/native.cxx.libasset/libs.xzs");
    zipInspector.assertFileExists("assets/native.cxx.libasset/libs.txt");
    zipInspector.assertFileExists("lib/x86/libnative_cxx_libasset2.so");
    zipInspector.assertFileExists("lib/x86/libnative_cxx_foo1.so");
    zipInspector.assertFileExists("lib/x86/libnative_cxx_foo2.so");
    zipInspector.assertFileDoesNotExist("assets/lib/libs.xzs");
    zipInspector.assertFileDoesNotExist("assets/lib/metadata.txt");
    zipInspector.assertFileDoesNotExist("lib/x86/libnative_cxx_libasset.so");
    zipInspector.assertFileDoesNotExist("assets/lib/x86/libnative_cxx_libasset.so");
    zipInspector.assertFileDoesNotExist("assets/lib/x86/libnative_cxx_libasset2.so");
    zipInspector.assertFileDoesNotExist("assets/lib/x86/libnative_cxx_foo1.so");
    zipInspector.assertFileDoesNotExist("assets/lib/x86/libnative_cxx_foo2.so");
}
Also used : ZipInspector(com.facebook.buck.testutil.integration.ZipInspector) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test)

Example 32 with ZipInspector

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

the class AndroidAarIntegrationTest method testNativeLibraryDependent.

@Test
public void testNativeLibraryDependent() throws IOException {
    AssumeAndroidPlatform.assumeNdkIsAvailable();
    ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "android_aar_native_deps/ndk_deps", tmp);
    workspace.setUp();
    String target = "//:app";
    workspace.runBuckBuild(target).assertSuccess();
    Path aar = workspace.getPath(BuildTargets.getGenPath(filesystem, BuildTargetFactory.newInstance(target), AndroidAar.AAR_FORMAT));
    ZipInspector zipInspector = new ZipInspector(aar);
    zipInspector.assertFileExists("AndroidManifest.xml");
    zipInspector.assertFileExists("classes.jar");
    zipInspector.assertFileExists("R.txt");
    zipInspector.assertFileExists("res/");
    zipInspector.assertFileExists("assets/lib/armeabi/libfoo.so");
    zipInspector.assertFileExists("assets/lib/armeabi-v7a/libfoo.so");
    zipInspector.assertFileExists("assets/lib/x86/libfoo.so");
    zipInspector.assertFileExists("jni/armeabi/libbar.so");
    zipInspector.assertFileExists("jni/armeabi-v7a/libbar.so");
    zipInspector.assertFileExists("jni/x86/libbar.so");
}
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 33 with ZipInspector

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

the class AndroidAarIntegrationTest method testBuildPrebuiltAndroidAar.

@Test
public void testBuildPrebuiltAndroidAar() throws IOException {
    ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "android_aar_build/caseB", tmp);
    workspace.setUp();
    String target = "//:app";
    workspace.runBuckBuild(target).assertSuccess();
    Path aar = workspace.getPath(BuildTargets.getGenPath(filesystem, BuildTargetFactory.newInstance(target), AndroidAar.AAR_FORMAT));
    ZipInspector zipInspector = new ZipInspector(aar);
    zipInspector.assertFileExists("AndroidManifest.xml");
    zipInspector.assertFileExists("classes.jar");
    zipInspector.assertFileExists("R.txt");
    zipInspector.assertFileExists("res/");
    zipInspector.assertFileExists("res/values/");
    zipInspector.assertFileExists("res/values/values.xml");
    zipInspector.assertFileContents("res/values/values.xml", "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + "<resources>\n" + "    <string name=\"app_name\">Hello World</string>\n" + "</resources>");
}
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 34 with ZipInspector

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

the class AndroidExopackageBinaryIntegrationTest method testEditingNativeForcesRebuild.

@Test
public void testEditingNativeForcesRebuild() throws IOException, InterruptedException {
    // Sleep 1 second (plus another half to be super duper safe) to make sure that
    // fakesystem.c gets a later timestamp than the fakesystem.o that was produced
    // during the build in setUp.  If we don't do this, there's a chance that the
    // ndk-build we run during the upcoming build will not rebuild it (on filesystems
    // that have 1-second granularity for last modified).
    // To verify this, create a Makefile with the following rule (don't forget to use a tab):
    // out: in
    //   cat $< > $@
    // Run: echo foo > in ; make ; cat out ; echo bar > in ; make ; cat out
    // On a filesystem with 1-second mtime granularity, the last "cat" should print "foo"
    // (with very high probability).
    Thread.sleep(1500);
    ZipInspector zipInspector;
    // Change the binary and ensure that we re-run apkbuilder.
    workspace.replaceFileContents("native/fakenative/jni/fakesystem.c", "exit(status)", "exit(1+status)");
    workspace.resetBuildLogFile();
    workspace.runBuckBuild(DEX_EXOPACKAGE_TARGET).assertSuccess();
    workspace.getBuildLog().assertTargetBuiltLocally(DEX_EXOPACKAGE_TARGET);
    zipInspector = new ZipInspector(workspace.getPath("buck-out/gen/apps/multidex/app-dex-exo.apk"));
    zipInspector.assertFileExists("lib/armeabi/libfakenative.so");
    zipInspector.assertFileDoesNotExist("assets/lib/armeabi/libfakenative.so");
    // Now convert it into an asset native library and ensure that we re-run apkbuilder.
    workspace.replaceFileContents("native/fakenative/jni/BUCK", "name = 'fakenative',", "name = 'fakenative',\nis_asset=True,");
    workspace.resetBuildLogFile();
    workspace.runBuckBuild(DEX_EXOPACKAGE_TARGET).assertSuccess();
    workspace.getBuildLog().assertTargetBuiltLocally(DEX_EXOPACKAGE_TARGET);
    zipInspector = new ZipInspector(workspace.getPath("buck-out/gen/apps/multidex/app-dex-exo.apk"));
    zipInspector.assertFileDoesNotExist("lib/armeabi/libfakenative.so");
    zipInspector.assertFileExists("assets/lib/armeabi/libfakenative.so");
    // Now edit it again and make sure we re-run apkbuilder.
    Thread.sleep(1500);
    workspace.replaceFileContents("native/fakenative/jni/fakesystem.c", "exit(1+status)", "exit(2+status)");
    workspace.resetBuildLogFile();
    workspace.runBuckBuild(DEX_EXOPACKAGE_TARGET).assertSuccess();
    workspace.getBuildLog().assertTargetBuiltLocally(DEX_EXOPACKAGE_TARGET);
    zipInspector = new ZipInspector(workspace.getPath(BuildTargets.getGenPath(filesystem, BuildTargetFactory.newInstance(DEX_EXOPACKAGE_TARGET), "%s.apk")));
    zipInspector.assertFileDoesNotExist("lib/armeabi/libfakenative.so");
    zipInspector.assertFileExists("assets/lib/armeabi/libfakenative.so");
}
Also used : ZipInspector(com.facebook.buck.testutil.integration.ZipInspector) Test(org.junit.Test)

Example 35 with ZipInspector

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

the class AndroidExopackageBinaryIntegrationTest method testAllExopackageHasNeitherSecondaryNorNativeLibraries.

@Test
public void testAllExopackageHasNeitherSecondaryNorNativeLibraries() throws IOException {
    ZipInspector zipInspector = new ZipInspector(workspace.getPath(BuildTargets.getGenPath(filesystem, BuildTargetFactory.newInstance(DEX_AND_NATIVE_EXOPACKAGE_TARGET), "%s.apk")));
    zipInspector.assertFileDoesNotExist("assets/secondary-program-dex-jars/metadata.txt");
    zipInspector.assertFileDoesNotExist("classes2.dex");
    zipInspector.assertFileExists("classes.dex");
    assertNativeLibrariesDontExist(zipInspector);
}
Also used : 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