Skip to content

Commit e3db72a

Browse files
mchernyavskyyopox
authored andcommitted
RUN: Fix coverage for projects located on WSL file system
1 parent 3219ef6 commit e3db72a

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

coverage/src/main/kotlin/org/rust/coverage/LcovCoverageReport.kt

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
package org.rust.coverage
77

8+
import com.intellij.openapi.util.io.systemIndependentPath
89
import com.intellij.util.containers.PeekableIteratorWrapper
910
import org.rust.stdext.buildList
1011
import java.io.File
@@ -18,7 +19,7 @@ class LcovCoverageReport {
1819
val file = File(filePath).let {
1920
if (it.isAbsolute || basePath == null) it else File(basePath, filePath)
2021
}
21-
val normalizedFilePath = getNormalizedPath(file)
22+
val normalizedFilePath = file.systemIndependentPath
2223
val oldReport = info[normalizedFilePath]
2324
val result = normalizeLineHitsList(report).let {
2425
if (oldReport == null) it else doMerge(oldReport, report)
@@ -103,17 +104,6 @@ class LcovCoverageReport {
103104
}
104105

105106
companion object {
106-
private const val UNIX_SEPARATOR: String = "/"
107-
108-
fun getNormalizedPath(file: File): String {
109-
val uri = file.toURI()
110-
val normalizedUri = uri.normalize()
111-
var normalizedPath = normalizedUri.path
112-
if (normalizedPath.startsWith(UNIX_SEPARATOR) && File.separator != UNIX_SEPARATOR) {
113-
normalizedPath = normalizedPath.substring(1)
114-
}
115-
return normalizedPath
116-
}
117107

118108
private fun normalizeLineHitsList(lineHits: List<LineHits>): List<LineHits> =
119109
lineHits.sortedBy { it.lineNumber }.distinctBy { it.lineNumber }

0 commit comments

Comments
 (0)