Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

surefire.forkNumber undefined variable #1884

Open
r6squeegee opened this issue Nov 2, 2024 · 4 comments
Open

surefire.forkNumber undefined variable #1884

r6squeegee opened this issue Nov 2, 2024 · 4 comments

Comments

@r6squeegee
Copy link

r6squeegee commented Nov 2, 2024

surefire.forkNumber generates an error when junit test is run from with in eclipse.

Basically in a pom.xml surefire plugin section, you can configure to fork. This works on the command line using mvn directly, this also worked in prior versions of eclipse. I'm unsure when it broke but I think it was with in the last month or so.

Reverting back to a much earlier version of eclipse (the only one I had was 2024-03) shows it worked back then.

The reason I didn't notice it the day it happened was because you must right click the project -> maven -> update project, before it breaks (or after you install a new eclipse), if your system was working with an older version it would continue working until you had to do an update-project.

attached as a simple project showing this.

dialog

project zipped : temp.zip

To un-break it, you have to downgrade to an older version of eclipse and delete the working directories .metadata directory or it will continue to appear broken even on older versions.

We also tested jdk 17,21,23 and it happens on all versions. It happened on multiple fedora 40 machines. It happened with both the eclipse-installer with bundled jdk and binary untar-gz versions with separately downloaded openjdks.

the download was tagged eclipse-jee-2024-09-R-linux-gtk-x86_64.tar.gz

the relavant part of the pom (it's in the zip file) is as follows :

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>-Xmx1g -Duser.timezone=UTC</argLine>
<trimStackTrace>false</trimStackTrace>
<runOrder>alphabetical</runOrder>
<forkCount>1</forkCount>
<reuseForks>true</reuseForks>
<systemPropertyVariables>
<forkQualifier>_${surefire.forkNumber}</forkQualifier>
<!-- 						<forkQualifier>_1</forkQualifier>  -->
</systemPropertyVariables>
</configuration>
</plugin>
@merks
Copy link
Contributor

merks commented Nov 2, 2024

Have you tried my suggestion to define a corresponding variable in Window -> Preferences -> Run/Debug -> String Substitutions. That definitely will solve the problem.

@r6squeegee
Copy link
Author

the problem isn't working around it, the problem is a regression in functionality.

I believe I can also work around it by adding -DDEV to the jvm run parameters.

@merks
Copy link
Contributor

merks commented Nov 2, 2024

Have you looked at the launch configuration itself? I expect it will contain the ${surefire.forkNumber} in the VM or Progres args section. It may well be that adding this is a regression or maybe it's an enhancement. I just wanted to be sure your not blocked until there is an answer and/or a fix...

@r6squeegee
Copy link
Author

r6squeegee commented Nov 2, 2024

yes, in the run configuration -> arguments -> vm arguments it is populated with

-DforkQualifier=_${surefire.forkNumber}

and yes, if I manually remove that, it will run again.

The easier work around is for me to just set the forking to 1 and hard code the fork count instead of using the forkNumber right now. The reason being - that vm argument is auto generated /added by eclipse every time you run a junit test for the first time.

So effectively every time some one runs a junit test, instead of just right clicking -> run as junit, they would have to right-click -> run junit, watch it fail, right-click -> run configuration -> remove argument -> run.

Thanks for the concern about this blocking me. I'm not blocked, I've just hard coded it to 1 thread and the number 1, and it works for all our developers with out any additional effort for any of them. (the performance difference for forking v.s. non-forking was not significant for us anyways.)

I just wanted to lodge this issue as it seems like no one else had run into it yet (and it took us quite a while to narrow it down to this, we though we broke it with something we did). It also means that anyone else using any surefire variables (or possibly any other plugins with any other variables) will also no longer work for the same reason. So while my problem was trivial to work around, it may be more significant for other people.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants