@Test public void testVariousSuccessTypesInReport() throws IOException { ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "keep_going", tmp).setUp(); ProcessResult result1 = buildTwoGoodRulesAndAssertSuccess(workspace); String expectedReport1 = "OK //:rule_with_output BUILT_LOCALLY " + GENRULE_OUTPUT + "\n" + "OK //:rule_without_output BUILT_LOCALLY\n"; assertThat(result1.getStderr(), containsString(expectedReport1)); ProcessResult result2 = buildTwoGoodRulesAndAssertSuccess(workspace); String expectedReport2 = "OK //:rule_with_output MATCHING_RULE_KEY " + GENRULE_OUTPUT + "\n" + "OK //:rule_without_output MATCHING_RULE_KEY\n"; assertThat(result2.getStderr(), containsString(expectedReport2)); workspace.runBuckCommand("clean").assertSuccess(); ProcessResult result3 = buildTwoGoodRulesAndAssertSuccess(workspace); String expectedReport3 = "OK //:rule_with_output FETCHED_FROM_CACHE " + GENRULE_OUTPUT + "\n" + "OK //:rule_without_output FETCHED_FROM_CACHE\n"; assertThat(result3.getStderr(), containsString(expectedReport3)); }
@Test public void testKeepGoingWithMultipleSuccessfulTargets() throws IOException { ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "keep_going", tmp).setUp(); ProcessResult result = buildTwoGoodRulesAndAssertSuccess(workspace); String expectedReport = "OK //:rule_with_output BUILT_LOCALLY " + GENRULE_OUTPUT + "\n" + "OK //:rule_without_output BUILT_LOCALLY\n"; assertThat(result.getStderr(), containsString(expectedReport)); }
@Test public void testIfCommandExitsZeroThenGenruleFails() throws IOException { assumeTrue( "This genrule uses the 'bash' argument, which is not supported on Windows. ", Platform.detect() != Platform.WINDOWS); ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario( this, "genrule_failing_command", temporaryFolder); workspace.setUp(); ProcessResult buildResult = workspace.runBuckCommand("build", "//:fail"); buildResult.assertExitCode(1); // We make sure that we failed for the right reason. assertThat( buildResult.getStderr(), containsString("BUILD FAILED: //:fail failed on step \"genrule\" with exit code 1")); }
@Test public void testKeepGoingWithOneFailingTarget() throws IOException { ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "keep_going", tmp).setUp(); ProcessResult result = workspace .runBuckBuild("--keep-going", "//:rule_with_output", "//:failing_rule") .assertFailure(); String expectedReport = "OK //:rule_with_output BUILT_LOCALLY " + GENRULE_OUTPUT + "\n" + "FAIL //:failing_rule\n"; assertThat(result.getStderr(), containsString(expectedReport)); Path outputFile = workspace.getPath(GENRULE_OUTPUT); assertTrue(Files.exists(outputFile)); }