1
0
forked from phoedos/pmd

[dist] Add integration test for --debug flag

This commit is contained in:
Andreas Dangel
2022-02-17 18:04:35 +01:00
parent ad86896682
commit c166613c0f
2 changed files with 23 additions and 0 deletions
pmd-dist/src/test/java/net/sourceforge/pmd/it

@ -93,6 +93,25 @@ public class BinaryDistributionIT extends AbstractBinaryDistributionTest {
result.assertExecutionResult(4, "");
}
@Test
public void logging() throws Exception {
String srcDir = new File(".", "src/test/resources/sample-source/java/").getAbsolutePath();
ExecutionResult result;
result = PMDExecutor.runPMD(tempDir, "-d", srcDir, "-R", "src/test/resources/rulesets/sample-ruleset.xml",
"-r", folder.newFile().toString());
result.assertExecutionResult(4);
result.assertErrorOutputContains("[main] INFO net.sourceforge.pmd.PMD - Loglevel is at INFO");
// now with debug
result = PMDExecutor.runPMD(tempDir, "-d", srcDir, "-R", "src/test/resources/rulesets/sample-ruleset.xml",
"-r", folder.newFile().toString(), "--debug");
result.assertExecutionResult(4);
result.assertErrorOutputContains("[main] DEBUG net.sourceforge.pmd.PMD - Loglevel is at DEBUG");
}
@Test
public void runCPD() throws Exception {
String srcDir = new File(".", "src/test/resources/sample-source-cpd/").getAbsolutePath();

@ -105,6 +105,10 @@ public class ExecutionResult {
report.contains(errorMessage));
}
public void assertErrorOutputContains(String message) {
assertTrue("erroroutput didn't contain " + message, errorOutput.contains(message));
}
static class Builder {
private int exitCode;
private String output;