[test framework] adding all Windows roots to in-memory filesystems (excluding UNC ones)

GitOrigin-RevId: 140ffdfa34059f2d15337445d5103cdb2201939a
This commit is contained in:
Roman Shevchenko
2025-09-25 11:34:34 +00:00
committed by intellij-monorepo-bot
parent 13e6e530ba
commit 7867dc603e
@@ -2,6 +2,7 @@
package com.intellij.testFramework.rules
import com.github.marschall.memoryfilesystem.MemoryFileSystemBuilder
import com.intellij.openapi.util.io.OSAgnosticPathUtil
import com.intellij.util.system.OS
import org.junit.jupiter.api.extension.AfterEachCallback
import org.junit.jupiter.api.extension.BeforeEachCallback
@@ -69,7 +70,10 @@ private fun fsBuilder(windows: Boolean): MemoryFileSystemBuilder =
if (windows) {
val builder = MemoryFileSystemBuilder.newWindows().setCurrentWorkingDirectory("C:\\")
if (OS.CURRENT == OS.Windows) {
FileSystems.getDefault().rootDirectories.forEach { builder.addRoot(it.toString()) }
FileSystems.getDefault().rootDirectories.asSequence()
.map { it.toString() }
.filter { OSAgnosticPathUtil.isAbsoluteDosPath(it) }
.forEach { builder.addRoot(it) }
}
builder
}