mirror of
https://github.com/apple/pkl.git
synced 2026-07-03 11:41:43 +02:00
pkl-doc: Fix/improve Executor handling in DocGenerator (#1590)
run() now creates and closes a default Executor per call. This is fine because there is no good reason to call this method multiple times. run(Executor) now lets callers provide their own Executor, which is customary for a well-behaved library. Also: Fix IntelliJ warning by calling toSet() Closes #1583
This commit is contained in:
@@ -17,22 +17,15 @@ package org.pkl.doc
|
||||
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.condition.EnabledIf
|
||||
import org.junit.jupiter.api.condition.EnabledForJreRange
|
||||
import org.junit.jupiter.api.condition.JRE
|
||||
|
||||
class DocGeneratorTest {
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun isJdk21OrLater(): Boolean {
|
||||
return Runtime.version().feature() >= 21
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnabledIf("isJdk21OrLater")
|
||||
fun `uses virtual thread executor on JDK 21`() {
|
||||
@EnabledForJreRange(min = JRE.JAVA_21)
|
||||
fun `uses virtual thread executor on JDK 21+`() {
|
||||
// On older JDKs, we get a ThreadPoolExecutor.
|
||||
// not sure if there's a better assertion to make here.
|
||||
assertThat(DocGenerator.executor.javaClass.canonicalName)
|
||||
assertThat(DocGenerator.createDefaultExecutor().javaClass.canonicalName)
|
||||
.isEqualTo("java.util.concurrent.ThreadPerTaskExecutor")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user