Python path validation should support \\wsl paths on Windows.

On Windows user may create project in `\\wsl`

GitOrigin-RevId: 593ecf6440394df6d3034b1ea630c262b6ff26c2
This commit is contained in:
Ilya.Kazakevich
2023-08-11 20:24:30 +03:00
committed by intellij-monorepo-bot
parent 36bfc32b19
commit b708b01a7d
2 changed files with 31 additions and 1 deletions

View File

@@ -52,7 +52,8 @@ class ValidationRequest(@NonNls internal val path: String?,
private fun isAbsolutePath(path: String): Boolean = when (platformAndRoot.platform) {
Platform.UNIX -> path.startsWith("/")
Platform.WINDOWS -> OSAgnosticPathUtil.isAbsoluteDosPath(path)
// On Windows user may create project in \\wsl
Platform.WINDOWS -> OSAgnosticPathUtil.isAbsoluteDosPath(path) || path.startsWith("\\\\wsl")
}
}

View File

@@ -0,0 +1,29 @@
package com.jetbrains.python.tests
import com.intellij.execution.Platform
import com.jetbrains.python.pathValidation.PlatformAndRoot
import com.jetbrains.python.pathValidation.ValidationRequest
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertNull
import org.junit.Test
class ValidationRequestTest {
@Test
fun testAbsolutePath() {
if (PlatformAndRoot.local.platform == Platform.UNIX) {
assertNull("No error must be returned",
ValidationRequest("/", "", PlatformAndRoot.local, null).validate { null })
assertNotNull("Path not absolute, but no error returned",
ValidationRequest("abc", "", PlatformAndRoot.local, null).validate { null })
}
else {
assertNull("No error must be returned",
ValidationRequest("\\\\wsl$\\asdad", "", PlatformAndRoot.local, null).validate { null })
assertNull("No error must be returned",
ValidationRequest("c:\\", "", PlatformAndRoot.local, null).validate { null })
assertNotNull("Path not absolute, but no error returned",
ValidationRequest("abc", "", PlatformAndRoot.local, null).validate { null })
}
}
}