Skip to content
Permalink
Browse files

Avoid NPE when build aborts prematurely and produces no results

  • Loading branch information...
cpfeiffer committed Apr 5, 2012
1 parent c01c78f commit f9552c5dea5ff2a4eb93aaf6b0c1f8e6e39dd6f4
@@ -71,6 +71,8 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher,
try {
FilePath[] resultFiles = getResultFiles(build);
FitnesseResults results = getResults(listener.getLogger(), resultFiles);
if (results == null) return true; // no Fitnesse results found at all

FitnesseResultsAction action = new FitnesseResultsAction(build, results);
if (results.getBuildResult() != null) build.setResult(results.getBuildResult());
build.addAction(action);
@@ -157,4 +157,17 @@ public void testBuildStartingFitnesseAndExplodingTheJarFile() throws Exception {
Assert.assertTrue(resultsAction.getResult().getPassCount() > 0);
Assert.assertEquals(2, resultsAction.getResult().getFailCount());
}

public void testBuildWithoutResults() throws Exception {
FreeStyleProject project = createFreeStyleProject(getName());
project.getBuildersList().clear();
project.getPublishersList().clear();
String resultsFile = "fitnesse-results-inexistant.xml";
project.getPublishersList().add(new FitnesseResultsRecorder(resultsFile));

FreeStyleBuild build = project.scheduleBuild2(0).get();
Assert.assertTrue(build.getLogFile().getAbsolutePath(), Result.SUCCESS.equals(build.getResult()));
FitnesseResultsAction resultsAction = build.getAction(FitnesseResultsAction.class);
Assert.assertNull(resultsAction);
}
}

0 comments on commit f9552c5

Please sign in to comment.
You can’t perform that action at this time.