Philip W
05/28/2025, 7:19 AMVampire
05/28/2025, 7:38 AMPhilip W
05/28/2025, 7:41 AMExecOperations
. Can I also inject a WorkerExecutor
?Philip W
05/28/2025, 7:43 AMafterSuite
. Will WorkerExecutor also block the listener?Vampire
05/28/2025, 7:44 AMPhilip W
05/28/2025, 7:44 AMVampire
05/28/2025, 7:45 AMVampire
05/28/2025, 7:49 AMPhilip W
05/28/2025, 7:50 AMobjects.newInstance(UploadXRayResults::class)
Vampire
05/28/2025, 8:05 AMabstract class MyTestListener : TestListener {
@get:Inject
abstract val execOperations: ExecOperations
@get:Inject
abstract val workerExecutor: WorkerExecutor
init {
println(execOperations)
println(workerExecutor)
}
override fun beforeSuite(suite: TestDescriptor?) = Unit
override fun afterSuite(suite: TestDescriptor?, result: TestResult?) = Unit
override fun beforeTest(testDescriptor: TestDescriptor?) = Unit
override fun afterTest(testDescriptor: TestDescriptor?, result: TestResult?) = Unit
}
tasks.test {
addTestListener(objects.newInstance<MyTestListener>())
}
et voilá, works 🙂Vampire
05/28/2025, 8:05 AMorg.gradle.process.internal.DefaultExecOperations_Decorated@1dd1c241
org.gradle.workers.internal.DefaultWorkerExecutor_Decorated@4613c0c6
Philip W
05/28/2025, 9:08 AMPhilip W
05/28/2025, 9:08 AMPhilip W
05/28/2025, 9:08 AMPhilip W
06/03/2025, 8:55 AMAn attempt was made to submit work from a thread not managed by Gradle. Work may only be submitted from a Gradle-managed thread.
Vampire
06/03/2025, 8:59 AMPhilip W
06/03/2025, 9:26 AMabstract class MyTestListener : TestListener {
@get:Inject
abstract val workerExecutor: WorkerExecutor
private val s by lazy {
val s = workerExecutor.noIsolation()
s.submit(FooWork::class) {
}
s.await()
42
}
override fun beforeSuite(suite: TestDescriptor) = Unit
override fun afterSuite(suite: TestDescriptor, result: TestResult) {
println(s)
}
override fun beforeTest(testDescriptor: TestDescriptor) = Unit
override fun afterTest(testDescriptor: TestDescriptor, result: TestResult) = Unit
}
abstract class FooWork : WorkAction<WorkParameters.None> {
override fun execute() {
println("Running Foo work")
}
}
tasks.test {
addTestListener(objects.newInstance<MyTestListener>())
}
Philip W
06/03/2025, 9:30 AMafterSuite
function with its own threadPhilip W
06/03/2025, 9:34 AM