Skip to content

Commit fe65ec7

Browse files
committed
Assert exitCode in execCmd & fix CoursierScalaTests setup call
1 parent 44fa111 commit fe65ec7

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

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

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,12 @@ class CoursierScalaTests:
148148

149149
object CoursierScalaTests:
150150

151-
def execCmd(command: String, options: String*): (Int, List[String]) =
151+
def execCmd(command: String, options: String*): List[String] =
152152
val cmd = (command :: options.toList).toSeq.mkString(" ")
153153
val out = new ListBuffer[String]
154-
val code = cmd.!(ProcessLogger(out += _, out += _))
155-
(code, out.toList)
154+
val exit = cmd.!(ProcessLogger(out += _, out += _))
155+
assertEquals(s"running $cmd returned exit code $exit", 0, exit)
156+
out.toList
156157

157158
def csScalaCmd(options: String*): List[String] =
158159
csCmd("dotty.tools.MainGenericRunner", options*)
@@ -166,16 +167,10 @@ object CoursierScalaTests:
166167
case Nil => args
167168
case _ => "--" +: args
168169
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)*)._2
170+
execCmd("./cs", (s"""launch "org.scala-lang:scala3-compiler_3:${sys.env("DOTTY_BOOTSTRAPPED_VERSION")}" $newJOpts --main-class "$entry" --property "scala.usejavacp=true"""" +: newOptions)*)
170171

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

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)