Skip to content

Conversation

sormuras
Copy link
Member

@sormuras sormuras commented Sep 2, 2025

Please review this change to use JUnit in tests of test/langtools/tools/javac.

Assess Status Quo

A local make test TEST=test/langtools/tools/javac run before the conversion yields:

Test results: passed: 3,938; excluded: 4; did not match keywords: 2; did not meet platform requirements: 2
Framework-based tests: 3043 = 2762 TestNG + 281 JUnit

Perform Automatic Conversion

Perform Manual Adjustments

Some of the following adjustments will be integrated into the junit-convert tool.

Make argument source factory method static

Method 'public java.lang.Object[][] org.openjdk.tests.javac.FDTest.caseGenerator()'
  must be static: local factory methods must be static
  unless the PER_CLASS @testinstance lifecycle mode is used;
  external factory methods must always be static.

Make @AfterAll-annotated method static

[ERROR] @afterall method 'public void org.openjdk.tests.vm.FDSeparateCompilationTest.cleanupCompilerCache()'
  must be static unless the test class
  is annotated with `@TestInstance(Lifecycle.PER_CLASS)`.

Remove static modifier from @Test-annotated methods

This configuration error should have been detected by JUnit Jupiter and reported via the Discovery
Issues API: https://docs.junit.org/current/user-guide/#running-tests-discovery-issues

Rename test property to JUnit.dirs

package org.junit.jupiter.api does not exist

Prune extra contructors

Class [FDTests] must declare a single constructor
Class [MethodReferenceTestKinds] must declare a single constructor

Initially by adding custom test instance factory to help JUnit select the correct constructor.
Now by deleting all-but-one constructor to used by file-local code and JUnit alike.

Results

Re-run tests via make test TEST=test/langtools/tools/javac after the conversion; yielding:

Test results: passed: 3,939; excluded: 4; did not match keywords: 2; did not meet platform requirements: 2
Framework-based tests: 3043 = 0 TestNG + 3043 JUnit

Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8366678: Use JUnit in test/langtools/tools/javac (Sub-task - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/27046/head:pull/27046
$ git checkout pull/27046

Update a local copy of the PR:
$ git checkout pull/27046
$ git pull https://git.openjdk.org/jdk.git pull/27046/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 27046

View PR using the GUI difftool:
$ git pr show -t 27046

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/27046.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Sep 2, 2025

👋 Welcome back cstein! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Sep 2, 2025

@sormuras This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8366678: Use JUnit in test/langtools/tools/javac

Reviewed-by: liach

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been no new commits pushed to the master branch. If another commit should be pushed before you perform the /integrate command, your PR will be automatically rebased. If you prefer to avoid any potential automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk
Copy link

openjdk bot commented Sep 2, 2025

@sormuras this pull request can not be integrated into master due to one or more merge conflicts. To resolve these merge conflicts and update this pull request you can run the following commands in the local repository for your personal fork:

git checkout JDK-8366678-use-junit-in-javac-tests
git fetch https://git.openjdk.org/jdk.git master
git merge FETCH_HEAD
# resolve conflicts and follow the instructions given by git merge
git commit -m "Merge master"
git push

@openjdk openjdk bot added the merge-conflict Pull request has merge conflict with target branch label Sep 2, 2025
@openjdk
Copy link

openjdk bot commented Sep 2, 2025

@sormuras The following label will be automatically applied to this pull request:

  • compiler

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@sormuras sormuras force-pushed the JDK-8366678-use-junit-in-javac-tests branch from 5bb112e to 0b0cac1 Compare September 2, 2025 12:53
@openjdk openjdk bot removed the merge-conflict Pull request has merge conflict with target branch label Sep 2, 2025
- Make argument source factory method `static`

Solves:
```
Method 'public java.lang.Object[][] org.openjdk.tests.javac.FDTest.caseGenerator()'
  must be static: local factory methods must be static
  unless the PER_CLASS @testinstance lifecycle mode is used;
  external factory methods must always be static.
```

- Make `@AfterAll`-annotated method `static`

Solves:
```
[ERROR] @afterall method 'public void org.openjdk.tests.vm.FDSeparateCompilationTest.cleanupCompilerCache()'
  must be static unless the test class
  is annotated with `@TestInstance(Lifecycle.PER_CLASS)`.
```

- Rename test property to `JUnit.dirs`

Solves:
```
package org.junit.jupiter.api does not exist
```

- Add custom test instance factory

Solves:
```
Class [FDTests] must declare a single constructor
Class [MethodReferenceTestKinds] must declare a single constructor
```
This configuration error should have been detected
by JUnit Jupiter and reported via the Discovery
Issues API:

https://docs.junit.org/current/user-guide/#running-tests-discovery-issues
@sormuras sormuras marked this pull request as ready for review September 3, 2025 13:07
@openjdk openjdk bot added the rfr Pull request is ready for review label Sep 3, 2025
@mlbridge
Copy link

mlbridge bot commented Sep 3, 2025

Webrevs

@liach
Copy link
Member

liach commented Sep 3, 2025

Please run bash make/scripts/update_copyright_year.sh -b 31847149c1956b23c19a99309982660b4bbdd2d6 to update your copyright years.

That way, Jupiter doesn't need the help of a custom test instance factory
@sormuras sormuras changed the base branch from master to pr/26261 September 4, 2025 21:11
Copy link
Member

@liach liach left a comment

Choose a reason for hiding this comment

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

The actual changes look good - unfortunately github does not show the correct ... diff.

@openjdk-notifier openjdk-notifier bot changed the base branch from pr/26261 to master September 18, 2025 12:19
@openjdk-notifier
Copy link

The parent pull request that this pull request depends on has now been integrated and the target branch of this pull request has been updated. This means that changes from the dependent pull request can start to show up as belonging to this pull request, which may be confusing for reviewers. To remedy this situation, simply merge the latest changes from the new target branch into this pull request by running commands similar to these in the local repository for your personal fork:

git checkout JDK-8366678-use-junit-in-javac-tests
git fetch https://git.openjdk.org/jdk.git master
git merge FETCH_HEAD
# if there are conflicts, follow the instructions given by git merge
git commit -m "Merge master"
git push

@openjdk openjdk bot added the merge-conflict Pull request has merge conflict with target branch label Sep 18, 2025
…nit-in-javac-tests

# Conflicts:
#	test/jdk/java/security/SignedJar/spi-calendar-provider/TestSPISigned.java
Copy link
Member

@liach liach left a comment

Choose a reason for hiding this comment

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

Merge looks trivial

@openjdk openjdk bot added ready Pull request is ready to be integrated and removed merge-conflict Pull request has merge conflict with target branch labels Sep 18, 2025
@sormuras
Copy link
Member Author

/integrate

@openjdk
Copy link

openjdk bot commented Sep 22, 2025

Going to push as commit 682fd78.
Since your change was applied there have been 43 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Sep 22, 2025
@openjdk openjdk bot closed this Sep 22, 2025
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Sep 22, 2025
@openjdk
Copy link

openjdk bot commented Sep 22, 2025

@sormuras Pushed as commit 682fd78.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@sormuras sormuras deleted the JDK-8366678-use-junit-in-javac-tests branch September 22, 2025 06:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

compiler [email protected] integrated Pull request has been integrated

Development

Successfully merging this pull request may close these issues.

3 participants