use of com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult in project buck by facebook.
the class DefaultJavaLibraryIntegrationTest method ensureProvidedDepsAreIncludedWhenCompilingButNotWhenPackaging.
@Test
public void ensureProvidedDepsAreIncludedWhenCompilingButNotWhenPackaging() throws IOException {
workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "provided_deps", tmp);
workspace.setUp();
// Run `buck build`.
BuildTarget binaryTarget = BuildTargetFactory.newInstance("//:binary");
BuildTarget binary2Target = BuildTargetFactory.newInstance("//:binary_2");
ProcessResult buildResult = workspace.runBuckCommand("build", binaryTarget.getFullyQualifiedName(), binary2Target.getFullyQualifiedName());
buildResult.assertSuccess("Successful build should exit with 0.");
for (Path filename : new Path[] { BuildTargets.getGenPath(filesystem, binaryTarget, "%s.jar"), BuildTargets.getGenPath(filesystem, binary2Target, "%s.jar") }) {
Path file = workspace.getPath(filename);
try (Zip zip = new Zip(file, /* for writing? */
false)) {
Set<String> allNames = zip.getFileNames();
// Representative file from provided_deps we don't expect to be there.
assertFalse(allNames.contains("org/junit/Test.class"));
// Representative file from the deps that we do expect to be there.
assertTrue(allNames.contains("com/google/common/collect/Sets.class"));
// The file we built.
assertTrue(allNames.contains("com/facebook/buck/example/Example.class"));
}
}
}
use of com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult in project buck by facebook.
the class DefaultJavaLibraryIntegrationTest method testBuildJavaLibraryWithFirstOrder.
@Test
public void testBuildJavaLibraryWithFirstOrder() throws IOException {
workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "warn_on_transitive", tmp);
workspace.setUp();
// Run `buck build`.
ProcessResult buildResult = workspace.runBuckCommand("build", "//:raz", "-b", "FIRST_ORDER_ONLY");
buildResult.assertFailure("Build should have failed.");
workspace.verify();
}
use of com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult in project buck by facebook.
the class DefaultJavaLibraryIntegrationTest method testBucksClasspathNotOnBuildClasspath.
@Test
public void testBucksClasspathNotOnBuildClasspath() throws IOException {
workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "guava_no_deps", tmp);
workspace.setUp();
// Run `buck build`.
ProcessResult buildResult = workspace.runBuckCommand("build", "//:foo");
buildResult.assertFailure("Build should have failed since //:foo depends on Guava and " + "Args4j but does not include it in its deps.");
workspace.verify();
}
use of com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult in project buck by facebook.
the class DefaultJavaLibraryIntegrationTest method testAddedSourceFileInvalidatesManifest.
// Yes, we actually had the bug against which this test is guarding.
@Test
public void testAddedSourceFileInvalidatesManifest() throws IOException {
workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "manifest_key", tmp);
workspace.setUp();
workspace.enableDirCache();
// Run `buck build` to warm the cache.
BuildTarget mainTarget = BuildTargetFactory.newInstance("//:main");
// Warm the used classes file
ProcessResult buildResult = workspace.runBuckCommand("build", mainTarget.getFullyQualifiedName());
buildResult.assertSuccess("Successful build should exit with 0.");
workspace.getBuildLog().assertTargetBuiltLocally("//:main");
// Run `buck clean` so that we're forced to fetch the dep file from the cache.
ProcessResult cleanResult = workspace.runBuckCommand("clean");
cleanResult.assertSuccess("Successful clean should exit with 0.");
// Add a new source file
workspace.writeContentsToPath("package com.example; public class NewClass { }", "NewClass.java");
// Run `buck build` again.
ProcessResult buildResult2 = workspace.runBuckCommand("build", mainTarget.getFullyQualifiedName());
buildResult2.assertSuccess("Successful build should exit with 0.");
// The new source file should result in a different manifest being downloaded and thus a
// cache miss.
workspace.getBuildLog().assertTargetBuiltLocally("//:main");
}
use of com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult in project buck by facebook.
the class DefaultJavaLibraryIntegrationTest method testNoDepsCompilesCleanly.
@Test
public void testNoDepsCompilesCleanly() throws IOException {
workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "guava_no_deps", tmp);
workspace.setUp();
// Run `buck build`.
ProcessResult buildResult = workspace.runBuckCommand("build", "//:bar");
buildResult.assertSuccess("Build should have succeeded.");
workspace.verify();
}
Aggregations