Skip to content

Commit 7469f90

Browse files
otethaltimfel
authored andcommitted
Fix VirtualFileSystem on Windows, skip test_native_executable_venv_and_one_file
(cherry picked from commit 053b42b)
1 parent 1258a82 commit 7469f90

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

graalpython/com.oracle.graal.python.test/src/tests/test_standalone.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949

5050
def run_cmd(cmd, env, cwd=None):
5151
print(f"Executing:\n {cmd=}\n {env=}\n {cwd=}")
52-
process = subprocess.Popen(cmd, env=env, cwd=cwd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True, text=True)
52+
process = subprocess.Popen(cmd, env=env, cwd=cwd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True, text=True, errors='backslashreplace')
5353
out = []
5454
for line in iter(process.stdout.readline, ""):
5555
print(line, end="")
@@ -170,6 +170,7 @@ def test_native_executable_one_file():
170170
assert "hello world, argv[1:]: " + str(cmd[1:]) in out
171171

172172
@unittest.skipUnless(is_enabled, "ENABLE_STANDALONE_UNITTESTS is not true")
173+
@unittest.skipUnless(sys.platform != 'win32', 'not supported on Windows')
173174
def test_native_executable_venv_and_one_file():
174175
graalpy = get_gp()
175176
if graalpy is None:

graalpython/lib-graalpython/modules/standalone/templates/VirtualFileSystem.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public final class VirtualFileSystem implements FileSystem, AutoCloseable {
8282
/*
8383
* Root of the virtual filesystem in the resources.
8484
*/
85-
private static final Path VFS_PREFIX = Path.of("/vfs");
85+
private static final String VFS_PREFIX = "/vfs";
8686

8787
/*
8888
* Index of all files and directories available in the resources at runtime.
@@ -194,18 +194,14 @@ public static boolean isWindows() {
194194
return System.getProperty("os.name").toLowerCase(Locale.ROOT).contains("windows");
195195
}
196196

197-
public String resourcePathToPlatformPath(String spath) {
198-
Path path = Path.of(spath);
197+
public String resourcePathToPlatformPath(String path) {
199198
assert path.startsWith(VFS_PREFIX);
200-
Path mountPoint = this.mountPoint;
201-
if (path.startsWith(VFS_PREFIX)) {
202-
path = VFS_PREFIX.relativize(path);
203-
}
204-
String result = mountPoint.resolve(path).toString();
199+
path = path.substring(VFS_PREFIX.length() + 1);
205200
if (!PLATFORM_SEPARATOR.equals(RESOURCE_SEPARATOR)) {
206-
result = result.replace(RESOURCE_SEPARATOR, PLATFORM_SEPARATOR);
201+
path = path.replace(RESOURCE_SEPARATOR, PLATFORM_SEPARATOR);
207202
}
208-
return result;
203+
Path mountPoint = this.mountPoint;
204+
return mountPoint.resolve(path).toString();
209205
}
210206

211207
private String platformPathToResourcePath(String path) throws IOException {

0 commit comments

Comments
 (0)