Skip to content

Commit 3156fe9

Browse files
anatoliykmetyukKordyjan
authored andcommitted
Check the status of coursier download in CoursierScalaTests.scala
This should provide more insight on why #17119 happens.
1 parent 7809f9b commit 3156fe9

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

compiler/test-coursier/dotty/tools/coursier/CoursierScalaTests.scala

+12-6
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,11 @@ class CoursierScalaTests:
148148

149149
object CoursierScalaTests:
150150

151-
def execCmd(command: String, options: String*): List[String] =
151+
def execCmd(command: String, options: String*): (Int, List[String]) =
152152
val cmd = (command :: options.toList).toSeq.mkString(" ")
153153
val out = new ListBuffer[String]
154-
cmd.!(ProcessLogger(out += _, out += _))
155-
out.toList
154+
val code = cmd.!(ProcessLogger(out += _, out += _))
155+
(code, out.toList)
156156

157157
def csScalaCmd(options: String*): List[String] =
158158
csCmd("dotty.tools.MainGenericRunner", options*)
@@ -166,10 +166,16 @@ object CoursierScalaTests:
166166
case Nil => args
167167
case _ => "--" +: args
168168
val newJOpts = jOpts.map(s => s"--java-opt ${s.stripPrefix("-J")}").mkString(" ")
169-
execCmd("./cs", (s"""launch "org.scala-lang:scala3-compiler_3:${sys.env("DOTTY_BOOTSTRAPPED_VERSION")}" $newJOpts --main-class "$entry" --property "scala.usejavacp=true"""" +: newOptions)*)
169+
execCmd("./cs", (s"""launch "org.scala-lang:scala3-compiler_3:${sys.env("DOTTY_BOOTSTRAPPED_VERSION")}" $newJOpts --main-class "$entry" --property "scala.usejavacp=true"""" +: newOptions)*)._2
170170

171171
/** Get coursier script */
172172
@BeforeClass def setup(): Unit =
173-
val ver = execCmd("uname").head.replace('L', 'l').replace('D', 'd')
174-
execCmd("curl", s"-fLo cs https://git.io/coursier-cli-$ver") #&& execCmd("chmod", "+x cs")
173+
val ver = execCmd("uname")._2.head.replace('L', 'l').replace('D', 'd')
175174

175+
def runAndCheckCmd(cmd: String, options: String*): Unit =
176+
val (code, out) = execCmd(cmd, options*)
177+
if code != 0 then
178+
fail(s"Failed to run $cmd ${options.mkString(" ")}, exit code: $code, output: ${out.mkString("\n")}")
179+
180+
runAndCheckCmd("curl", s"-fLo cs https://git.io/coursier-cli-$ver")
181+
runAndCheckCmd("chmod", "+x cs")

0 commit comments

Comments
 (0)