use of com.facebook.buck.testutil.integration.ProjectWorkspace in project buck by facebook.
the class CommandLineTargetNodeSpecParserIntegrationTest method trailingColonBuild.
@Test
public void trailingColonBuild() throws IOException {
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "command_line_parser", tmp);
workspace.setUp();
workspace.runBuckBuild("//simple:").assertSuccess();
workspace.getBuildLog().assertTargetBuiltLocally("//simple:simple");
assertEquals(ImmutableSet.of(BuildTargetFactory.newInstance(workspace.getDestPath(), "//simple:simple")), workspace.getBuildLog().getAllTargets());
}
use of com.facebook.buck.testutil.integration.ProjectWorkspace in project buck by facebook.
the class CommandLineTargetNodeSpecParserIntegrationTest method multiAlias.
@Test
public void multiAlias() throws IOException {
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "command_line_parser", tmp);
workspace.setUp();
workspace.runBuckBuild("multialias").assertSuccess();
ImmutableSet<BuildTarget> targets = ImmutableSet.of(BuildTargetFactory.newInstance(workspace.getDestPath(), "//simple:simple"), BuildTargetFactory.newInstance(workspace.getDestPath(), "//simple/foo:foo"));
for (BuildTarget target : targets) {
workspace.getBuildLog().assertTargetBuiltLocally(target.toString());
}
assertEquals(targets, workspace.getBuildLog().getAllTargets());
}
use of com.facebook.buck.testutil.integration.ProjectWorkspace in project buck by facebook.
the class DaemonIntegrationTest method whenConcurrentReadOnlyCommandExecutedThenReadOnlyCommandSucceeds.
@Test
public void whenConcurrentReadOnlyCommandExecutedThenReadOnlyCommandSucceeds() throws IOException, InterruptedException, ExecutionException {
final ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "exclusive_execution", tmp);
workspace.setUp();
Future<?> firstThread = executorService.schedule(createRunnableCommand(SUCCESS_EXIT_CODE, "build", "//:sleep"), 0, TimeUnit.MILLISECONDS);
Future<?> secondThread = executorService.schedule(createRunnableCommand(SUCCESS_EXIT_CODE, "targets"), 500L, TimeUnit.MILLISECONDS);
firstThread.get();
secondThread.get();
}
use of com.facebook.buck.testutil.integration.ProjectWorkspace in project buck by facebook.
the class DaemonIntegrationTest method whenClientDisconnectionDetectedThenBuildIsInterrupted.
/**
* This verifies that a client timeout will be detected by a Nailgun
* NGInputStream reading from an empty heartbeat stream and that the generated
* InterruptedException will cause command execution to fail after timeout.
*/
@Test
public void whenClientDisconnectionDetectedThenBuildIsInterrupted() throws InterruptedException, IOException {
// Sub process interruption not supported on Windows.
assumeTrue(Platform.detect() != Platform.WINDOWS);
// Stream timeout > test timeout.
final long timeoutMillis = 2000;
// Disconnect before test timeout.
final long disconnectMillis = 100;
final ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "exclusive_execution", tmp);
workspace.setUp();
// Build an NGContext connected to an NGInputStream reading from stream that will timeout.
try (TestContext context = new TestContext(ImmutableMap.copyOf(System.getenv()), TestContext.createDisconnectionStream(disconnectMillis), timeoutMillis)) {
ProcessResult result = workspace.runBuckdCommand(context, "build", "//:sleep");
result.assertFailure();
assertThat(result.getStderr(), containsString("InterruptedException"));
}
}
use of com.facebook.buck.testutil.integration.ProjectWorkspace in project buck by facebook.
the class DaemonIntegrationTest method whenSourceInputRemovedThenRebuildFails.
@Test
public void whenSourceInputRemovedThenRebuildFails() throws IOException, InterruptedException {
final ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "file_watching", tmp);
workspace.setUp();
workspace.runBuckdCommand("build", "//java/com/example/activity:activity").assertSuccess();
String fileName = "java/com/example/activity/MyFirstActivity.java";
Files.delete(workspace.getPath(fileName));
try {
workspace.runBuckdCommand("build", "//java/com/example/activity:activity");
fail("Should have thrown HumanReadableException.");
} catch (java.lang.RuntimeException e) {
assertThat("Failure should have been due to file removal.", e.getMessage(), containsString("MyFirstActivity.java"));
}
}
Aggregations