mirror of https://github.com/sbt/sbt.git
[2.x] fix: Handle --version in sbt 2.x project dirs (sbt#8717)
**Problem** `sbt --version` in sbt 2.x project directories was delegated to the native client, which could try to start/connect to a server instead of printing version info. **Solution** Skip native-client delegation when `--version` is requested, and add runner-script tests for sbt 1.x and 2.x project variants.
This commit is contained in:
parent
6d94d6db61
commit
03351d6c56
|
|
@ -129,6 +129,32 @@ object RunnerScriptTest extends verify.BasicTestSuite with ShellScriptUtil:
|
|||
assert(out.mkString(System.lineSeparator()).trim.matches(expectedVersion))
|
||||
()
|
||||
|
||||
testOutput(
|
||||
"sbt --version should work (sbt 1.x project)",
|
||||
citestVariant = "citest",
|
||||
)("--version"): (out: List[String]) =>
|
||||
val output = out.mkString(System.lineSeparator())
|
||||
assert(
|
||||
output.contains("sbt version in this project:") ||
|
||||
output.contains("sbtVersion")
|
||||
)
|
||||
assert(output.contains("sbt runner version:"))
|
||||
assert(!output.contains("failed to connect to server"))
|
||||
()
|
||||
|
||||
testOutput(
|
||||
"sbt --version should work (sbt 2.x project)",
|
||||
citestVariant = "citest2",
|
||||
)("--version"): (out: List[String]) =>
|
||||
val output = out.mkString(System.lineSeparator())
|
||||
assert(
|
||||
output.contains("sbt version in this project:") ||
|
||||
output.contains("sbtVersion")
|
||||
)
|
||||
assert(output.contains("sbt runner version:"))
|
||||
assert(!output.contains("failed to connect to server"))
|
||||
()
|
||||
|
||||
testOutput("--sbt-cache")("--sbt-cache", "./cachePath"): (out: List[String]) =>
|
||||
assert(out.contains[String]("-Dsbt.global.localcache=./cachePath"))
|
||||
|
||||
|
|
|
|||
|
|
@ -617,7 +617,7 @@ if !sbt_args_print_sbt_script_version! equ 1 (
|
|||
goto :eof
|
||||
)
|
||||
|
||||
if !run_native_client! equ 1 (
|
||||
if !run_native_client! equ 1 if not defined sbt_args_print_version (
|
||||
goto :runnative !SBT_ARGS!
|
||||
goto :eof
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in New Issue