diff --git a/pmd-compat6/src/it/pmd-for-java/invoker.properties b/pmd-compat6/src/it/pmd-for-java/invoker.properties index 0d92d959f3..bfaaa1661c 100644 --- a/pmd-compat6/src/it/pmd-for-java/invoker.properties +++ b/pmd-compat6/src/it/pmd-for-java/invoker.properties @@ -1,2 +1,4 @@ -invoker.goals = verify +invoker.goals.1 = verify +invoker.goals.2 = pmd:check -Dformat=csv +invoker.goals.3 = pmd:check -Dformat=txt invoker.buildResult = failure diff --git a/pmd-compat6/src/it/pmd-for-java/verify.bsh b/pmd-compat6/src/it/pmd-for-java/verify.bsh index f148872c0e..f0325f4c97 100644 --- a/pmd-compat6/src/it/pmd-for-java/verify.bsh +++ b/pmd-compat6/src/it/pmd-for-java/verify.bsh @@ -14,13 +14,15 @@ String readFile(File file) throws IOException { File buildLogPath = new File(basedir, "build.log"); String buildLog = readFile(buildLogPath); +if (buildLog.contains("An API incompatibility was encountered while")) { + throw new RuntimeException("Executing failed due to API incompatibility"); +} if (!buildLog.contains("[INFO] PMD Failure: org.example.Main:5 Rule:UnusedLocalVariable")) { throw new RuntimeException("No pmd violation detected, did PMD run?"); } File pmdXmlReport = new File(basedir, "target/pmd.xml"); -if(!pmdXmlReport.exists()) -{ +if(!pmdXmlReport.exists()) { throw new FileNotFoundException("Could not find pmd xml report: " + pmdXmlReport); } String pmdXml = readFile(pmdXmlReport); @@ -31,3 +33,21 @@ File mainFile = new File("pmd-for-java/src/main/java/org/example/Main.java"); if (!pmdXml.contains(mainFile + "\">")) { throw new RuntimeException("Expected violation has not been reported"); } + +File pmdCsvReport = new File(basedir, "target/pmd.csv"); +if (!pmdCsvReport.exists()) { + throw new FileNotFoundException("Could not find pmd CSV report: " + pmdCsvReport); +} +String csvReport = readFile(pmdCsvReport); +if (!csvReport.contains(mainFile + "\",\"3\",\"5\",\"Avoid unused local")) { + throw new RuntimeException("Expected violation has not been reported in CSV"); +} + +File pmdTextReport = new File(basedir, "target/pmd.txt"); +if (!pmdTextReport.exists()) { + throw new FileNotFoundException("Could not find pmd TXT report: " + pmdTextReport); +} +String textReport = readFile(pmdTextReport); +if (!textReport.contains(mainFile + ":5:\tUnusedLocalVariable")) { + throw new RuntimeException("Expected violation has not been reported in TXT"); +}