@@ -54,7 +54,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
5454 def outDir : JFile
5555 def flags : TestFlags
5656
57- def runClassPath : String = outDir.getAbsolutePath + " : " + flags.runClassPath
57+ def runClassPath : String = outDir.getAbsolutePath + JFile .pathSeparator + flags.runClassPath
5858
5959 def title : String = self match {
6060 case self : JointCompilationSource =>
@@ -337,7 +337,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
337337 " javac" ,
338338 " -encoding" , " UTF-8" ,
339339 " -classpath" ,
340- s " ${Properties .scalaLibrary}: ${targetDir.getAbsolutePath}"
340+ s " ${Properties .scalaLibrary}${ JFile .pathSeparator} ${targetDir.getAbsolutePath}"
341341 ) ++ flags.all.takeRight(2 ) ++ fs
342342
343343 val process = Runtime .getRuntime.exec(fullArgs)
@@ -396,7 +396,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
396396 val flags = flags0 and (" -d" , tastyOutput.getAbsolutePath) and " -from-tasty"
397397
398398 def tastyFileToClassName (f : JFile ): String = {
399- val pathStr = targetDir.toPath.relativize(f.toPath).toString.replace('/' , '.' )
399+ val pathStr = targetDir.toPath.relativize(f.toPath).toString.replace(JFile .separatorChar , '.' )
400400 pathStr.stripSuffix(" .tasty" ).stripSuffix(" .hasTasty" )
401401 }
402402 val classes = flattenFiles(targetDir).filter(isTastyFile).map(tastyFileToClassName)
@@ -420,14 +420,15 @@ trait ParallelTesting extends RunnerOrchestration { self =>
420420
421421 protected def decompile (flags0 : TestFlags , suppressErrors : Boolean , targetDir0 : JFile ): TestReporter = {
422422 val targetDir = new JFile (targetDir0.getParent + " _decompiled" )
423- val decompilationOutput = new JFile (targetDir + " / " + targetDir0.getName)
423+ val decompilationOutput = new JFile (targetDir + JFile .separator + targetDir0.getName)
424424 decompilationOutput.mkdirs()
425425 val flags =
426426 flags0 and (" -d" , decompilationOutput.getAbsolutePath) and
427427 " -decompile" and " -pagewidth" and " 80"
428428
429429 def hasTastyFileToClassName (f : JFile ): String =
430- targetDir0.toPath.relativize(f.toPath).toString.stripSuffix(" .hasTasty" ).stripSuffix(" .tasty" ).replace('/' , '.' )
430+ targetDir0.toPath.relativize(f.toPath).toString.stripSuffix(" .hasTasty" ).
431+ stripSuffix(" .tasty" ).replace(JFile .separatorChar, '.' )
431432 val classes = flattenFiles(targetDir0).filter(isTastyFile).map(hasTastyFileToClassName).sorted
432433
433434 val reporter =
@@ -531,17 +532,19 @@ trait ParallelTesting extends RunnerOrchestration { self =>
531532 }.headOption
532533 checkFileOpt match {
533534 case Some (checkFile) =>
535+ val ignoredFilePathLine = " /** Decompiled from"
534536 val stripTrailingWhitespaces = " (.*\\ S|)\\ s+" .r
535- val output = Source .fromFile(outDir.getParent + " _decompiled/" + outDir.getName + " /decompiled.scala" ).getLines().map {line =>
537+ val output = Source .fromFile(outDir.getParent + " _decompiled" + JFile .separator + outDir.getName
538+ + JFile .separator + " decompiled.scala" ).getLines().map {line =>
536539 stripTrailingWhitespaces.unapplySeq(line).map(_.head).getOrElse(line)
537- }.mkString(" \n " )
538-
539- val check : String = Source .fromFile(checkFile).getLines().mkString(" \n " )
540+ }
540541
542+ val check : String = Source .fromFile(checkFile).getLines().filter(! _.startsWith(ignoredFilePathLine))
543+ .mkString(" \n " )
541544
542- if (output != check) {
545+ if (output.filter( ! _.startsWith(ignoredFilePathLine)).mkString( " \n " ) != check) {
543546 val outFile = dotty.tools.io.File (checkFile.toPath).addExtension(" .out" )
544- outFile.writeAll(output)
547+ outFile.writeAll(output.mkString( " \n " ) )
545548 val msg =
546549 s """ Output differed for test $name, use the following command to see the diff:
547550 | > diff $checkFile $outFile
@@ -678,7 +681,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
678681 (reporter.compilerCrashed, reporter.errorCount, reporter.warningCount, () => verifyOutput(checkFile, outDir, testSource, reporter.warningCount))
679682
680683 case testSource @ SeparateCompilationSource (_, dir, flags, outDir) =>
681- val checkFile = new JFile (dir.getAbsolutePath.reverse.dropWhile(_ == '/' ).reverse + " .check" )
684+ val checkFile = new JFile (dir.getAbsolutePath.reverse.dropWhile(_ == JFile .separatorChar ).reverse + " .check" )
682685 val reporters = testSource.compilationGroups.map(compile(_, flags, false , outDir))
683686 val compilerCrashed = reporters.exists(_.compilerCrashed)
684687 val (errorCount, warningCount) =
@@ -1120,15 +1123,15 @@ trait ParallelTesting extends RunnerOrchestration { self =>
11201123 /** Create out directory for `file` */
11211124 private def createOutputDirsForFile (file : JFile , sourceDir : JFile , outDir : String ): JFile = {
11221125 val uniqueSubdir = file.getName.substring(0 , file.getName.lastIndexOf('.' ))
1123- val targetDir = new JFile (outDir + s " ${sourceDir.getName}/ $uniqueSubdir" )
1126+ val targetDir = new JFile (outDir + s " ${sourceDir.getName}${ JFile .separatorChar} $uniqueSubdir" )
11241127 targetDir.mkdirs()
11251128 targetDir
11261129 }
11271130
11281131 /** Make sure that directory string is as expected */
11291132 private def checkRequirements (f : String , sourceDir : JFile , outDir : String ): Unit = {
11301133 require(sourceDir.isDirectory && sourceDir.exists, " passed non-directory to `compileFilesInDir`" )
1131- require(outDir.last == '/' , " please specify an `outDir` with a trailing slash " )
1134+ require(outDir.last == JFile .separatorChar , " please specify an `outDir` with a trailing file separator " )
11321135 }
11331136
11341137 /** Separates directories from files and returns them as `(dirs, files)` */
@@ -1145,8 +1148,8 @@ trait ParallelTesting extends RunnerOrchestration { self =>
11451148 val sourceFile = new JFile (f)
11461149 val parent = sourceFile.getParentFile
11471150 val outDir =
1148- defaultOutputDir + testGroup + " / " +
1149- sourceFile.getName.substring(0 , sourceFile.getName.lastIndexOf('.' )) + " / "
1151+ defaultOutputDir + testGroup + JFile .separator +
1152+ sourceFile.getName.substring(0 , sourceFile.getName.lastIndexOf('.' )) + JFile .separator
11501153
11511154 require(
11521155 sourceFile.exists && ! sourceFile.isDirectory &&
@@ -1171,7 +1174,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
11711174 * can be used for randomization.
11721175 */
11731176 def compileDir (f : String , flags : TestFlags , randomOrder : Option [Int ] = None , recursive : Boolean = true )(implicit testGroup : TestGroup ): CompilationTest = {
1174- val outDir = defaultOutputDir + testGroup + " / "
1177+ val outDir = defaultOutputDir + testGroup + JFile .separator
11751178 val sourceDir = new JFile (f)
11761179 checkRequirements(f, sourceDir, outDir)
11771180
@@ -1190,7 +1193,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
11901193 }
11911194
11921195 // Directories in which to compile all containing files with `flags`:
1193- val targetDir = new JFile (outDir + " / " + sourceDir.getName + " / " )
1196+ val targetDir = new JFile (outDir + JFile .separator + sourceDir.getName + JFile .separator )
11941197 targetDir.mkdirs()
11951198
11961199 val target = JointCompilationSource (s " compiling ' $f' in test ' $testGroup' " , randomized, flags, targetDir)
@@ -1202,7 +1205,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
12021205 * dissociated
12031206 */
12041207 def compileList (testName : String , files : List [String ], flags : TestFlags )(implicit testGroup : TestGroup ): CompilationTest = {
1205- val outDir = defaultOutputDir + testGroup + " / " + testName + " / "
1208+ val outDir = defaultOutputDir + testGroup + JFile .separator + testName + JFile .separator
12061209
12071210 // Directories in which to compile all containing files with `flags`:
12081211 val targetDir = new JFile (outDir)
@@ -1233,7 +1236,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
12331236 * the same name as the directory (with the file extension `.check`)
12341237 */
12351238 def compileFilesInDir (f : String , flags : TestFlags , fileFilter : FileFilter = FileFilter .NoFilter )(implicit testGroup : TestGroup ): CompilationTest = {
1236- val outDir = defaultOutputDir + testGroup + " / "
1239+ val outDir = defaultOutputDir + testGroup + JFile .separator
12371240 val sourceDir = new JFile (f)
12381241 checkRequirements(f, sourceDir, outDir)
12391242
@@ -1269,7 +1272,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
12691272 */
12701273 def compileTastyInDir (f : String , flags0 : TestFlags , fromTastyFilter : FileFilter , decompilationFilter : FileFilter , recompilationFilter : FileFilter )(
12711274 implicit testGroup : TestGroup ): TastyCompilationTest = {
1272- val outDir = defaultOutputDir + testGroup + " / "
1275+ val outDir = defaultOutputDir + testGroup + JFile .separator
12731276 val flags = flags0 and " -Yretain-trees"
12741277 val sourceDir = new JFile (f)
12751278 checkRequirements(f, sourceDir, outDir)
@@ -1291,15 +1294,15 @@ trait ParallelTesting extends RunnerOrchestration { self =>
12911294 ) extends JointCompilationSource (name, Array (file), flags, outDir, fromTasty, decompilation) {
12921295
12931296 override def buildInstructions (errors : Int , warnings : Int ): String = {
1294- val runOrPos = if (file.getPath.startsWith(" tests/ run/ " )) " run" else " pos"
1297+ val runOrPos = if (file.getPath.startsWith(s " tests ${ JFile .separator} run ${ JFile .separator} " )) " run" else " pos"
12951298 val listName = if (fromTasty) " from-tasty" else " decompilation"
12961299 s """ |
12971300 |Test ' $title' compiled with $errors error(s) and $warnings warning(s),
12981301 |the test can be reproduced by running:
12991302 |
13001303 | sbt "testFromTasty $file"
13011304 |
1302- |This tests can be disabled by adding ` ${file.getName}` to `compiler/ test/ dotc/ $runOrPos- $listName.blacklist`
1305+ |This tests can be disabled by adding ` ${file.getName}` to `compiler ${ JFile .separator} test ${ JFile .separator} dotc ${ JFile .separator} $runOrPos- $listName.blacklist`
13031306 |
13041307 | """ .stripMargin
13051308 }
@@ -1378,7 +1381,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
13781381 * tests.
13791382 */
13801383 def compileShallowFilesInDir (f : String , flags : TestFlags )(implicit testGroup : TestGroup ): CompilationTest = {
1381- val outDir = defaultOutputDir + testGroup + " / "
1384+ val outDir = defaultOutputDir + testGroup + JFile .separator
13821385 val sourceDir = new JFile (f)
13831386 checkRequirements(f, sourceDir, outDir)
13841387
@@ -1395,7 +1398,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
13951398
13961399object ParallelTesting {
13971400
1398- def defaultOutputDir : String = " out/ "
1401+ def defaultOutputDir : String = " out" + JFile .separator
13991402
14001403 def isSourceFile (f : JFile ): Boolean = {
14011404 val name = f.getName
0 commit comments