use of com.facebook.buck.testutil.integration.ProjectWorkspace in project buck by facebook.
the class NdkCxxPlatformIntegrationTest method testWorkingDirectoryAndNdkHeaderPathsAreSanitized.
@Test
public void testWorkingDirectoryAndNdkHeaderPathsAreSanitized() throws IOException {
ProjectWorkspace workspace = setupWorkspace("ndk_debug_paths");
workspace.writeContentsToPath("[ndk]\n" + " cpu_abis = arm, armv7, arm64, x86, x86_64\n" + " gcc_version = 4.9\n" + " app_platform = android-21\n", ".buckconfig");
ProjectFilesystem filesystem = new ProjectFilesystem(workspace.getDestPath());
BuildTarget target = BuildTargetFactory.newInstance(String.format("//:lib#android-%s,static", arch));
workspace.runBuckBuild(target.getFullyQualifiedName()).assertSuccess();
Path lib = workspace.getPath(BuildTargets.getGenPath(filesystem, target, "%s/lib" + target.getShortName() + ".a"));
String contents = MorePaths.asByteSource(lib).asCharSource(Charsets.ISO_8859_1).read();
// Verify that the working directory is sanitized.
assertFalse(contents.contains(tmp.getRoot().toString()));
// Verify that we don't have any references to the build toolchain in the debug info.
for (NdkCxxPlatforms.Host host : NdkCxxPlatforms.Host.values()) {
assertFalse(contents.contains(host.toString()));
}
// Verify that the NDK path is sanitized.
assertFalse(contents.contains(getNdkRoot().toString()));
}
use of com.facebook.buck.testutil.integration.ProjectWorkspace in project buck by facebook.
the class NdkLibraryIntegrationTest method cxxLibraryDep.
@Test
public void cxxLibraryDep() throws IOException {
AssumeAndroidPlatform.assumeNdkIsAvailable();
ProjectWorkspace workspace1 = TestDataHelper.createProjectWorkspaceForScenario(this, "cxx_deps", tmp1);
workspace1.setUp();
workspace1.runBuckBuild("//jni:foo").assertSuccess();
ProjectWorkspace workspace2 = TestDataHelper.createProjectWorkspaceForScenario(this, "cxx_deps", tmp2);
workspace2.setUp();
workspace2.runBuckBuild("//jni:foo").assertSuccess();
// Verify that rule keys generated from building in two different working directories
// does not affect the rule key.
assertNotEquals(workspace1.resolve(Paths.get("test")), workspace2.resolve(Paths.get("test")));
assertEquals(workspace1.getBuildLog().getRuleKey("//jni:foo"), workspace2.getBuildLog().getRuleKey("//jni:foo"));
}
use of com.facebook.buck.testutil.integration.ProjectWorkspace in project buck by facebook.
the class GenAidlIntegrationTest method buildingCleaningAndThenRebuildingFromCacheShouldWorkAsExpected.
@Test
public void buildingCleaningAndThenRebuildingFromCacheShouldWorkAsExpected() throws IOException {
AssumeAndroidPlatform.assumeSdkIsAvailable();
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "cached_build", tmp);
workspace.setUp();
workspace.enableDirCache();
// Populate the cache
ProjectWorkspace.ProcessResult result = workspace.runBuckBuild("//:android-lib");
result.assertSuccess();
result = workspace.runBuckCommand("clean");
result.assertSuccess();
// Now the cache is clean, do the build where we expect the results to come from the cache
result = workspace.runBuckBuild("//:android-lib");
result.assertSuccess();
}
use of com.facebook.buck.testutil.integration.ProjectWorkspace in project buck by facebook.
the class GenAidlIntegrationTest method rootDirectoryDoesntChangeBuild.
@Test
public void rootDirectoryDoesntChangeBuild() throws IOException {
AssumeAndroidPlatform.assumeSdkIsAvailable();
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "cached_build", tmp);
workspace.setUp();
Path outputOne = workspace.buildAndReturnOutput("//:AService");
ProjectWorkspace workspaceTwo = TestDataHelper.createProjectWorkspaceForScenario(this, "cached_build", tmp2);
workspaceTwo.setUp();
Path outputTwo = workspaceTwo.buildAndReturnOutput("//:AService");
assertEquals(workspace.getBuildLog().getRuleKey("//:AService"), workspaceTwo.getBuildLog().getRuleKey("//:AService"));
try (ZipFile zipOne = new ZipFile(outputOne.toFile());
ZipFile zipTwo = new ZipFile(outputTwo.toFile())) {
Enumeration<? extends ZipEntry> entriesOne = zipOne.entries(), entriesTwo = zipTwo.entries();
while (entriesOne.hasMoreElements()) {
assertTrue(entriesTwo.hasMoreElements());
ZipEntry entryOne = entriesOne.nextElement(), entryTwo = entriesTwo.nextElement();
// Compare data first, otherwise crc difference will cause a failure and you don't get to
// see the actual difference.
assertEquals(zipEntryData(zipOne, entryOne), zipEntryData(zipTwo, entryTwo));
assertEquals(zipEntryDebugString(entryOne), zipEntryDebugString(entryTwo));
}
assertFalse(entriesTwo.hasMoreElements());
}
assertEquals(new String(Files.readAllBytes(outputOne)), new String(Files.readAllBytes(outputTwo)));
}
use of com.facebook.buck.testutil.integration.ProjectWorkspace in project buck by facebook.
the class AppleBundleIntegrationTest method infoPlistSubstitutionsAreApplied.
@Test
public void infoPlistSubstitutionsAreApplied() throws Exception {
assumeTrue(Platform.detect() == Platform.MACOS);
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "application_bundle_with_substitutions", tmp);
workspace.setUp();
BuildTarget target = workspace.newBuildTarget("//:DemoApp#iphonesimulator-x86_64,no-debug");
workspace.runBuckCommand("build", target.getFullyQualifiedName()).assertSuccess();
workspace.verify(Paths.get("DemoApp_output.expected"), BuildTargets.getGenPath(filesystem, BuildTarget.builder(target).addFlavors(AppleDescriptions.NO_INCLUDE_FRAMEWORKS_FLAVOR).build(), "%s"));
Path appPath = BuildTargets.getGenPath(filesystem, BuildTarget.builder(target).addFlavors(AppleDescriptions.NO_INCLUDE_FRAMEWORKS_FLAVOR).build(), "%s").resolve(target.getShortName() + ".app");
assertTrue(Files.exists(workspace.getPath(appPath.resolve(target.getShortName()))));
}
Aggregations