@@ -84,12 +84,12 @@ class BashScriptsTests:
8484 @ Test def verifyScriptPathProperty =
8585 val scriptFile = testFiles.find(_.getName == " scriptPath.sc" ).get
8686 val expected = s " / ${scriptFile.getName}"
87- printf(" ===> verify valid system property script.path is reported by script [%s]\n " , scriptFile.getName)
87+ System .err. printf(" ===> verify valid system property script.path is reported by script [%s]\n " , scriptFile.getName)
8888 val (exitCode, stdout, stderr) = bashCommand(scriptFile.absPath)
8989 if exitCode == 0 && ! stderr.exists(_.contains(" Permission denied" )) then
9090 // var cmd = Array(bashExe, "-c", scriptFile.absPath)
9191 // val stdout = Process(cmd).lazyLines_!
92- stdout.foreach { printf(" ######### [%s]\n " , _) }
92+ stdout.foreach { System .err. printf(" ######### [%s]\n " , _) }
9393 val valid = stdout.exists { _.endsWith(expected) }
9494 if valid then printf(" # valid script.path reported by [%s]\n " , scriptFile.getName)
9595 assert(valid, s " script ${scriptFile.absPath} did not report valid script.path value " )
@@ -99,35 +99,39 @@ class BashScriptsTests:
9999 */
100100 @ Test def verifyScalaOpts =
101101 val scriptFile = testFiles.find(_.getName == " classpathReport.sc" ).get
102- printf(" ===> verify valid system property script.path is reported by script [%s]\n " , scriptFile.getName)
102+ printf(" ===> verify SCALA_OPTS -classpath setting in argument file seen by script [%s]\n " , scriptFile.getName)
103103 val argsfile = createArgsFile() // avoid problems caused by drive letter
104104 val envPairs = List ((" SCALA_OPTS" , s " @ $argsfile" ))
105105 val (exitCode, stdout, stderr) = bashCommand(scriptFile.absPath, envPairs:_* )
106+ printf(" \n " )
106107 if exitCode != 0 || stderr.exists(_.contains(" Permission denied" )) then
107108 stderr.foreach { System .err.printf(" stderr [%s]\n " , _) }
108109 printf(" unable to execute script, return value is %d\n " , exitCode)
109110 else
110- // val stdout: Seq[String] = Process(cmd, cwd, envPairs:_*).lazyLines_!.toList
111- val expected = s " ${cwd.toString}"
111+ val expected = cwd
112112 val List (line1 : String , line2 : String ) = stdout.take(2 )
113+ printf(" line1 [%s]\n " , line1)
113114 val valid = line2.dropWhile( _ != ' ' ).trim.startsWith(expected)
115+ val psep = if osname.startsWith(" Windows" ) then ';' else ':'
116+ printf(" line2 start [%s]\n " , line2.take(100 ))
114117 if valid then printf(s " \n ===> success: classpath begins with %s, as reported by [%s] \n " , cwd, scriptFile.getName)
115- assert(valid, s " script ${scriptFile.absPath } did not report valid java.class.path first entry " )
118+ assert(valid, s " script ${scriptFile.getName } did not report valid java.class.path first entry " )
116119
117- lazy val cwd = Paths .get(dotty.tools.dotc.config. Properties .userDir).toFile
120+ lazy val cwd : String = Paths .get(" . " ).toAbsolutePath.normalize.toString.norm
118121
119122 def createArgsFile (): String =
120123 val utfCharset = java.nio.charset.StandardCharsets .UTF_8 .name
121- val text = s " -classpath ${ cwd.absPath} "
124+ val text = s " -classpath $cwd"
122125 val path = Files .createTempFile(" scriptingTest" , " .args" )
123126 Files .write(path, text.getBytes(utfCharset))
124- path.toFile.getAbsolutePath.replace( ' \\ ' , '/' )
127+ path.toFile.getAbsolutePath.norm
125128
126- extension (str : String ) def dropExtension : String =
127- str.reverse.dropWhile(_ != '.' ).drop(1 ).reverse
129+ extension(str : String )
130+ def norm : String = str.replace('\\ ' , '/' )
131+ def dropExtension : String = str.reverse.dropWhile(_ != '.' ).drop(1 ).reverse
128132
129133 extension(f : File ) def absPath : String =
130- f.getAbsolutePath.replace( ' \\ ' , '/' )
134+ f.getAbsolutePath.norm
131135
132136 lazy val osname = Option (sys.props(" os.name" )).getOrElse(" " ).toLowerCase
133137
0 commit comments