Search in sources :

Example 86 with ProjectWorkspace

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());
}
Also used : ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) Test(org.junit.Test)

Example 87 with ProjectWorkspace

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());
}
Also used : ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) BuildTarget(com.facebook.buck.model.BuildTarget) Test(org.junit.Test)

Example 88 with ProjectWorkspace

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();
}
Also used : ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) Test(org.junit.Test)

Example 89 with ProjectWorkspace

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"));
    }
}
Also used : ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) TestContext(com.facebook.buck.testutil.integration.TestContext) ProcessResult(com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult) Test(org.junit.Test)

Example 90 with ProjectWorkspace

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"));
    }
}
Also used : ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Aggregations

ProjectWorkspace (com.facebook.buck.testutil.integration.ProjectWorkspace)747 Test (org.junit.Test)726 Path (java.nio.file.Path)219 BuildTarget (com.facebook.buck.model.BuildTarget)177 ProcessResult (com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult)127 ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)89 Matchers.containsString (org.hamcrest.Matchers.containsString)50 BuckBuildLog (com.facebook.buck.testutil.integration.BuckBuildLog)47 ProcessExecutor (com.facebook.buck.util.ProcessExecutor)35 ZipInspector (com.facebook.buck.testutil.integration.ZipInspector)21 HumanReadableException (com.facebook.buck.util.HumanReadableException)14 OcamlRuleBuilder.createStaticLibraryBuildTarget (com.facebook.buck.ocaml.OcamlRuleBuilder.createStaticLibraryBuildTarget)13 TestConsole (com.facebook.buck.testutil.TestConsole)12 FakeProjectFilesystem (com.facebook.buck.testutil.FakeProjectFilesystem)10 DefaultProcessExecutor (com.facebook.buck.util.DefaultProcessExecutor)10 Cell (com.facebook.buck.rules.Cell)9 TestContext (com.facebook.buck.testutil.integration.TestContext)9 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)9 MappedByteBuffer (java.nio.MappedByteBuffer)9 FileChannel (java.nio.channels.FileChannel)9