mirror of
https://github.com/apple/pkl.git
synced 2026-04-22 08:18:32 +02:00
Clean up http-client changes (#295)
* pkl-excutor tests: symlink 0.25.0 distribution into pkl-executable/build * Use `IoUtils.getPklHomeDir` in HttpClientBuilder * Simplify Exceptions.java * Enable testing for older pkl-executor distribution
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import java.nio.file.Files
|
||||
|
||||
plugins {
|
||||
pklAllProjects
|
||||
pklJavaLibrary
|
||||
@@ -6,7 +8,7 @@ plugins {
|
||||
}
|
||||
|
||||
val pklDistributionCurrent: Configuration by configurations.creating
|
||||
val pklDistribution025: Configuration by configurations.creating
|
||||
val pklHistoricalDistributions: Configuration by configurations.creating
|
||||
|
||||
// Because pkl-executor doesn't depend on other Pkl modules
|
||||
// (nor has overlapping dependencies that could cause a version conflict),
|
||||
@@ -15,7 +17,7 @@ val pklDistribution025: Configuration by configurations.creating
|
||||
dependencies {
|
||||
pklDistributionCurrent(project(":pkl-config-java", "fatJar"))
|
||||
@Suppress("UnstableApiUsage")
|
||||
pklDistribution025(libs.pklConfigJavaAll025)
|
||||
pklHistoricalDistributions(libs.pklConfigJavaAll025)
|
||||
|
||||
implementation(libs.slf4jApi)
|
||||
|
||||
@@ -52,14 +54,29 @@ sourceSets {
|
||||
}
|
||||
}
|
||||
|
||||
// this task could be folded into tasks.test by switching to IntelliJ's Gradle test runner
|
||||
val prepareHistoricalDistributions by tasks.registering {
|
||||
val outputDir = layout.buildDirectory.dir("pklHistoricalDistributions")
|
||||
inputs.files(pklHistoricalDistributions.files())
|
||||
outputs.dir(outputDir)
|
||||
doLast {
|
||||
val distributionDir = outputDir.get().asFile.toPath()
|
||||
.also(Files::createDirectories)
|
||||
for (file in pklHistoricalDistributions.files) {
|
||||
val link = distributionDir.resolve(file.name)
|
||||
if (!Files.isSymbolicLink(link)) {
|
||||
if (Files.exists(link)) {
|
||||
Files.delete(link)
|
||||
}
|
||||
Files.createSymbolicLink(link, file.toPath())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val prepareTest by tasks.registering {
|
||||
// used by EmbeddedExecutorTest
|
||||
dependsOn(pklDistributionCurrent, pklDistribution025)
|
||||
dependsOn(pklDistributionCurrent, prepareHistoricalDistributions)
|
||||
}
|
||||
|
||||
tasks.test {
|
||||
dependsOn(prepareTest)
|
||||
systemProperty("pklDistributionCurrent", pklDistributionCurrent.singleFile)
|
||||
systemProperty("pklDistribution025", pklDistribution025.singleFile)
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ class EmbeddedExecutorTest {
|
||||
|
||||
// This context has a pkl-executor version that is lower than the distribution version.
|
||||
// It can be enabled once there is a distribution that includes pkl-executor.
|
||||
//ExecutionContext(executor1_2.value, ::convertToOptions1, "Options1, Executor1, Distribution2"),
|
||||
ExecutionContext(executor1_2.value, ::convertToOptions1, "Options1, Executor1, Distribution2"),
|
||||
|
||||
ExecutionContext(executor2_1.value, ::convertToOptions1, "Options1, Executor2, Distribution1"),
|
||||
ExecutionContext(executor2_1.value, ::convertToOptions2, "Options2, Executor2, Distribution1"),
|
||||
@@ -70,7 +70,7 @@ class EmbeddedExecutorTest {
|
||||
}
|
||||
|
||||
// A pkl-executor library that supports ExecutorSpiOptions up to v2
|
||||
// and a Pkl distribution that supports ExecutorSpiOptions up to v.
|
||||
// and a Pkl distribution that supports ExecutorSpiOptions up to v2.
|
||||
private val executor2_2: Lazy<Executor> = lazy {
|
||||
EmbeddedExecutor(listOf(pklDistribution2), pklExecutorClassLoader2)
|
||||
}
|
||||
@@ -98,28 +98,22 @@ class EmbeddedExecutorTest {
|
||||
if (executor.isInitialized()) executor.value.close()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// a Pkl distribution that supports ExecutorSpiOptions up to v1
|
||||
private val pklDistribution1: Path by lazy {
|
||||
val path = System.getProperty("pklDistribution025")?.toPath() ?:
|
||||
// can get rid of this path by switching to IntelliJ's Gradle test runner
|
||||
System.getProperty("user.home").toPath()
|
||||
.resolve(".gradle/caches/modules-2/files-2.1/org.pkl-lang/pkl-config-java-all/" +
|
||||
"0.25.0/e9451dda554f1659e49ff5bdd30accd26be7bf0f/pkl-config-java-all-0.25.0.jar")
|
||||
path.apply {
|
||||
if (!exists()) throw AssertionError("Missing test fixture. " +
|
||||
FileTestUtils.rootProjectDir.resolve("pkl-executor/build/pklHistoricalDistributions/pkl-config-java-all-0.25.0.jar").apply {
|
||||
if (!exists()) {
|
||||
throw AssertionError("Missing test fixture. " +
|
||||
"To fix this problem, run `./gradlew :pkl-executor:prepareTest`.")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// a Pkl distribution that supports ExecutorSpiOptions up to v2
|
||||
private val pklDistribution2: Path by lazy {
|
||||
val path = System.getProperty("pklDistributionCurrent")?.toPath() ?:
|
||||
// can get rid of this path by switching to IntelliJ's Gradle test runner
|
||||
FileTestUtils.rootProjectDir
|
||||
.resolve("pkl-config-java/build/libs/pkl-config-java-all-" +
|
||||
"${Release.current().version().withBuild(null).toString().replaceFirst("dev", "SNAPSHOT")}.jar")
|
||||
path.apply {
|
||||
FileTestUtils.rootProjectDir
|
||||
.resolve("pkl-config-java/build/libs/pkl-config-java-all-" +
|
||||
"${Release.current().version().withBuild(null).toString().replaceFirst("dev", "SNAPSHOT")}.jar").apply {
|
||||
if (!exists()) throw AssertionError("Missing test fixture. " +
|
||||
"To fix this problem, run `./gradlew :pkl-executor:prepareTest`.")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user