diff --git a/modules/integration/src/test/scala/scala/cli/integration/RunJdkTestDefinitions.scala b/modules/integration/src/test/scala/scala/cli/integration/RunJdkTestDefinitions.scala index bb93fbea58..060b18e3b4 100644 --- a/modules/integration/src/test/scala/scala/cli/integration/RunJdkTestDefinitions.scala +++ b/modules/integration/src/test/scala/scala/cli/integration/RunJdkTestDefinitions.scala @@ -11,27 +11,19 @@ trait RunJdkTestDefinitions { _: RunTestDefinitions => s"zulu:$javaVersion" else javaVersion.toString - def canUseScalaInstallationWrapper: Boolean = - actualScalaVersion.startsWith("3") && actualScalaVersion.split('.').drop(1).head.toInt >= 5 - for { javaVersion <- Constants.allJavaVersions index = javaIndex(javaVersion) useScalaInstallationWrapper <- if (canUseScalaInstallationWrapper) Seq(false, true) else Seq(false) launcherString = if (useScalaInstallationWrapper) "coursier scala installation" else "Scala CLI" - scalaRunnerWrapperVersion = actualScalaVersion match { - case v if v == Constants.scala3NextRc => Constants.scala3NextRcAnnounced - case v if v == Constants.scala3Next => Constants.scala3NextAnnounced - case v => v - } withLauncher = (root: os.Path) => (f: Seq[os.Shellable] => Unit) => if (useScalaInstallationWrapper) withScalaRunnerWrapper( root = root, localBin = root / "local-bin", - scalaVersion = scalaRunnerWrapperVersion, + scalaVersion = actualScalaRunnerWrapperVersion, shouldCleanUp = false )(launcher => f(Seq(launcher))) else diff --git a/modules/integration/src/test/scala/scala/cli/integration/RunTestDefinitions.scala b/modules/integration/src/test/scala/scala/cli/integration/RunTestDefinitions.scala index 100391e613..4fa6bcfdd9 100644 --- a/modules/integration/src/test/scala/scala/cli/integration/RunTestDefinitions.scala +++ b/modules/integration/src/test/scala/scala/cli/integration/RunTestDefinitions.scala @@ -32,6 +32,15 @@ abstract class RunTestDefinitions protected val ciOpt: Seq[String] = Option(System.getenv("CI")).map(v => Seq("-e", s"CI=$v")).getOrElse(Nil) + def canUseScalaInstallationWrapper: Boolean = + actualScalaVersion.startsWith("3") && actualScalaVersion.split('.').drop(1).head.toInt >= 5 + + lazy val actualScalaRunnerWrapperVersion: String = actualScalaVersion match { + case v if v == Constants.scala3NextRc => Constants.scala3NextRcAnnounced + case v if v == Constants.scala3Next => Constants.scala3NextAnnounced + case v => v + } + test("print command") { val fileName = "simple.sc" val message = "Hello" @@ -1071,6 +1080,40 @@ abstract class RunTestDefinitions } } + for { + useScalaInstallationWrapper <- + if (canUseScalaInstallationWrapper) Seq(false, true) else Seq(false) + launcherString = if (useScalaInstallationWrapper) "coursier scala installation" else "Scala CLI" + withLauncher = (root: os.Path) => + (f: Seq[os.Shellable] => Unit) => + if (useScalaInstallationWrapper) + withScalaRunnerWrapper( + root = root, + localBin = root / "local-bin", + scalaVersion = actualScalaRunnerWrapperVersion, + shouldCleanUp = false + )(launcher => f(Seq(launcher))) + else + f(Seq(TestUtil.cli)) + } + test( + s"UTF-8 characters on the input path & current working directory path with $launcherString" + ) { + val expectedMessage = "Hello" + val utf8DirPath = os.rel / "äöü" + val inputName = "Hello.sc" + val inputPath = utf8DirPath / inputName + TestInputs(inputPath -> s"""println("$expectedMessage")""") + .fromRoot { root => + withLauncher(root / utf8DirPath) { launcher => + println(launcher.toString()) + val res = os.proc(launcher, "run", inputName, extraOptions) + .call(cwd = root / utf8DirPath) + expect(res.out.trim() == expectedMessage) + } + } + } + test("return relevant error if multiple .scala main classes are present") { TestUtil.retryOnCi() { val (scalaFile1, scalaFile2, scriptName) = diff --git a/modules/integration/src/test/scala/scala/cli/integration/SipScalaTests.scala b/modules/integration/src/test/scala/scala/cli/integration/SipScalaTests.scala index 55b1398acf..d3a79b9ef6 100644 --- a/modules/integration/src/test/scala/scala/cli/integration/SipScalaTests.scala +++ b/modules/integration/src/test/scala/scala/cli/integration/SipScalaTests.scala @@ -884,4 +884,60 @@ class SipScalaTests extends ScalaCliSuite expect(launcherVersionOverrideHelp == standardVersionOverrideHelp) } } + + test("coursier scala installation works with utf8 paths") { + val utf8DirPath = os.rel / "äöü" + TestInputs(utf8DirPath / "version.sc" -> + "println(dotty.tools.dotc.config.Properties.versionNumberString)") + .fromRoot { root => + val rootWithUtf8 = root / utf8DirPath + val localCache = rootWithUtf8 / "local-cache" + val localBin = rootWithUtf8 / "local-bin" + val scalaVersion = Constants.scala3NextRcAnnounced + withScalaRunnerWrapper( + root = rootWithUtf8, + localCache = Some(localCache), + localBin = localBin, + scalaVersion = scalaVersion + ) { launchScalaPath => + val r = os.proc(launchScalaPath, "--with-compiler", "version.sc") + .call( + cwd = rootWithUtf8, + env = Map("COURSIER_CACHE" -> localCache.toString), + check = false // need to clean up even on failure + ) + expect(r.exitCode == 0) + expect(r.out.trim() == scalaVersion) + } + } + } + + test("raw coursier works with utf8 paths") { + val utf8DirPath = os.rel / "äöü" + TestInputs(utf8DirPath / "version.sc" -> + "println(dotty.tools.dotc.config.Properties.versionNumberString)") + .fromRoot { root => + val rootWithUtf8 = root / utf8DirPath + val localCache = rootWithUtf8 / "local-cache" + val localBin = rootWithUtf8 / "local-bin" + val scalaVersion = Constants.scala3NextRcAnnounced + // ensure cs works at all + os.proc(TestUtil.cs, "version") + .call(cwd = rootWithUtf8, stdout = os.Inherit) + // ensure scala is installable + os.proc( + TestUtil.cs, + "install", + "--cache", + localCache, + "--install-dir", + localBin, + s"scala:$scalaVersion" + ).call(cwd = rootWithUtf8) + // ensure scala got installed + val launcherPath = if (Properties.isWin) localBin / "scala.bat" else localBin / "scala" + os.proc(launcherPath, "--version") + .call(cwd = rootWithUtf8, stdout = os.Inherit) + } + } }