Skip to content
This repository has been archived by the owner on Nov 14, 2017. It is now read-only.

Commit

Permalink
Merge pull request #6 from cpfeiffer/no_results_found
Browse files Browse the repository at this point in the history
Avoid NPE when build aborts prematurely and produces no results
  • Loading branch information
swestcott committed May 3, 2012
2 parents c01c78f + f9552c5 commit 47864bc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
13 changes: 13 additions & 0 deletions src/test/java/hudson/plugins/fitnesse/HudsonDependentTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 47864bc

Please sign in to comment.