mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 15:19:59 +07:00
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:
committed by
intellij-monorepo-bot
parent
36bfc32b19
commit
b708b01a7d
@@ -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")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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 })
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user