Fix sbtw integration tests on Windows: pass full test classpath

When useSbtw=true, LauncherTestHelper runs 'java -cp ... sbtw.Main' using
java.class.path, which is incomplete in the test JVM. Pass the full test
classpath via -Dsbt.test.classpath in launcherPackageIntegrationTest
(fork=true, javaOptions) and use it in LauncherTestHelper when set.
This commit is contained in:
bitloi 2026-02-15 12:05:25 +01:00
parent f95cf024b9
commit a115036378
2 changed files with 9 additions and 3 deletions

View File

@ -1391,6 +1391,11 @@ lazy val launcherPackageIntegrationTest =
), ),
testFrameworks += TestFramework("hedgehog.sbt.Framework"), testFrameworks += TestFramework("hedgehog.sbt.Framework"),
testFrameworks += TestFramework("verify.runner.Framework"), testFrameworks += TestFramework("verify.runner.Framework"),
Test / fork := true,
Test / javaOptions += {
val cp = (Test / fullClasspath).value.map(_.data.getAbsolutePath).mkString(java.io.File.pathSeparator)
s"-Dsbt.test.classpath=$cp"
},
Test / test := { Test / test := {
(Test / test) (Test / test)
.dependsOn(launcherPackage / Universal / packageBin) .dependsOn(launcherPackage / Universal / packageBin)

View File

@ -15,8 +15,9 @@ object LauncherTestHelper {
/** Command prefix to run the launcher: either script path or java -cp sbtw.Main */ /** Command prefix to run the launcher: either script path or java -cp sbtw.Main */
def launcherCommand(scriptPath: String): Seq[String] = def launcherCommand(scriptPath: String): Seq[String] =
if (useSbtw) if (useSbtw) {
Seq("java", "-cp", System.getProperty("java.class.path"), "sbtw.Main") val cp = sys.props.get("sbt.test.classpath").getOrElse(System.getProperty("java.class.path"))
else Seq("java", "-cp", cp, "sbtw.Main")
} else
Seq(scriptPath) Seq(scriptPath)
} }