@@ -148,11 +148,11 @@ class CoursierScalaTests:
148
148
149
149
object CoursierScalaTests :
150
150
151
- def execCmd (command : String , options : String * ): List [String ] =
151
+ def execCmd (command : String , options : String * ): ( Int , List [String ]) =
152
152
val cmd = (command :: options.toList).toSeq.mkString(" " )
153
153
val out = new ListBuffer [String ]
154
- cmd.! (ProcessLogger (out += _, out += _))
155
- out.toList
154
+ val code = cmd.! (ProcessLogger (out += _, out += _))
155
+ (code, out.toList)
156
156
157
157
def csScalaCmd (options : String * ): List [String ] =
158
158
csCmd(" dotty.tools.MainGenericRunner" , options* )
@@ -166,10 +166,16 @@ object CoursierScalaTests:
166
166
case Nil => args
167
167
case _ => " --" +: args
168
168
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
170
170
171
171
/** Get coursier script */
172
172
@ 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' )
175
174
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