michael-o commented on PR #144:
URL: https://github.com/apache/maven-pmd-plugin/pull/144#issuecomment-2094371392
This change introduced now a failing test which did no bubble up in CI, but
should have:
```
[INFO] Running org.apache.maven.plugins.pmd.CpdReportTest
org.apache.maven.reporting.MavenReportException: Can't find CPD custom
format xhtml: java.lang.ClassNotFoundException
at
org.apache.maven.plugins.pmd.exec.CpdExecutor.createRenderer(CpdExecutor.java:251)
at
org.apache.maven.plugins.pmd.exec.CpdExecutor.writeFormattedReport(CpdExecutor.java:226)
at
org.apache.maven.plugins.pmd.exec.CpdExecutor.lambda$run$1(CpdExecutor.java:181)
at
net.sourceforge.pmd.cpd.CpdAnalysis.performAnalysis(CpdAnalysis.java:203)
at
org.apache.maven.plugins.pmd.exec.CpdExecutor.run(CpdExecutor.java:174)
at
org.apache.maven.plugins.pmd.exec.CpdExecutor.execute(CpdExecutor.java:64)
at
org.apache.maven.plugins.pmd.CpdReport.executeCpd(CpdReport.java:204)
at
org.apache.maven.plugins.pmd.CpdReport.canGenerateReport(CpdReport.java:156)
at
org.apache.maven.reporting.AbstractMavenReport.execute(AbstractMavenReport.java:143)
at
org.apache.maven.plugins.pmd.AbstractPmdReportTestCase.generateReport(AbstractPmdReportTestCase.java:119)
at
org.apache.maven.plugins.pmd.CpdReportTest.testInvalidFormat(CpdReportTest.java:129)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at junit.framework.TestCase.runTest(TestCase.java:177)
at junit.framework.TestCase.runBare(TestCase.java:142)
at junit.framework.TestResult$1.protect(TestResult.java:122)
at junit.framework.TestResult.runProtected(TestResult.java:142)
at junit.framework.TestResult.run(TestResult.java:125)
at junit.framework.TestCase.run(TestCase.java:130)
at junit.framework.TestSuite.runTest(TestSuite.java:241)
at junit.framework.TestSuite.run(TestSuite.java:236)
at
org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:90)
at
org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:316)
at
org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:240)
at
org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:214)
at
org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:155)
at
org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:385)
at
org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:162)
at
org.apache.maven.surefire.booter.ForkedBooter.run(ForkedBooter.java:507)
at
org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:495)
Caused by: java.lang.ClassNotFoundException: xhtml
at java.net.URLClassLoader.findClass(URLClassLoader.java:387)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at
org.apache.maven.plugins.pmd.exec.CpdExecutor.createRenderer(CpdExecutor.java:247)
... 31 more
```
Verififed against `maven-pmd-plugin-3.21.2`.
The acutal reason is this change:
```
+ } catch (MavenReportException e) {
+ LOG.error("Error while writing CPD report", e);
+ }
```
and the reason why it does not bubble up is because
`org.apache.maven.plugins.pmd.CpdReportTest.testInvalidFormat()` does
```
} catch (Exception e) {
assertTrue(true);
}
```
There is an exception thrown because the test file des not set
`localRepository` parameter:
```
D:\Entwicklung\Projekte\maven-pmd-plugin [master ≡ +0 ~1 -0 !]> git diff -U0
diff --git
a/src/test/resources/unit/invalid-format/cpd-invalid-format-plugin-config.xml
b/src/test/resources/unit/invalid-format/cpd-invalid-format-plugin-config.xml
index e3cff6c2..aca6d08e 100644
---
a/src/test/resources/unit/invalid-format/cpd-invalid-format-plugin-config.xml
+++
b/src/test/resources/unit/invalid-format/cpd-invalid-format-plugin-config.xml
@@ -38,0 +39 @@ under the License.
+ <localRepository>${localRepository}</localRepository>
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]