@@ -54,7 +54,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
54
54
def outDir : JFile
55
55
def flags : TestFlags
56
56
57
- def runClassPath : String = outDir.getAbsolutePath + " : " + flags.runClassPath
57
+ def runClassPath : String = outDir.getAbsolutePath + JFile .pathSeparator + flags.runClassPath
58
58
59
59
def title : String = self match {
60
60
case self : JointCompilationSource =>
@@ -337,7 +337,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
337
337
" javac" ,
338
338
" -encoding" , " UTF-8" ,
339
339
" -classpath" ,
340
- s " ${Properties .scalaLibrary}: ${targetDir.getAbsolutePath}"
340
+ s " ${Properties .scalaLibrary}${ JFile .pathSeparator} ${targetDir.getAbsolutePath}"
341
341
) ++ flags.all.takeRight(2 ) ++ fs
342
342
343
343
val process = Runtime .getRuntime.exec(fullArgs)
@@ -396,7 +396,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
396
396
val flags = flags0 and (" -d" , tastyOutput.getAbsolutePath) and " -from-tasty"
397
397
398
398
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 , '.' )
400
400
pathStr.stripSuffix(" .tasty" ).stripSuffix(" .hasTasty" )
401
401
}
402
402
val classes = flattenFiles(targetDir).filter(isTastyFile).map(tastyFileToClassName)
@@ -420,14 +420,15 @@ trait ParallelTesting extends RunnerOrchestration { self =>
420
420
421
421
protected def decompile (flags0 : TestFlags , suppressErrors : Boolean , targetDir0 : JFile ): TestReporter = {
422
422
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)
424
424
decompilationOutput.mkdirs()
425
425
val flags =
426
426
flags0 and (" -d" , decompilationOutput.getAbsolutePath) and
427
427
" -decompile" and " -pagewidth" and " 80"
428
428
429
429
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, '.' )
431
432
val classes = flattenFiles(targetDir0).filter(isTastyFile).map(hasTastyFileToClassName).sorted
432
433
433
434
val reporter =
@@ -531,17 +532,19 @@ trait ParallelTesting extends RunnerOrchestration { self =>
531
532
}.headOption
532
533
checkFileOpt match {
533
534
case Some (checkFile) =>
535
+ val ignoredFilePathLine = " /** Decompiled from"
534
536
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 =>
536
539
stripTrailingWhitespaces.unapplySeq(line).map(_.head).getOrElse(line)
537
- }.mkString(" \n " )
538
-
539
- val check : String = Source .fromFile(checkFile).getLines().mkString(" \n " )
540
+ }
540
541
542
+ val check : String = Source .fromFile(checkFile).getLines().filter(! _.startsWith(ignoredFilePathLine))
543
+ .mkString(" \n " )
541
544
542
- if (output != check) {
545
+ if (output.filter( ! _.startsWith(ignoredFilePathLine)).mkString( " \n " ) != check) {
543
546
val outFile = dotty.tools.io.File (checkFile.toPath).addExtension(" .out" )
544
- outFile.writeAll(output)
547
+ outFile.writeAll(output.mkString( " \n " ) )
545
548
val msg =
546
549
s """ Output differed for test $name, use the following command to see the diff:
547
550
| > diff $checkFile $outFile
@@ -678,7 +681,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
678
681
(reporter.compilerCrashed, reporter.errorCount, reporter.warningCount, () => verifyOutput(checkFile, outDir, testSource, reporter.warningCount))
679
682
680
683
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" )
682
685
val reporters = testSource.compilationGroups.map(compile(_, flags, false , outDir))
683
686
val compilerCrashed = reporters.exists(_.compilerCrashed)
684
687
val (errorCount, warningCount) =
@@ -1120,15 +1123,15 @@ trait ParallelTesting extends RunnerOrchestration { self =>
1120
1123
/** Create out directory for `file` */
1121
1124
private def createOutputDirsForFile (file : JFile , sourceDir : JFile , outDir : String ): JFile = {
1122
1125
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" )
1124
1127
targetDir.mkdirs()
1125
1128
targetDir
1126
1129
}
1127
1130
1128
1131
/** Make sure that directory string is as expected */
1129
1132
private def checkRequirements (f : String , sourceDir : JFile , outDir : String ): Unit = {
1130
1133
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 " )
1132
1135
}
1133
1136
1134
1137
/** Separates directories from files and returns them as `(dirs, files)` */
@@ -1145,8 +1148,8 @@ trait ParallelTesting extends RunnerOrchestration { self =>
1145
1148
val sourceFile = new JFile (f)
1146
1149
val parent = sourceFile.getParentFile
1147
1150
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
1150
1153
1151
1154
require(
1152
1155
sourceFile.exists && ! sourceFile.isDirectory &&
@@ -1171,7 +1174,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
1171
1174
* can be used for randomization.
1172
1175
*/
1173
1176
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
1175
1178
val sourceDir = new JFile (f)
1176
1179
checkRequirements(f, sourceDir, outDir)
1177
1180
@@ -1190,7 +1193,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
1190
1193
}
1191
1194
1192
1195
// 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 )
1194
1197
targetDir.mkdirs()
1195
1198
1196
1199
val target = JointCompilationSource (s " compiling ' $f' in test ' $testGroup' " , randomized, flags, targetDir)
@@ -1202,7 +1205,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
1202
1205
* dissociated
1203
1206
*/
1204
1207
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
1206
1209
1207
1210
// Directories in which to compile all containing files with `flags`:
1208
1211
val targetDir = new JFile (outDir)
@@ -1233,7 +1236,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
1233
1236
* the same name as the directory (with the file extension `.check`)
1234
1237
*/
1235
1238
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
1237
1240
val sourceDir = new JFile (f)
1238
1241
checkRequirements(f, sourceDir, outDir)
1239
1242
@@ -1269,7 +1272,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
1269
1272
*/
1270
1273
def compileTastyInDir (f : String , flags0 : TestFlags , fromTastyFilter : FileFilter , decompilationFilter : FileFilter , recompilationFilter : FileFilter )(
1271
1274
implicit testGroup : TestGroup ): TastyCompilationTest = {
1272
- val outDir = defaultOutputDir + testGroup + " / "
1275
+ val outDir = defaultOutputDir + testGroup + JFile .separator
1273
1276
val flags = flags0 and " -Yretain-trees"
1274
1277
val sourceDir = new JFile (f)
1275
1278
checkRequirements(f, sourceDir, outDir)
@@ -1291,15 +1294,15 @@ trait ParallelTesting extends RunnerOrchestration { self =>
1291
1294
) extends JointCompilationSource (name, Array (file), flags, outDir, fromTasty, decompilation) {
1292
1295
1293
1296
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"
1295
1298
val listName = if (fromTasty) " from-tasty" else " decompilation"
1296
1299
s """ |
1297
1300
|Test ' $title' compiled with $errors error(s) and $warnings warning(s),
1298
1301
|the test can be reproduced by running:
1299
1302
|
1300
1303
| sbt "testFromTasty $file"
1301
1304
|
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`
1303
1306
|
1304
1307
| """ .stripMargin
1305
1308
}
@@ -1378,7 +1381,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
1378
1381
* tests.
1379
1382
*/
1380
1383
def compileShallowFilesInDir (f : String , flags : TestFlags )(implicit testGroup : TestGroup ): CompilationTest = {
1381
- val outDir = defaultOutputDir + testGroup + " / "
1384
+ val outDir = defaultOutputDir + testGroup + JFile .separator
1382
1385
val sourceDir = new JFile (f)
1383
1386
checkRequirements(f, sourceDir, outDir)
1384
1387
@@ -1395,7 +1398,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
1395
1398
1396
1399
object ParallelTesting {
1397
1400
1398
- def defaultOutputDir : String = " out/ "
1401
+ def defaultOutputDir : String = " out" + JFile .separator
1399
1402
1400
1403
def isSourceFile (f : JFile ): Boolean = {
1401
1404
val name = f.getName
0 commit comments