@@ -14,6 +14,7 @@ import java.nio.file.{Files, FileSystems, Path, Paths, StandardCopyOption}
1414import scala .jdk .CollectionConverters .*
1515import scala .util .Properties .userDir
1616import scala .language .unsafeNulls
17+ import scala .collection .mutable .Buffer
1718
1819@ Category (Array (classOf [BootstrappedOnlyTests ]))
1920class CoverageTests :
@@ -31,6 +32,15 @@ class CoverageTests:
3132 checkCoverageIn(rootSrc.resolve(" run" ), true )
3233
3334 def checkCoverageIn (dir : Path , run : Boolean )(using TestGroup ): Unit =
35+ /** Converts \ to / on windows, to make the tests pass without changing the serialization. */
36+ def fixWindowsPaths (lines : Buffer [String ]): Buffer [String ] =
37+ val separator = java.io.File .separatorChar
38+ if separator != '/' then
39+ lines.map(_.replace(" \\ " + separator, " /" )) // escape the separator
40+ else
41+ lines
42+ end fixWindowsPaths
43+
3444 Files .walk(dir).filter(scalaFile.matches).forEach(p => {
3545 val path = p
3646 val fileName = path.getFileName.toString.stripSuffix(" .scala" )
@@ -41,8 +51,8 @@ class CoverageTests:
4151 if updateCheckFiles then
4252 Files .copy(targetFile, expectFile, StandardCopyOption .REPLACE_EXISTING )
4353 else
44- val expected = Files .readAllLines(expectFile).asScala
45- val obtained = Files .readAllLines(targetFile).asScala
54+ val expected = fixWindowsPaths( Files .readAllLines(expectFile).asScala)
55+ val obtained = fixWindowsPaths( Files .readAllLines(targetFile).asScala)
4656 if expected != obtained then
4757 for ((exp, actual),i) <- expected.zip(obtained).filter(_ != _).zipWithIndex do
4858 Console .err.println(s " wrong line ${i+ 1 }: " )
0 commit comments