Skip to content

Conversation

@elharo
Copy link
Contributor

@elharo elharo commented Dec 14, 2024

This cleanup revealed bugs in tests including in testInvalidTargetJdk and PmdViolationCheckMojoTest where the tests were incorrectly configured so the wrong exceptions were thrown. That is, the tests were in fact failing but this was hidden by an overly broad catch clause.

@elharo elharo changed the title IN progress, do not review: Remove unused code and otherwise cleanuop tests Remove unused code and otherwise cleanup tests Dec 14, 2024
@elharo elharo marked this pull request as ready for review December 14, 2024 12:38
@elharo elharo requested a review from michael-o December 14, 2024 12:38
@elharo
Copy link
Contributor Author

elharo commented Dec 15, 2024

Test passes locally. Not sure why it's failing in CI:

Error: org.apache.maven.plugins.pmd.CpdViolationCheckMojoTest.testException -- Time elapsed: 0.126 s <<< FAILURE!
junit.framework.AssertionFailedError: MojoFailureException should be thrown.

@elharo
Copy link
Contributor Author

elharo commented Dec 15, 2024

Also, all tests do appear to be passing on some of the builds, just not all of them.

@elharo
Copy link
Contributor Author

elharo commented Dec 15, 2024

Possibly only failing on Windows? Need a windows system to test on

@elharo elharo changed the title Remove unused code and otherwise cleanup tests [MPMD-412] Remove unused code and otherwise cleanup tests Dec 16, 2024
@michael-o michael-o removed their request for review December 31, 2024 16:16
@slachiewicz
Copy link
Member

is this still valid PR?

@slachiewicz slachiewicz added the waiting-for-feedback Waiting for 90 days until issues or pull request will be closed label Apr 8, 2025
@elharo
Copy link
Contributor Author

elharo commented Apr 8, 2025

I assume so. I seem to recall this one is hitting some problems on Windows, and I don't have a windows system handy to test

@github-actions github-actions bot removed the waiting-for-feedback Waiting for 90 days until issues or pull request will be closed label Apr 8, 2025
@Bukama
Copy link
Contributor

Bukama commented Apr 15, 2025

Branch fails for me on Windows 10

D:\Github\Maven\maven-pmd-plugin>git status
On branch test
Your branch is up to date with 'upstream/test'.

nothing to commit, working tree clean

D:\Github\Maven\maven-pmd-plugin>mvn --version
Apache Maven 4.0.0-rc-3 (3952d00ce65df6753b63a51e86b1f626c55a8df2)
Maven home: C:\apache-maven-4.0.0-rc-3
Java version: 21.0.1, vendor: Eclipse Adoptium, runtime: C:\JDK\Java21
Default locale: de_DE, platform encoding: UTF-8
OS name: "windows 10", version: "10.0", arch: "amd64", family: "winnt"

D:\Github\Maven\maven-pmd-plugin>mvn clean verify site -V
Apache Maven 4.0.0-rc-3 (3952d00ce65df6753b63a51e86b1f626c55a8df2)
Maven home: C:\apache-maven-4.0.0-rc-3
Java version: 21.0.1, vendor: Eclipse Adoptium, runtime: C:\JDK\Java21
Default locale: de_DE, platform encoding: UTF-8
OS name: "windows 10", version: "10.0", arch: "amd64", family: "winnt"
[INFO]
[INFO] 1 problem was encountered while building the effective settings (use -e to see details)
[INFO]
[WARNING] Unable to find the root directory. Create a .mvn directory in the root directory or add the root="true" attribute on the root project's model to identify it.
[INFO] Scanning for projects...
[INFO]
[INFO] --------------------------------------< org.apache.maven.plugins:maven-pmd-plugin >---------------------------------------
[INFO] Building Apache Maven PMD Plugin 3.26.1-SNAPSHOT
[INFO]   from pom.xml
[INFO] -----------------------------------------------------[ maven-plugin ]-----------------------------------------------------
[INFO]
[INFO] --- clean:3.4.0:clean (default-clean) @ maven-pmd-plugin ---
[INFO] Deleting D:\Github\Maven\maven-pmd-plugin\target
[INFO]
[INFO] --- enforcer:3.5.0:enforce (enforce-bytecode-version) @ maven-pmd-plugin ---
[INFO] Rule 0: org.codehaus.mojo.extraenforcer.dependencies.EnforceBytecodeVersion passed
[INFO]
[INFO] --- enforcer:3.5.0:enforce (enforce-maven-version) @ maven-pmd-plugin ---
[INFO] Rule 0: org.apache.maven.enforcer.rules.version.RequireMavenVersion passed
[INFO]
[INFO] --- enforcer:3.5.0:enforce (enforce-java-version) @ maven-pmd-plugin ---
[INFO] Rule 0: org.apache.maven.enforcer.rules.version.RequireJavaVersion passed
[INFO]
[INFO] --- enforcer:3.5.0:enforce (ensure-no-container-api) @ maven-pmd-plugin ---
[INFO] Rule 0: org.apache.maven.enforcer.rules.dependency.BannedDependencies passed
[INFO]
[INFO] --- plugin:3.13.1:helpmojo (generate-helpmojo) @ maven-pmd-plugin ---
[INFO]
[INFO] --- modello:2.4.0:java (default) @ maven-pmd-plugin ---
[INFO] outputDirectory: D:\Github\Maven\maven-pmd-plugin\target\generated-sources\modello
[INFO] Working on model: src/main/mdo/pmd.mdo
[INFO] Generating current version: 1.0
[INFO] Working on model: src/main/mdo/cpd.mdo
[INFO] Generating current version: 1.0
[INFO]
[INFO] --- modello:2.4.0:xpp3-reader (default) @ maven-pmd-plugin ---
[INFO] outputDirectory: D:\Github\Maven\maven-pmd-plugin\target\generated-sources\modello
[INFO] Working on model: src/main/mdo/pmd.mdo
[INFO] Generating current version: 1.0
[INFO] Working on model: src/main/mdo/cpd.mdo
[INFO] Generating current version: 1.0
[INFO]
[INFO] --- checkstyle:3.4.0:check (checkstyle-check) @ maven-pmd-plugin ---
[INFO] You have 0 Checkstyle violations.
[INFO]
[INFO] --- spotless:2.43.0:check (default) @ maven-pmd-plugin ---
[INFO] Index file does not exist. Fallback to an empty index
[INFO] Spotless.Java is keeping 40 files clean - 0 needs changes to be clean, 40 were already clean, 0 were skipped because caching determined they were already clean
[INFO] Sorting file C:\Users\matth\AppData\Local\Temp\pom5179293842041346236.xml
[INFO] Saved sorted pom file to C:\Users\matth\AppData\Local\Temp\pom5179293842041346236.xml
[INFO] Spotless.Pom is keeping 1 files clean - 0 needs changes to be clean, 1 were already clean, 0 were skipped because caching determined they were already clean
[INFO]
[INFO] --- remote-resources:3.2.0:process (process-resource-bundles) @ maven-pmd-plugin ---
[INFO] Preparing remote bundle org.apache.apache.resources:apache-jar-resource-bundle:1.5
[INFO] Copying 3 resources from 1 bundle.
[INFO]
[INFO] --- resources:3.3.1:resources (default-resources) @ maven-pmd-plugin ---
[INFO] Copying 18 resources from src\main\resources to target\classes
[INFO] skip non existing resourceDirectory D:\Github\Maven\maven-pmd-plugin\src\main\resources-filtered
[INFO] Copying 3 resources from target\maven-shared-archive-resources to target\classes
[INFO]
[INFO] --- apache-rat:0.16.1:check (rat-check) @ maven-pmd-plugin ---
[INFO] Rat check: Summary over all files. Unapproved: 0, unknown: 0, generated: 1, approved: 449 licenses.
[INFO]
[INFO] --- compiler:3.13.0:compile (default-compile) @ maven-pmd-plugin ---
[INFO] Recompiling the module because of changed source code.
[INFO] Compiling 37 source files with javac [debug deprecation release 8] to target\classes
[WARNING] Quellwert 8 ist veraltet und wird in einem zukünftigen Release entfernt
[WARNING] Zielwert 8 ist veraltet und wird in einem zukünftigen Release entfernt
[WARNING] Verwenden Sie -Xlint:-options, um Warnungen zu veralteten Optionen zu unterdrücken.
[WARNING] /D:/Github/Maven/maven-pmd-plugin/src/main/java/org/apache/maven/plugins/pmd/exec/CpdExecutor.java:[150,25] setSkipLexicalErrors(boolean) in net.sourceforge.pmd.cpd.CPDConfiguration ist veraltet
[INFO]
[INFO] --- plugin:3.13.1:descriptor (default-descriptor) @ maven-pmd-plugin ---
[INFO] Using 'UTF-8' encoding to read mojo source files.
[WARNING] Unresolvable link in javadoc tag with value SiteTool#DEFAULT_LOCALE found in target/maven-plugin-plugin-sources/org.apache.maven.reporting/maven-reporting-impl/4.0.0/sources/org/apache/maven/reporting/AbstractMavenReport.java:149: Could not resolve javadoc reference JavadocReference [moduleName=Optional.empty, packageNameClassName=Optional[SiteTool], member=Optional[DEFAULT_LOCALE], label=Optional.empty]
[WARNING] Unresolvable link in javadoc tag with value SiteTool#getSiteLocales(String) found in target/maven-plugin-plugin-sources/org.apache.maven.reporting/maven-reporting-impl/4.0.0/sources/org/apache/maven/reporting/AbstractMavenReport.java:149: Could not resolve javadoc reference JavadocReference [moduleName=Optional.empty, packageNameClassName=Optional[SiteTool], member=Optional[getSiteLocales(String)], label=Optional.empty]
[WARNING] Unresolvable link in javadoc tag with value #getOutputName() found in target/maven-plugin-plugin-sources/org.apache.maven.reporting/maven-reporting-impl/4.0.0/sources/org/apache/maven/reporting/AbstractMavenReport.java:92: Could not resolve javadoc reference JavadocReference [moduleName=Optional.empty, packageNameClassName=Optional.empty, member=Optional[getOutputName()], label=Optional.empty]
[WARNING] Unresolvable link in javadoc tag with value SiteTool#DEFAULT_LOCALE found in target/maven-plugin-plugin-sources/org.apache.maven.reporting/maven-reporting-impl/4.0.0/sources/org/apache/maven/reporting/AbstractMavenReport.java:149: Could not resolve javadoc reference JavadocReference [moduleName=Optional.empty, packageNameClassName=Optional[SiteTool], member=Optional[DEFAULT_LOCALE], label=Optional.empty]
[WARNING] Unresolvable link in javadoc tag with value SiteTool#getSiteLocales(String) found in target/maven-plugin-plugin-sources/org.apache.maven.reporting/maven-reporting-impl/4.0.0/sources/org/apache/maven/reporting/AbstractMavenReport.java:149: Could not resolve javadoc reference JavadocReference [moduleName=Optional.empty, packageNameClassName=Optional[SiteTool], member=Optional[getSiteLocales(String)], label=Optional.empty]
[WARNING] Unresolvable link in javadoc tag with value #getOutputName() found in target/maven-plugin-plugin-sources/org.apache.maven.reporting/maven-reporting-impl/4.0.0/sources/org/apache/maven/reporting/AbstractMavenReport.java:92: Could not resolve javadoc reference JavadocReference [moduleName=Optional.empty, packageNameClassName=Optional.empty, member=Optional[getOutputName()], label=Optional.empty]
[WARNING] Unresolvable link in javadoc tag with value SiteTool#DEFAULT_LOCALE found in target/maven-plugin-plugin-sources/org.apache.maven.reporting/maven-reporting-impl/4.0.0/sources/org/apache/maven/reporting/AbstractMavenReport.java:149: Could not resolve javadoc reference JavadocReference [moduleName=Optional.empty, packageNameClassName=Optional[SiteTool], member=Optional[DEFAULT_LOCALE], label=Optional.empty]
[WARNING] Unresolvable link in javadoc tag with value SiteTool#getSiteLocales(String) found in target/maven-plugin-plugin-sources/org.apache.maven.reporting/maven-reporting-impl/4.0.0/sources/org/apache/maven/reporting/AbstractMavenReport.java:149: Could not resolve javadoc reference JavadocReference [moduleName=Optional.empty, packageNameClassName=Optional[SiteTool], member=Optional[getSiteLocales(String)], label=Optional.empty]
[WARNING] Unresolvable link in javadoc tag with value #getOutputName() found in target/maven-plugin-plugin-sources/org.apache.maven.reporting/maven-reporting-impl/4.0.0/sources/org/apache/maven/reporting/AbstractMavenReport.java:92: Could not resolve javadoc reference JavadocReference [moduleName=Optional.empty, packageNameClassName=Optional.empty, member=Optional[getOutputName()], label=Optional.empty]
[WARNING] Unresolvable link in javadoc tag with value SiteTool#DEFAULT_LOCALE found in target/maven-plugin-plugin-sources/org.apache.maven.reporting/maven-reporting-impl/4.0.0/sources/org/apache/maven/reporting/AbstractMavenReport.java:149: Could not resolve javadoc reference JavadocReference [moduleName=Optional.empty, packageNameClassName=Optional[SiteTool], member=Optional[DEFAULT_LOCALE], label=Optional.empty]
[WARNING] Unresolvable link in javadoc tag with value SiteTool#getSiteLocales(String) found in target/maven-plugin-plugin-sources/org.apache.maven.reporting/maven-reporting-impl/4.0.0/sources/org/apache/maven/reporting/AbstractMavenReport.java:149: Could not resolve javadoc reference JavadocReference [moduleName=Optional.empty, packageNameClassName=Optional[SiteTool], member=Optional[getSiteLocales(String)], label=Optional.empty]
[WARNING] Unresolvable link in javadoc tag with value #getOutputName() found in target/maven-plugin-plugin-sources/org.apache.maven.reporting/maven-reporting-impl/4.0.0/sources/org/apache/maven/reporting/AbstractMavenReport.java:92: Could not resolve javadoc reference JavadocReference [moduleName=Optional.empty, packageNameClassName=Optional.empty, member=Optional[getOutputName()], label=Optional.empty]
[WARNING] Unresolvable link in javadoc tag with value SiteTool#DEFAULT_LOCALE found in target/maven-plugin-plugin-sources/org.apache.maven.reporting/maven-reporting-impl/4.0.0/sources/org/apache/maven/reporting/AbstractMavenReport.java:149: Could not resolve javadoc reference JavadocReference [moduleName=Optional.empty, packageNameClassName=Optional[SiteTool], member=Optional[DEFAULT_LOCALE], label=Optional.empty]
[WARNING] Unresolvable link in javadoc tag with value SiteTool#getSiteLocales(String) found in target/maven-plugin-plugin-sources/org.apache.maven.reporting/maven-reporting-impl/4.0.0/sources/org/apache/maven/reporting/AbstractMavenReport.java:149: Could not resolve javadoc reference JavadocReference [moduleName=Optional.empty, packageNameClassName=Optional[SiteTool], member=Optional[getSiteLocales(String)], label=Optional.empty]
[WARNING] Unresolvable link in javadoc tag with value #getOutputName() found in target/maven-plugin-plugin-sources/org.apache.maven.reporting/maven-reporting-impl/4.0.0/sources/org/apache/maven/reporting/AbstractMavenReport.java:92: Could not resolve javadoc reference JavadocReference [moduleName=Optional.empty, packageNameClassName=Optional.empty, member=Optional[getOutputName()], label=Optional.empty]
[WARNING] Unresolvable link in javadoc tag with value SiteTool#DEFAULT_LOCALE found in target/maven-plugin-plugin-sources/org.apache.maven.reporting/maven-reporting-impl/4.0.0/sources/org/apache/maven/reporting/AbstractMavenReport.java:149: Could not resolve javadoc reference JavadocReference [moduleName=Optional.empty, packageNameClassName=Optional[SiteTool], member=Optional[DEFAULT_LOCALE], label=Optional.empty]
[WARNING] Unresolvable link in javadoc tag with value SiteTool#getSiteLocales(String) found in target/maven-plugin-plugin-sources/org.apache.maven.reporting/maven-reporting-impl/4.0.0/sources/org/apache/maven/reporting/AbstractMavenReport.java:149: Could not resolve javadoc reference JavadocReference [moduleName=Optional.empty, packageNameClassName=Optional[SiteTool], member=Optional[getSiteLocales(String)], label=Optional.empty]
[WARNING] Unresolvable link in javadoc tag with value #getOutputName() found in target/maven-plugin-plugin-sources/org.apache.maven.reporting/maven-reporting-impl/4.0.0/sources/org/apache/maven/reporting/AbstractMavenReport.java:92: Could not resolve javadoc reference JavadocReference [moduleName=Optional.empty, packageNameClassName=Optional.empty, member=Optional[getOutputName()], label=Optional.empty]
[INFO] java-annotations mojo extractor found 10 mojo descriptors.
[INFO]
[INFO] --- animal-sniffer:1.24:check (check-java-1.8-compat) @ maven-pmd-plugin ---
[INFO] Checking unresolved references to org.codehaus.mojo.signature:java18:1.0
[INFO]
[INFO] --- resources:3.3.1:testResources (default-testResources) @ maven-pmd-plugin ---
[INFO] Copying 277 resources from src\test\resources to target\test-classes
[INFO] skip non existing resourceDirectory D:\Github\Maven\maven-pmd-plugin\src\test\resources-filtered
[INFO] Copying 3 resources from target\maven-shared-archive-resources to target\test-classes
[INFO]
[INFO] --- compiler:3.13.0:testCompile (default-testCompile) @ maven-pmd-plugin ---
[INFO] Recompiling the module because of changed dependency.
[INFO] Compiling 14 source files with javac [debug deprecation release 8] to target\test-classes
[WARNING] Quellwert 8 ist veraltet und wird in einem zukünftigen Release entfernt
[WARNING] Zielwert 8 ist veraltet und wird in einem zukünftigen Release entfernt
[WARNING] Verwenden Sie -Xlint:-options, um Warnungen zu veralteten Optionen zu unterdrücken.
[INFO]
[INFO] --- surefire:3.3.0:test (default-test) @ maven-pmd-plugin ---
[INFO] Using auto detected provider org.apache.maven.surefire.junit4.JUnit4Provider
[INFO]
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running org.apache.maven.plugins.pmd.CpdReportTest
[INFO] Tests run: 13, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 3.865 s -- in org.apache.maven.plugins.pmd.CpdReportTest
[INFO] Running org.apache.maven.plugins.pmd.CpdViolationCheckMojoTest
[ERROR] Tests run: 4, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.377 s <<< FAILURE! -- in org.apache.maven.plugins.pmd.CpdViolationCheckMojoTest
[ERROR] org.apache.maven.plugins.pmd.CpdViolationCheckMojoTest.testException -- Time elapsed: 0.048 s <<< FAILURE!
junit.framework.AssertionFailedError: MojoFailureException should be thrown.
        at junit.framework.Assert.fail(Assert.java:57)
        at junit.framework.TestCase.fail(TestCase.java:223)
        at org.apache.maven.plugins.pmd.CpdViolationCheckMojoTest.testException(CpdViolationCheckMojoTest.java:68)
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
        at java.base/java.lang.reflect.Method.invoke(Method.java:580)
        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)

[INFO] Running org.apache.maven.plugins.pmd.exec.ExecutorTest
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.001 s -- in org.apache.maven.plugins.pmd.exec.ExecutorTest
[INFO] Running org.apache.maven.plugins.pmd.PmdReportTest
[INFO] Tests run: 26, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 9.431 s -- in org.apache.maven.plugins.pmd.PmdReportTest
[INFO] Running org.apache.maven.plugins.pmd.PmdViolationCheckMojoTest
[INFO] Tests run: 6, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.661 s -- in org.apache.maven.plugins.pmd.PmdViolationCheckMojoTest
[INFO]
[INFO] Results:
[INFO]
[ERROR] Failures:
[ERROR]   CpdViolationCheckMojoTest.testException:68 MojoFailureException should be thrown.
[INFO]
[ERROR] Tests run: 50, Failures: 1, Errors: 0, Skipped: 0
[INFO]
[INFO] --------------------------------------------------------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] --------------------------------------------------------------------------------------------------------------------------
[INFO] Total time:  36.845 s
[INFO] Finished at: 2025-04-15T21:13:35+02:00
[INFO] --------------------------------------------------------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.3.0:test (default-test) on project maven-pmd-plugin: There are test failures.
[ERROR]
[ERROR] Please refer to D:\Github\Maven\maven-pmd-plugin\target\surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the '-e' switch
[ERROR] Re-run Maven using the '-X' switch to enable verbose output
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

@elharo elharo requested review from Bukama and slachiewicz April 20, 2025 19:48
Copy link
Contributor Author

@elharo elharo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PTAL. I've split these changes into several PRs. The changes remaining in this PR no longer trip the issue on Windows.

@elharo elharo merged commit 010a1b1 into master Apr 21, 2025
51 checks passed
@elharo elharo deleted the test branch April 21, 2025 18:55
@github-actions github-actions bot added this to the 3.26.1 milestone Apr 21, 2025
@jira-importer
Copy link

Resolve #379

1 similar comment
@jira-importer
Copy link

Resolve #379

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants