mirror of
https://github.com/apple/pkl.git
synced 2026-04-24 09:18:35 +02:00
Improve configuration and tests for native-image (#509)
* Don't expose JDK internal classes; instead solve msgpack issue with `--initialize-at-run-time`. * Use quick build mode for non-release builds: 40% faster compilation, 20% smaller executable. * Remove options that were commented out. * Also run ServerTest against native executable
This commit is contained in:
@@ -154,10 +154,7 @@ tasks.compileKotlin {
|
||||
}
|
||||
|
||||
tasks.test {
|
||||
inputs.dir("src/test/files/LanguageSnippetTests/input").withPropertyName("languageSnippetTestsInput").withPathSensitivity(PathSensitivity.RELATIVE)
|
||||
inputs.dir("src/test/files/LanguageSnippetTests/input-helper").withPropertyName("languageSnippetTestsInputHelper").withPathSensitivity(PathSensitivity.RELATIVE)
|
||||
inputs.dir("src/test/files/LanguageSnippetTests/output").withPropertyName("languageSnippetTestsOutput").withPathSensitivity(PathSensitivity.RELATIVE)
|
||||
|
||||
configureTest()
|
||||
useJUnitPlatform {
|
||||
excludeEngines("MacAmd64LanguageSnippetTestsEngine")
|
||||
excludeEngines("MacAarch64LanguageSnippetTestsEngine")
|
||||
@@ -168,11 +165,7 @@ tasks.test {
|
||||
}
|
||||
|
||||
val testJavaExecutable by tasks.registering(Test::class) {
|
||||
inputs.dir("src/test/files/LanguageSnippetTests/input").withPropertyName("languageSnippetTestsInput").withPathSensitivity(PathSensitivity.RELATIVE)
|
||||
inputs.dir("src/test/files/LanguageSnippetTests/input-helper").withPropertyName("languageSnippetTestsInputHelper").withPathSensitivity(PathSensitivity.RELATIVE)
|
||||
inputs.dir("src/test/files/LanguageSnippetTests/output").withPropertyName("languageSnippetTestsOutput").withPathSensitivity(PathSensitivity.RELATIVE)
|
||||
|
||||
testClassesDirs = files(tasks.test.get().testClassesDirs)
|
||||
configureExecutableTest("LanguageSnippetTestsEngine")
|
||||
classpath =
|
||||
// compiled test classes
|
||||
sourceSets.test.get().output +
|
||||
@@ -182,10 +175,6 @@ val testJavaExecutable by tasks.registering(Test::class) {
|
||||
// (test dependencies that are also main dependencies must already be contained in java executable;
|
||||
// to verify that we don't want to include them here)
|
||||
(configurations.testRuntimeClasspath.get() - configurations.runtimeClasspath.get())
|
||||
|
||||
useJUnitPlatform {
|
||||
includeEngines("LanguageSnippetTestsEngine")
|
||||
}
|
||||
}
|
||||
|
||||
tasks.check {
|
||||
@@ -194,92 +183,32 @@ tasks.check {
|
||||
|
||||
val testMacExecutableAmd64 by tasks.registering(Test::class) {
|
||||
dependsOn(":pkl-cli:macExecutableAmd64")
|
||||
|
||||
inputs.dir("src/test/files/LanguageSnippetTests/input").withPropertyName("languageSnippetTestsInput").withPathSensitivity(PathSensitivity.RELATIVE)
|
||||
inputs.dir("src/test/files/LanguageSnippetTests/input-helper").withPropertyName("languageSnippetTestsInputHelper").withPathSensitivity(PathSensitivity.RELATIVE)
|
||||
inputs.dir("src/test/files/LanguageSnippetTests/output").withPropertyName("languageSnippetTestsOutput").withPathSensitivity(PathSensitivity.RELATIVE)
|
||||
|
||||
testClassesDirs = files(tasks.test.get().testClassesDirs)
|
||||
classpath = tasks.test.get().classpath
|
||||
|
||||
useJUnitPlatform {
|
||||
includeEngines("MacAmd64LanguageSnippetTestsEngine")
|
||||
}
|
||||
configureExecutableTest("MacAmd64LanguageSnippetTestsEngine")
|
||||
}
|
||||
|
||||
val testMacExecutableAarch64 by tasks.registering(Test::class) {
|
||||
dependsOn(":pkl-cli:macExecutableAarch64")
|
||||
|
||||
inputs.dir("src/test/files/LanguageSnippetTests/input")
|
||||
inputs.dir("src/test/files/LanguageSnippetTests/input-helper")
|
||||
inputs.dir("src/test/files/LanguageSnippetTests/output")
|
||||
|
||||
testClassesDirs = files(tasks.test.get().testClassesDirs)
|
||||
classpath = tasks.test.get().classpath
|
||||
|
||||
useJUnitPlatform {
|
||||
includeEngines("MacAarch64LanguageSnippetTestsEngine")
|
||||
}
|
||||
configureExecutableTest("MacAarch64LanguageSnippetTestsEngine")
|
||||
}
|
||||
|
||||
val testLinuxExecutableAmd64 by tasks.registering(Test::class) {
|
||||
dependsOn(":pkl-cli:linuxExecutableAmd64")
|
||||
|
||||
inputs.dir("src/test/files/LanguageSnippetTests/input")
|
||||
inputs.dir("src/test/files/LanguageSnippetTests/input-helper")
|
||||
inputs.dir("src/test/files/LanguageSnippetTests/output")
|
||||
|
||||
testClassesDirs = files(tasks.test.get().testClassesDirs)
|
||||
classpath = tasks.test.get().classpath
|
||||
|
||||
useJUnitPlatform {
|
||||
includeEngines("LinuxAmd64LanguageSnippetTestsEngine")
|
||||
}
|
||||
configureExecutableTest("LinuxAmd64LanguageSnippetTestsEngine")
|
||||
}
|
||||
|
||||
val testLinuxExecutableAarch64 by tasks.registering(Test::class) {
|
||||
dependsOn(":pkl-cli:linuxExecutableAarch64")
|
||||
|
||||
inputs.dir("src/test/files/LanguageSnippetTests/input")
|
||||
inputs.dir("src/test/files/LanguageSnippetTests/input-helper")
|
||||
inputs.dir("src/test/files/LanguageSnippetTests/output")
|
||||
|
||||
testClassesDirs = files(tasks.test.get().testClassesDirs)
|
||||
classpath = tasks.test.get().classpath
|
||||
|
||||
useJUnitPlatform {
|
||||
includeEngines("LinuxAarch64LanguageSnippetTestsEngine")
|
||||
}
|
||||
configureExecutableTest("LinuxAarch64LanguageSnippetTestsEngine")
|
||||
}
|
||||
|
||||
val testAlpineExecutableAmd64 by tasks.registering(Test::class) {
|
||||
dependsOn(":pkl-cli:alpineExecutableAmd64")
|
||||
|
||||
inputs.dir("src/test/files/LanguageSnippetTests/input")
|
||||
inputs.dir("src/test/files/LanguageSnippetTests/input-helper")
|
||||
inputs.dir("src/test/files/LanguageSnippetTests/output")
|
||||
|
||||
testClassesDirs = files(tasks.test.get().testClassesDirs)
|
||||
classpath = tasks.test.get().classpath
|
||||
|
||||
useJUnitPlatform {
|
||||
includeEngines("AlpineLanguageSnippetTestsEngine")
|
||||
}
|
||||
configureExecutableTest("AlpineLanguageSnippetTestsEngine")
|
||||
}
|
||||
|
||||
val testWindowsExecutableAmd64 by tasks.registering(Test::class) {
|
||||
dependsOn(":pkl-cli:windowsExecutableAmd64")
|
||||
|
||||
inputs.dir("src/test/files/LanguageSnippetTests/input")
|
||||
inputs.dir("src/test/files/LanguageSnippetTests/input-helper")
|
||||
inputs.dir("src/test/files/LanguageSnippetTests/output")
|
||||
|
||||
testClassesDirs = files(tasks.test.get().testClassesDirs)
|
||||
classpath = tasks.test.get().classpath
|
||||
|
||||
useJUnitPlatform {
|
||||
includeEngines("WindowsLanguageSnippetTestsEngine")
|
||||
}
|
||||
configureExecutableTest("WindowsLanguageSnippetTestsEngine")
|
||||
}
|
||||
|
||||
tasks.testNative {
|
||||
@@ -316,3 +245,24 @@ spotless {
|
||||
target(files("src/main/antlr/PklParser.g4", "src/main/antlr/PklLexer.g4"))
|
||||
}
|
||||
}
|
||||
|
||||
private fun Test.configureTest() {
|
||||
inputs.dir("src/test/files/LanguageSnippetTests/input")
|
||||
.withPropertyName("languageSnippetTestsInput")
|
||||
.withPathSensitivity(PathSensitivity.RELATIVE)
|
||||
inputs.dir("src/test/files/LanguageSnippetTests/input-helper")
|
||||
.withPropertyName("languageSnippetTestsInputHelper")
|
||||
.withPathSensitivity(PathSensitivity.RELATIVE)
|
||||
inputs.dir("src/test/files/LanguageSnippetTests/output")
|
||||
.withPropertyName("languageSnippetTestsOutput")
|
||||
.withPathSensitivity(PathSensitivity.RELATIVE)
|
||||
}
|
||||
|
||||
private fun Test.configureExecutableTest(engineName: String) {
|
||||
configureTest()
|
||||
testClassesDirs = files(tasks.test.get().testClassesDirs)
|
||||
classpath = tasks.test.get().classpath
|
||||
useJUnitPlatform {
|
||||
includeEngines(engineName)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import org.junit.platform.engine.support.descriptor.EngineDescriptor
|
||||
import org.pkl.commons.test.FileTestUtils
|
||||
import org.pkl.commons.test.InputOutputTestEngine
|
||||
import org.pkl.commons.test.PackageServer
|
||||
import org.pkl.commons.test.PklExecutablePaths
|
||||
import org.pkl.core.http.HttpClient
|
||||
import org.pkl.core.project.Project
|
||||
import org.pkl.core.util.IoUtils
|
||||
@@ -236,31 +237,31 @@ abstract class AbstractNativeLanguageSnippetTestsEngine : AbstractLanguageSnippe
|
||||
}
|
||||
|
||||
class MacAmd64LanguageSnippetTestsEngine : AbstractNativeLanguageSnippetTestsEngine() {
|
||||
override val pklExecutablePath: Path = rootProjectDir.resolve("pkl-cli/build/executable/pkl-macos-amd64")
|
||||
override val pklExecutablePath: Path = PklExecutablePaths.macAmd64
|
||||
override val testClass: KClass<*> = MacLanguageSnippetTests::class
|
||||
}
|
||||
|
||||
class MacAarch64LanguageSnippetTestsEngine : AbstractNativeLanguageSnippetTestsEngine() {
|
||||
override val pklExecutablePath: Path = rootProjectDir.resolve("pkl-cli/build/executable/pkl-macos-aarch64")
|
||||
override val pklExecutablePath: Path = PklExecutablePaths.macAarch64
|
||||
override val testClass: KClass<*> = MacLanguageSnippetTests::class
|
||||
}
|
||||
|
||||
class LinuxAmd64LanguageSnippetTestsEngine : AbstractNativeLanguageSnippetTestsEngine() {
|
||||
override val pklExecutablePath: Path = rootProjectDir.resolve("pkl-cli/build/executable/pkl-linux-amd64")
|
||||
override val pklExecutablePath: Path = PklExecutablePaths.linuxAmd64
|
||||
override val testClass: KClass<*> = LinuxLanguageSnippetTests::class
|
||||
}
|
||||
|
||||
class LinuxAarch64LanguageSnippetTestsEngine : AbstractNativeLanguageSnippetTestsEngine() {
|
||||
override val pklExecutablePath: Path = rootProjectDir.resolve("pkl-cli/build/executable/pkl-linux-aarch64")
|
||||
override val pklExecutablePath: Path = PklExecutablePaths.linuxAarch64
|
||||
override val testClass: KClass<*> = LinuxLanguageSnippetTests::class
|
||||
}
|
||||
|
||||
class AlpineLanguageSnippetTestsEngine : AbstractNativeLanguageSnippetTestsEngine() {
|
||||
override val pklExecutablePath: Path = rootProjectDir.resolve("pkl-cli/build/executable/pkl-alpine-linux-amd64")
|
||||
override val pklExecutablePath: Path = PklExecutablePaths.alpineAmd64
|
||||
override val testClass: KClass<*> = AlpineLanguageSnippetTests::class
|
||||
}
|
||||
|
||||
class WindowsLanguageSnippetTestsEngine : AbstractNativeLanguageSnippetTestsEngine() {
|
||||
override val pklExecutablePath: Path = rootProjectDir.resolve("pkl-cli/build/executable/pkl-windows-amd64.exe")
|
||||
override val pklExecutablePath: Path = PklExecutablePaths.windowsAmd64
|
||||
override val testClass: KClass<*> = WindowsLanguageSnippetTests::class
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user