@@ -39,4 +39,35 @@ class SipScalaTests extends ScalaCliSuite {
39
39
noDirectoriesCommandTest(" scala-cli-sip" )
40
40
}
41
41
}
42
+
43
+ def runVersionCommand (binaryName : String ) =
44
+ TestInputs .empty.fromRoot { root =>
45
+ val cliPath = os.Path (TestUtil .cliPath, os.pwd)
46
+ val ext = if (Properties .isWin) " .exe" else " "
47
+ val newCliPath = root / s " $binaryName$ext"
48
+ os.copy(cliPath, newCliPath)
49
+
50
+ for { versionOption <- Seq (" version" , " -version" , " --version" ) } {
51
+ val version = os.proc(newCliPath, versionOption).call(check = false )
52
+ assert(
53
+ version.exitCode == 0 ,
54
+ clues(version, version.out.text(), version.err.text(), version.exitCode)
55
+ )
56
+ val expectedLauncherVersion =
57
+ if (binaryName == " scala" ) " Scala code runner version:"
58
+ else " Scala CLI version:"
59
+ expect(version.out.text().contains(expectedLauncherVersion))
60
+ expect(version.out.text().contains(s " Scala version (default): ${Constants .defaultScala}" ))
61
+ }
62
+ }
63
+
64
+ if (TestUtil .isNativeCli) {
65
+ test(" version command print detailed info run as scala" ) {
66
+ runVersionCommand(" scala" )
67
+ }
68
+
69
+ test(" version command print detailed info run as scala-cli" ) {
70
+ runVersionCommand(" scala-cli" )
71
+ }
72
+ }
42
73
}
0 commit comments