@@ -167,6 +167,7 @@ class BashScriptsTests:
167
167
def exists : Boolean = s.toPath.toFile.exists
168
168
def name : String = s.toFile.getName
169
169
def dropExtension : String = s.reverse.dropWhile(_ != '.' ).drop(1 ).reverse
170
+ def parent (up : Int ): String = s.norm.split(" /" ).reverse.drop(up).reverse.mkString(" /" )
170
171
}
171
172
172
173
extension(p : Path ) {
@@ -201,22 +202,20 @@ class BashScriptsTests:
201
202
if scalacPath.isFile then scalacPath.replaceAll(" /bin/scalac" , " " )
202
203
else envOrElse(" SCALA_HOME" , " " ).norm
203
204
204
- lazy val javaHome = envOrElse( " JAVA_HOME " , " " ).norm
205
+ lazy val javaHome = whichJava.parent( 2 )
205
206
206
207
lazy val testEnvPairs = List (
207
208
(" JAVA_HOME" , javaHome),
208
209
(" SCALA_HOME" , scalaHome),
209
210
(" PATH" , adjustedPath),
210
211
).filter { case (name, valu) => valu.nonEmpty }
211
212
212
- lazy val whichBash : String =
213
- var whichBash = " "
214
- if osname.startsWith(" windows" ) then
215
- whichBash = which(" bash.exe" )
216
- else
217
- whichBash = which(" bash" )
213
+ lazy val whichBash : String = whichExe(" bash" )
214
+ lazy val whichJava : String = whichExe(" java" )
218
215
219
- whichBash
216
+ def whichExe (basename : String ): String =
217
+ val exeName = if (osname.toLowerCase.startsWith(" windows" )) s " $basename.exe " else basename
218
+ which(exeName)
220
219
221
220
def bashCommand (cmdstr : String , additionalEnvPairs : List [(String , String )] = Nil ): (Boolean , Int , Seq [String ], Seq [String ]) = {
222
221
var (stdout, stderr) = (List .empty[String ], List .empty[String ])
0 commit comments