Skip to content

Commit 40a8f85

Browse files
committed
Run tests for utf8 characters on input path / current working directory
1 parent fbc7cb1 commit 40a8f85

File tree

3 files changed

+78
-8
lines changed

3 files changed

+78
-8
lines changed

modules/integration/src/test/scala/scala/cli/integration/CoursierScalaInstallationTestHelper.scala

+10-8
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,17 @@ trait CoursierScalaInstallationTestHelper {
8080
0,
8181
underlyingScriptPath.toString().indexOf(scalaVersion) + scalaVersion.length
8282
))
83-
System.err.println(s"Cleaning up, trying to remove $csPrebuiltBinaryDir")
84-
try {
85-
os.remove.all(csPrebuiltBinaryDir)
83+
if (!Properties.isWin) {
84+
System.err.println(s"Cleaning up, trying to remove $csPrebuiltBinaryDir")
85+
try {
86+
os.remove.all(csPrebuiltBinaryDir)
8687

87-
System.err.println(s"Cleanup complete. Removed $csPrebuiltBinaryDir")
88-
}
89-
catch {
90-
case ex: java.nio.file.FileSystemException =>
91-
System.err.println(s"Failed to remove $csPrebuiltBinaryDir: $ex")
88+
System.err.println(s"Cleanup complete. Removed $csPrebuiltBinaryDir")
89+
}
90+
catch {
91+
case ex: java.nio.file.FileSystemException =>
92+
System.err.println(s"Failed to remove $csPrebuiltBinaryDir: $ex")
93+
}
9294
}
9395
}
9496
}

modules/integration/src/test/scala/scala/cli/integration/RunTestDefinitions.scala

+13
Original file line numberDiff line numberDiff line change
@@ -1069,6 +1069,19 @@ abstract class RunTestDefinitions
10691069
}
10701070
}
10711071

1072+
test("UTF-8 characters on the input path & current working directory path") {
1073+
val expectedMessage = "Hello"
1074+
val utf8DirPath = os.rel / "äöü"
1075+
val inputName = "Hello.sc"
1076+
val inputPath = utf8DirPath / inputName
1077+
TestInputs(inputPath -> s"""println("$expectedMessage")""")
1078+
.fromRoot { root =>
1079+
val res = os.proc(TestUtil.cli, "run", inputName, extraOptions)
1080+
.call(cwd = root / utf8DirPath)
1081+
expect(res.out.trim() == expectedMessage)
1082+
}
1083+
}
1084+
10721085
test("return relevant error if multiple .scala main classes are present") {
10731086
TestUtil.retryOnCi() {
10741087
val (scalaFile1, scalaFile2, scriptName) =

modules/integration/src/test/scala/scala/cli/integration/SipScalaTests.scala

+55
Original file line numberDiff line numberDiff line change
@@ -883,4 +883,59 @@ class SipScalaTests extends ScalaCliSuite
883883
expect(launcherVersionOverrideHelp == standardVersionOverrideHelp)
884884
}
885885
}
886+
887+
test("coursier scala installation works with utf8 paths") {
888+
val utf8DirPath = os.rel / "äöü"
889+
TestInputs(utf8DirPath / "version.sc" ->
890+
"println(dotty.tools.dotc.config.Properties.versionNumberString)")
891+
.fromRoot { root =>
892+
val rootWithUtf8 = root / utf8DirPath
893+
val localCache = rootWithUtf8 / "local-cache"
894+
val localBin = rootWithUtf8 / "local-bin"
895+
val scalaVersion = Constants.scala3NextRcAnnounced
896+
withScalaRunnerWrapper(
897+
root = rootWithUtf8,
898+
localCache = localCache,
899+
localBin = localBin,
900+
scalaVersion = scalaVersion
901+
) { launchScalaPath =>
902+
val r = os.proc(launchScalaPath, "--with-compiler", "version.sc")
903+
.call(
904+
cwd = rootWithUtf8,
905+
env = Map("COURSIER_CACHE" -> localCache.toString),
906+
check = false // need to clean up even on failure
907+
)
908+
expect(r.exitCode == 0)
909+
expect(r.out.trim() == scalaVersion)
910+
}
911+
}
912+
}
913+
914+
test("coursier scala installation works with utf8 paths") {
915+
val utf8DirPath = os.rel / "äöü"
916+
TestInputs(utf8DirPath / "version.sc" ->
917+
"println(dotty.tools.dotc.config.Properties.versionNumberString)")
918+
.fromRoot { root =>
919+
val rootWithUtf8 = root / utf8DirPath
920+
val localCache = rootWithUtf8 / "local-cache"
921+
val localBin = rootWithUtf8 / "local-bin"
922+
val scalaVersion = Constants.scala3NextRcAnnounced
923+
// ensure cs works at all
924+
os.proc(TestUtil.cs, "version")
925+
.call(cwd = rootWithUtf8, stdout = os.Inherit)
926+
// ensure scala is installable
927+
os.proc(
928+
TestUtil.cs,
929+
"install",
930+
"--cache",
931+
localCache,
932+
"--install-dir",
933+
localBin,
934+
s"scala:$scalaVersion"
935+
).call(cwd = rootWithUtf8)
936+
// ensure scala got installed
937+
os.proc(localBin / "scala.bat", "--version")
938+
.call(cwd = rootWithUtf8, stdout = os.Inherit)
939+
}
940+
}
886941
}

0 commit comments

Comments
 (0)