Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for setup-ide with --cli-version #3163

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion modules/cli/src/main/scala/scala/cli/ScalaCli.scala
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,9 @@ object ScalaCli {
predefinedCliVersion = None,
initialLauncherPath = None
)
case v if v < Version("1.5.1") && !ver.contains("nightly") =>
case v
if v < Version("1.5.0-34-g31a88e428-SNAPSHOT") && v < Version("1.5.1") &&
Gedochao marked this conversation as resolved.
Show resolved Hide resolved
!ver.contains("nightly") =>
initialScalaRunnerArgs.copy(
predefinedCliVersion = None,
initialLauncherPath = None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2163,21 +2163,43 @@ abstract class BspTestDefinitions extends ScalaCliSuite with TestScalaVersionArg
}
}

// TODO: uncomment when the fix for https://github.com/VirtusLab/scala-cli/issues/3157 is on nightly
// test("setup-ide prepares a valid BSP configuration with --cli-version") {
// val scriptName = "cli-version.sc"
// val cliVersion = "nightly"
// val inputs = TestInputs(os.rel / scriptName -> s"""println("Hello from launcher v$cliVersion""")
// inputs.fromRoot { root =>
// val cliVersionArgs = List("--cli-version", cliVersion)
// os.proc(TestUtil.cli, cliVersionArgs, "setup-ide", scriptName, extraOptions).call(cwd = root)
// val expectedIdeLauncherFile = root / Constants.workspaceDirName / "ide-launcher-options.json"
// expect(expectedIdeLauncherFile.toNIO.toFile.exists())
// expect(os.read(expectedIdeLauncherFile).contains(cliVersion))
// val bspConfig = readBspConfig(root)
// expect(bspConfig.argv.head == TestUtil.cliPath)
// expect(bspConfig.argv.containsSlice(cliVersionArgs))
// expect(bspConfig.argv.indexOfSlice(cliVersionArgs) < bspConfig.argv.indexOf("bsp"))
// }
// }
for { cliVersion <- Seq("1.5.0", "1.5.0-19-g932866db6-SNAPSHOT", "1.0.0") }
test(s"setup-ide doesn't pass unrecognised arguments to old --cli-versions: $cliVersion") {
val scriptName = "cli-version.sc"
val inputs = TestInputs(
os.rel / scriptName -> s"""println("Hello from launcher v$cliVersion"""
)
inputs.fromRoot { root =>
val r =
os.proc(TestUtil.cli, "--cli-version", cliVersion, "setup-ide", scriptName, extraOptions)
.call(cwd = root, stderr = os.Pipe, check = false)
expect(!r.err.text().contains("Unrecognized argument"))
expect(r.exitCode == 0)
}
}

// TODO: test for the most recent CLI version as well when 1.5.1 is out
for { cliVersion <- Seq("1.5.0-34-g31a88e428-SNAPSHOT") }
test(
s"setup-ide prepares a valid BSP configuration with --cli-version $cliVersion"
) {
val scriptName = "cli-version.sc"
val inputs = TestInputs(
os.rel / scriptName -> s"""println("Hello from launcher v$cliVersion"""
)
inputs.fromRoot { root =>
val cliVersionArgs = List("--cli-version", cliVersion)
os.proc(TestUtil.cli, cliVersionArgs, "setup-ide", scriptName, extraOptions).call(cwd =
root
)
val expectedIdeLauncherFile =
root / Constants.workspaceDirName / "ide-launcher-options.json"
expect(expectedIdeLauncherFile.toNIO.toFile.exists())
expect(os.read(expectedIdeLauncherFile).contains(cliVersion))
val bspConfig = readBspConfig(root)
expect(bspConfig.argv.head == TestUtil.cliPath)
expect(bspConfig.argv.containsSlice(cliVersionArgs))
expect(bspConfig.argv.indexOfSlice(cliVersionArgs) < bspConfig.argv.indexOf("bsp"))
}
}
}
Loading