Solution to "Incorrect config file cause CLI finish with error but no output with details" solves #1180
This commit is contained in:
parent
1eb344dc82
commit
fe6db3ab8a
|
|
@ -101,10 +101,9 @@ public final class Main {
|
|||
System.out.println(pex.getMessage());
|
||||
printUsage();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
// smth wrong during processing
|
||||
catch (CheckstyleException e) {
|
||||
errorCounter = 1;
|
||||
throw ex;
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
finally {
|
||||
// return exit code base on validation of Checker
|
||||
|
|
|
|||
|
|
@ -114,7 +114,8 @@ public class MainTest {
|
|||
exit.expectSystemExitWithStatus(1);
|
||||
exit.checkAssertionAfterwards(new Assertion() {
|
||||
public void checkAssertion() {
|
||||
assertEquals("Checkstyle ends with 1 errors." + System.lineSeparator(),
|
||||
assertEquals(String.format("unable to find src/main/resources/non_existing_config.xml%n"
|
||||
+ "Checkstyle ends with 1 errors.%n"),
|
||||
standardLog.getLog());
|
||||
assertEquals("", errorLog.getLog());
|
||||
}
|
||||
|
|
@ -335,4 +336,20 @@ public class MainTest {
|
|||
"-p", "nonexisting.properties",
|
||||
"src/test/resources/com/puppycrawl/tools/checkstyle/InputMain.java");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExistingIncorrectConfigFile()
|
||||
throws Exception {
|
||||
exit.expectSystemExitWithStatus(1);
|
||||
exit.checkAssertionAfterwards(new Assertion() {
|
||||
public void checkAssertion() {
|
||||
assertEquals(String.format("unable to parse configuration stream - Content is not allowed in prolog.:7:1%n"
|
||||
+ "Checkstyle ends with 1 errors.%n"), standardLog.getLog());
|
||||
assertEquals("", errorLog.getLog());
|
||||
}
|
||||
});
|
||||
Main.main("-c", "src/test/resources/com/puppycrawl/tools/checkstyle/"
|
||||
+ "config-Incorrect.xml",
|
||||
"src/test/resources/com/puppycrawl/tools/checkstyle/InputMain.java");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!DOCTYPE module PUBLIC
|
||||
"-//Puppy Crawl//DTD Check Configuration 1.1//EN"
|
||||
"http://www.puppycrawl.com/dtds/configuration_1_1.dtd">
|
||||
|
||||
#<module name="Checker">
|
||||
<module name="TreeWalker">
|
||||
<module name="TypeName">
|
||||
<property name="severity" value="warning"/>
|
||||
</module>
|
||||
</module>
|
||||
</module>
|
||||
Loading…
Reference in New Issue