Skip to content

Commit

Permalink
fix #38 Save a reportfile even when there are no problems
Browse files Browse the repository at this point in the history
including test
  • Loading branch information
Crydust authored and Kristof Neirynck committed Oct 26, 2015
1 parent e5ce4ec commit 69e3aaf
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/java/com/cj/jshintmojo/Mojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,8 @@ private void handleResults(final Map<String, Result> currentResults,
}
}

saveReportFile(currentResults, reporter, reportFile);
if(numProblematicFiles > 0) {
saveReportFile(currentResults, reporter, reportFile);

String errorMessage = "\nJSHint found problems with " + numProblematicFiles + " file";

Expand Down
19 changes: 19 additions & 0 deletions src/test/java/com/cj/jshintmojo/MojoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,25 @@ public void walksTheDirectoryTreeToFindAndUseJshintFiles() throws Exception {
}
}
}

@Test
public void savesReportEvenWhenThereAreNoProblems() throws Exception {
// given
File directory = tempDir();
File reportFile = new File(directory, "reportFile");

LogStub log = new LogStub();
Mojo mojo = new Mojo("", "",
directory,
Collections.singletonList(""),
Collections.<String>emptyList(),true, null, "jslint", reportFile.getAbsolutePath(), null);
mojo.setLog(log);
// when
mojo.execute();
// then
assertTrue("Saves report", log.hasMessage("info",
"Generating \"JSHint\" report. reporter=jslint, reportFile="+reportFile.getAbsolutePath()+"."));
}

@Test
public void warnsUsersWhenConfiguredToWorkWithNonexistentDirectories() throws Exception {
Expand Down

0 comments on commit 69e3aaf

Please sign in to comment.