Skip to content

Commit 45ac398

Browse files
Fix coverage tests on windows (#16245)
[test_windows_full failed](https://github.com/lampepfl/dotty/actions/runs/3313981586/jobs/5472673283) Coverage tests replaced all `\` by `/`, but the paths are now escaped, which turns `C:\folder\file` into `C:\\folder\\file`. Thus we need to replace `\\` by `/`! Note: this fix is better than removing `.escaped` from paths, because paths are allowed to contains problematic characters such as newlines, which would break the coverage report.
2 parents 7f21e0a + 432174b commit 45ac398

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

compiler/test/dotty/tools/dotc/coverage/CoverageTests.scala

+4-3
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,12 @@ class CoverageTests:
3333
checkCoverageIn(rootSrc.resolve("run"), true)
3434

3535
def checkCoverageIn(dir: Path, run: Boolean)(using TestGroup): Unit =
36-
/** Converts \ to / on windows, to make the tests pass without changing the serialization. */
36+
/** Converts \\ (escaped \) to / on windows, to make the tests pass without changing the serialization. */
3737
def fixWindowsPaths(lines: Buffer[String]): Buffer[String] =
3838
val separator = java.io.File.separatorChar
39-
if separator != '/' then
40-
lines.map(_.replace(separator, '/'))
39+
if separator == '\\' then
40+
val escapedSep = "\\\\"
41+
lines.map(_.replace(escapedSep, "/"))
4142
else
4243
lines
4344
end fixWindowsPaths

0 commit comments

Comments
 (0)