@@ -14,6 +14,7 @@ import java.nio.file.{Files, FileSystems, Path, Paths, StandardCopyOption}
14
14
import scala .jdk .CollectionConverters .*
15
15
import scala .util .Properties .userDir
16
16
import scala .language .unsafeNulls
17
+ import scala .collection .mutable .Buffer
17
18
18
19
@ Category (Array (classOf [BootstrappedOnlyTests ]))
19
20
class CoverageTests :
@@ -31,6 +32,15 @@ class CoverageTests:
31
32
checkCoverageIn(rootSrc.resolve(" run" ), true )
32
33
33
34
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
+
34
44
Files .walk(dir).filter(scalaFile.matches).forEach(p => {
35
45
val path = p
36
46
val fileName = path.getFileName.toString.stripSuffix(" .scala" )
@@ -41,8 +51,8 @@ class CoverageTests:
41
51
if updateCheckFiles then
42
52
Files .copy(targetFile, expectFile, StandardCopyOption .REPLACE_EXISTING )
43
53
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)
46
56
if expected != obtained then
47
57
for ((exp, actual),i) <- expected.zip(obtained).filter(_ != _).zipWithIndex do
48
58
Console .err.println(s " wrong line ${i+ 1 }: " )
0 commit comments