Skip to content

WIP #3309

New issue

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

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

Already on GitHub? # to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

WIP #3309

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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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) =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
Loading