Slackbot
09/14/2022, 10:42 AMVladimir Sitnikov
09/14/2022, 10:43 AM./gradlew.bat --stop
in-between the tests, however, it stops all the daemons, not just idle ones, so the build terminatesVladimir Sitnikov
09/14/2022, 10:44 AM--no-daemon
is not supported by GradleRunner
, and org.gradle.daemon=false
makes no difference eithergrossws
09/14/2022, 10:44 AM--no-daemon
to runner args along with tasks doesn't help?Vladimir Sitnikov
09/14/2022, 10:45 AM--no-daemon
is explicitly unsupported in GradleRunner
, and it just throws an errorThomas Broyer
09/14/2022, 10:51 AM--stop
in between tests (I personally use a job matrix so those tests can run in parallel)Vladimir Sitnikov
09/14/2022, 10:58 AMmelix
09/14/2022, 11:10 AMSystem.exit(0)
in the context of a build under test?Fleshgrinder
09/14/2022, 11:21 AMThe TestKit uses dedicated daemon processes that are automatically shut down after test execution.
— https://docs.gradle.org/current/userguide/test_kit.html#sec:controlling_the_build_environmentI stopped using TestKit and instead use Java
ProcessBuilder
to start an actual Gradle build. There simply are too many things that do not work properly in TestKit and one ends up doing more debugging of it, instead of testing. I recommend to do the same here, as it is going to unlock what you need.Tapchicoma
09/14/2022, 12:56 PMtearDown()
- ConnectorServices.reset()
. But this will stop all currently running Gradle daemons, so may not work for you if you are running tests in parallelVladimir Sitnikov
09/14/2022, 7:23 PM((DefaultGradleRunner) runner).withJvmArguments("-Xmx1024m")
, however it did not help either.
So I just stopped, and I excluded “windows + java8” from CI matrix.
@Fleshgrinder, do you think you could suggest pointers to “no-testkit” style of writing tests? I can imagine several ways, however, I don’t want to reinvent the wheel :)Fleshgrinder
09/15/2022, 6:38 AMGradleRunner
because repositories cannot be changed at all with it. Another huge issue is that Gradle keeps locking things all over and relies on the advisory locking of POSIX systems, which obviously fails miserably too on systems with mandatory locking (e.g. Windows). The testing kit that is based on Java's ProcessBuilder
solves all issues. Builds work exactly as you think they work. Concurrent/parallel execution is no problem at all, since each build is hermetic. The Gradle process either finishes successfully, fails, or gets killed by a timeout. Piping input is no problem, so, testing of interactive things is no problem either.
The only downside (if it can be considered one) is that you cannot access the outcome of individual tasks. This would require some output parser, which is doable, but probably going to be fragile over time. I use https://strikt.io/ which has many great assertions for working with text. I either check the output with contains
and matches
or massage the output so that the build only prints what I actually need, then I can use isEqualTo
. Attached is an example test for a closed source custom Gradle distribution (there's nothing special in this, so posting it won't disclose anything interesting other than the company). Note that I'm running all tests in parallel on my AMD Ryzen 9 3900X (24 tests at the same time) on Windows (mandatory locking) without any hick-up.Fleshgrinder
09/15/2022, 7:46 AMFleshgrinder
09/15/2022, 7:50 AMFleshgrinder
09/15/2022, 9:40 AMFleshgrinder
09/15/2022, 9:42 AMGRADLE_USER_HOME
and --no-daemon
. 🤷Fleshgrinder
09/15/2022, 10:18 AMjunit.jupiter.execution.parallel.config.dynamic.factor=0.5
seems to resolve the issue on Linux. I'll continue working on this. 😉
Not running tests in parallel always works, no matter what.