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

Test task and '-XstartOnFirstThread' makes gradle hang #864

Closed
nedtwigg opened this issue Nov 15, 2016 · 5 comments · Fixed by #17382 or #17753
Closed

Test task and '-XstartOnFirstThread' makes gradle hang #864

nedtwigg opened this issue Nov 15, 2016 · 5 comments · Fixed by #17382 or #17753

Comments

@nedtwigg
Copy link
Contributor

Expected Behavior

When test has specified the following arguments:

test {
    jvmArgs '-XstartOnFirstThread'
}

the JUnit test cases should be started on the first thread.

Current Behavior

The tests do not start on the first thread.

Context

This is required for SWT tests to run on mac.

As of May 2016, the Gradle test VM is started by org.gradle.api.internal.tasks.testing.worker.ForkingTestClassProcessor which uses org.gradle.process.internal.worker.DefaultWorkerProcessBuilder to create a WorkerProcess and start it.
All this is called from org.gradle.api.internal.tasks.testing.detection.DefaultTestExecuter.

Steps to Reproduce (for bugs)

git clone https://github.com/diffplug/durian-swt
cd durian-swt
git checkout macGradleRepro
gradlew test

Your Environment

Any version of macOS.

@fab1an
Copy link

fab1an commented Jan 22, 2017

I started the test using ./gradlew test --info and got the following:

/* I inserted newlines for better readability */

Starting process 'Gradle Test Executor 1'. Working directory: <mydirectory> 
Command: /Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/bin/java 
-Djava.awt.headless=true
-Djava.security.manager=worker.org.gradle.process.internal.worker.child.BootstrapSecurityManager 
-Xmx512m 
-Dfile.encoding=UTF-8 
-Duser.country=US 
-Duser.language=en 
-Duser.variant 
-ea 
-cp /Users/MyUser/.gradle/caches/2.14.1/workerMain/gradle-worker.jar worker.org.gradle.process.internal.worker.GradleWorkerMain 'Gradle Test Executor 1'

When I run this command manually, and press ⏎ I get this:

Error occurred during initialization of VM
java.lang.ExceptionInInitializerError
	at java.lang.ClassLoader.initSystemClassLoader(ClassLoader.java:1451)
	at java.lang.ClassLoader.getSystemClassLoader(ClassLoader.java:1436)
Caused by: java.lang.RuntimeException: Could not initialise system classpath.
	at worker.org.gradle.process.internal.worker.child.BootstrapSecurityManager.checkPermission(BootstrapSecurityManager.java:81)
	at java.lang.SecurityManager.checkPropertyAccess(SecurityManager.java:1294)
	at java.lang.System.getProperty(System.java:717)
	at sun.misc.Launcher.<clinit>(Launcher.java:59)
	at java.lang.ClassLoader.initSystemClassLoader(ClassLoader.java:1451)
	at java.lang.ClassLoader.getSystemClassLoader(ClassLoader.java:1436)
Caused by: java.io.IOException: Unexpected value 10 received. It seems the stream was not encoded correctly.
	at worker.org.gradle.process.internal.streams.EncodedStream$EncodedInput.hexToByte(EncodedStream.java:59)
	at worker.org.gradle.process.internal.streams.EncodedStream$EncodedInput.read(EncodedStream.java:49)
	at java.io.DataInputStream.readInt(DataInputStream.java:387)
	at worker.org.gradle.process.internal.worker.child.BootstrapSecurityManager.checkPermission(BootstrapSecurityManager.java:67)
	at java.lang.SecurityManager.checkPropertyAccess(SecurityManager.java:1294)
	at java.lang.System.getProperty(System.java:717)
	at sun.misc.Launcher.<clinit>(Launcher.java:59)
	at java.lang.ClassLoader.initSystemClassLoader(ClassLoader.java:1451)
	at java.lang.ClassLoader.getSystemClassLoader(ClassLoader.java:1436)

robeden pushed a commit to glazedlists/glazedlists that referenced this issue Jun 13, 2017
There is a Gradle bug (gradle/gradle#864)
which prevents the "-XstartOnFirstThread" from working correctly and
thus prevents SWT unit tests from function on Mac. Since we're unable
to work around the Gradle issue, I've made this task exit with a
descriptive error when run on Mac. The instructions detail how to
suppress the SWT tests so that all other unit tests can be run.

Relates to: #636
@stale
Copy link

stale bot commented Jul 1, 2020

This issue has been automatically marked as stale because it has not had recent activity. Given the limited bandwidth of the team, it will be automatically closed if no further activity occurs. If you're interested in how we try to keep the backlog in a healthy state, please read our blog post on how we refine our backlog. If you feel this is something you could contribute, please have a look at our Contributor Guide. Thank you for your contribution.

@stale stale bot added the stale label Jul 1, 2020
@stale
Copy link

stale bot commented Jul 22, 2020

This issue has been automatically closed due to inactivity. If you can reproduce this on a recent version of Gradle or if you have a good use case for this feature, please feel free to reopen the issue with steps to reproduce, a quick explanation of your use case or a high-quality pull request.

@stale stale bot closed this as completed Jul 22, 2020
nedtwigg added a commit to nedtwigg/gradle that referenced this issue Jun 8, 2021
…ts which need -XstartOnFirstThread can work.

Issue: gradle#864
Signed-off-by: Ned Twigg <ned.twigg@diffplug.com>
@nedtwigg
Copy link
Contributor Author

nedtwigg commented Jun 8, 2021

I submitted a PR which fixes this issue.

@ljacomet
Copy link
Member

ljacomet commented Jul 9, 2021

Re-opening since there is an PR open to fix this.

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