From b7091bc56f944ce9d0406c44805c492125b5558f Mon Sep 17 00:00:00 2001 From: Denis Lochmelis Date: Tue, 6 Aug 2024 21:24:38 +0200 Subject: [PATCH] Quickfix-2 --- .../org/jetbrains/litmuskt/JCStressRunner.kt | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/jcstress-wrapper/src/main/kotlin/org/jetbrains/litmuskt/JCStressRunner.kt b/jcstress-wrapper/src/main/kotlin/org/jetbrains/litmuskt/JCStressRunner.kt index 83a7f48..7a03354 100644 --- a/jcstress-wrapper/src/main/kotlin/org/jetbrains/litmuskt/JCStressRunner.kt +++ b/jcstress-wrapper/src/main/kotlin/org/jetbrains/litmuskt/JCStressRunner.kt @@ -25,7 +25,7 @@ class JCStressRunner( barrierProducer: BarrierProducer, syncPeriod: Int, affinityMap: AffinityMap? - ): () -> LitmusResult { + ): BlockingFuture { throw NotImplementedError("jcstress runner should not be called with explicit params like this") } @@ -33,7 +33,7 @@ class JCStressRunner( test: LitmusTest, params: LitmusRunParams, instances: Int - ): List<() -> LitmusResult> { + ): List> { throw NotImplementedError( "jcstress runs tests in parallel by default; asking for parallelism explicitly is meaningless" ) @@ -42,7 +42,7 @@ class JCStressRunner( internal fun startTests( tests: List>, params: LitmusRunParams - ): () -> Map, LitmusResult> { + ): BlockingFuture, LitmusResult>> { val mvn = ProcessBuilder("mvn", "install", "verify", "-U") .directory(jcstressDirectory.toFile()) .redirectOutput(ProcessBuilder.Redirect.INHERIT) @@ -69,20 +69,22 @@ class JCStressRunner( .redirectError(ProcessBuilder.Redirect.INHERIT) .start() - return handle@{ + return BlockingFuture { jcs.waitFor() if (jcs.exitValue() != 0) error("jcstress exited with code ${jcs.exitValue()}") // not all tests might have generated wrappers - return@handle tests + return@BlockingFuture tests .associateWith { test -> parseJCStressResults(test) } .filterValues { it != null } .mapValues { (_, result) -> result!! } // remove nullable type } } - override fun startTest(test: LitmusTest, params: LitmusRunParams): () -> LitmusResult { - val handle = startTests(listOf(test), params) - return { handle()[test] ?: error("test $test did not produce a result; perhaps its wrapper is missing?") } + override fun startTest(test: LitmusTest, params: LitmusRunParams): BlockingFuture { + val future = startTests(listOf(test), params) + return BlockingFuture { + future.await()[test] ?: error("test $test did not produce a result; perhaps its wrapper is missing?") + } } /** @@ -146,7 +148,7 @@ class JCStressRunner( fun JCStressRunner.runTests( tests: List>, params: LitmusRunParams, -): Map, LitmusResult> = startTests(tests, params).invoke() +): Map, LitmusResult> = startTests(tests, params).await() /** * Split a sequence into two: one with the first [size] elements and one with the rest.