Search in sources :

Example 26 with ProcessResult

use of com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult in project buck by facebook.

the class AuditRulesCommandIntegrationTest method testIncludeEmptyValues.

@Test
public void testIncludeEmptyValues() throws IOException {
    ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "audit_rules", tmp);
    workspace.setUp();
    ProcessResult result1 = workspace.runBuckCommand("audit", "rules", "--include_empty_values", "--type", "genrule", "example/BUCK");
    result1.assertSuccess();
    assertThat(result1.getStdout(), MoreStringsForTests.equalToIgnoringPlatformNewlines(workspace.getFileContents("stdout.genrule.include_empties")));
    ProcessResult result2 = workspace.runBuckCommand("audit", "rules", "--include_empty_values", "--type", "genrule", "--json", "example/BUCK");
    result2.assertSuccess();
    assertThat(result2.getStdout(), MoreStringsForTests.equalToIgnoringPlatformNewlines(workspace.getFileContents("stdout.genrule.include_empties.json")));
}
Also used : ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) ProcessResult(com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult) Test(org.junit.Test)

Example 27 with ProcessResult

use of com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult in project buck by facebook.

the class AuditTestsCommandIntegrationTest method testPassingTheJSONFlagCausesJSONOutput.

@Test
public void testPassingTheJSONFlagCausesJSONOutput() throws IOException {
    ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "audit_tests", tmp);
    workspace.setUp();
    // Print all of the inputs to the rule.
    ProcessResult result = workspace.runBuckCommand("audit", "tests", "--json", "//example:one", "//example:two", "//example:three", "//example:four", "//example:five", "//example:six");
    result.assertSuccess();
    String expected = workspace.getFileContents("stdout-one-two-three-four-five-six.json");
    assertEquals(expected, result.getStdout());
}
Also used : ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) ProcessResult(com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 28 with ProcessResult

use of com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult in project buck by facebook.

the class AuditTestsCommandIntegrationTest method testTestsWithMultipleTargetParametersPrintsTestsForAllTargets.

@Test
public void testTestsWithMultipleTargetParametersPrintsTestsForAllTargets() throws IOException {
    ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "audit_tests", tmp);
    workspace.setUp();
    // Print all of the inputs to the rule.
    ProcessResult result = workspace.runBuckCommand("audit", "tests", "//example:four", "//example:six");
    result.assertSuccess();
    assertEquals(workspace.getFileContents("stdout-four-six"), result.getStdout());
}
Also used : ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) ProcessResult(com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult) Test(org.junit.Test)

Example 29 with ProcessResult

use of com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult in project buck by facebook.

the class AuditTestsCommandIntegrationTest method testRunningWithNoParameterCausesBuildError.

@Test
public void testRunningWithNoParameterCausesBuildError() throws IOException {
    ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "audit_tests", tmp);
    workspace.setUp();
    // Print all of the inputs to the rule.
    ProcessResult result = workspace.runBuckCommand("audit", "tests");
    result.assertFailure();
    assertThat(result.getStderr(), containsString("Must specify at least one build target.\n"));
}
Also used : ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) ProcessResult(com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult) Test(org.junit.Test)

Example 30 with ProcessResult

use of com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult in project buck by facebook.

the class NumThreadsIntegrationTest method testCommandLineNumThreadsArgOverridesBuckConfig.

@Test
public void testCommandLineNumThreadsArgOverridesBuckConfig() throws IOException {
    ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "num_threads", tmp);
    workspace.setUp();
    workspace.disableThreadLimitOverride();
    ProcessResult buildResult1 = workspace.runBuckCommand("build", "//:noop", "--verbose", "10");
    assertThat("Number of threads to use should be read from .buckconfig.", buildResult1.getStderr(), containsString("Creating a build with 7 threads.\n"));
    ProcessResult buildResult2 = workspace.runBuckCommand("build", "//:noop", "--verbose", "10", "--num-threads", "27");
    assertThat("Command-line arg should override value in .buckconfig.", buildResult2.getStderr(), containsString("Creating a build with 27 threads.\n"));
    Path buckconfig = workspace.getPath(".buckconfig");
    Files.delete(buckconfig);
    int numThreads = Runtime.getRuntime().availableProcessors();
    ProcessResult buildResult3 = workspace.runBuckCommand("build", "//:noop", "--verbose", "10");
    assertThat("Once .buckconfig is deleted, the number of threads should be " + "equal to the number of processors.", buildResult3.getStderr(), containsString("Creating a build with " + numThreads + " threads.\n"));
}
Also used : Path(java.nio.file.Path) ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) ProcessResult(com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult) Test(org.junit.Test)

Aggregations

ProcessResult (com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult)175 Test (org.junit.Test)174 ProjectWorkspace (com.facebook.buck.testutil.integration.ProjectWorkspace)127 Path (java.nio.file.Path)21 Matchers.containsString (org.hamcrest.Matchers.containsString)20 BuildTarget (com.facebook.buck.model.BuildTarget)17 JsonNode (com.fasterxml.jackson.databind.JsonNode)8 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)8 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)6 TestContext (com.facebook.buck.testutil.integration.TestContext)4 ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)3 ZipInspector (com.facebook.buck.testutil.integration.ZipInspector)3 ZipFile (java.util.zip.ZipFile)3 FakeProjectFilesystem (com.facebook.buck.testutil.FakeProjectFilesystem)2 DelegatingInputStream (com.facebook.buck.testutil.integration.DelegatingInputStream)2 CapturingPrintStream (com.facebook.buck.util.CapturingPrintStream)2 File (java.io.File)2 Charset (java.nio.charset.Charset)2 FileTime (java.nio.file.attribute.FileTime)2 ArtifactCache (com.facebook.buck.artifact_cache.ArtifactCache)1