Skip to content

Commit 52c9e63

Browse files
committed
fixed VFS tests for windows
1 parent 9b0b1f2 commit 52c9e63

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

graalpython/com.oracle.graal.python.test.integration/src/org/graalvm/python/embedding/utils/test/VirtualFileSystemTest.java

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,12 @@ public void toRealPath() throws Exception {
146146
// from VFS
147147
for (FileSystem fs : new FileSystem[]{rwHostIOVFS, rHostIOVFS, noHostIOVFS}) {
148148
// check regular resource dir
149-
assertEquals(VFS_MOUNT_POINT + File.separator + "dir1", fs.toRealPath(Path.of(VFS_MOUNT_POINT + File.separator + "dir1")).toString());
149+
assertEquals(Path.of(VFS_MOUNT_POINT + File.separator + "dir1"), fs.toRealPath(Path.of(VFS_MOUNT_POINT + File.separator + "dir1")));
150150
// check regular resource file
151-
assertEquals(VFS_MOUNT_POINT + File.separator + "SomeFile", fs.toRealPath(Path.of(VFS_MOUNT_POINT + File.separator + "SomeFile")).toString());
151+
assertEquals(Path.of(VFS_MOUNT_POINT + File.separator + "SomeFile"), fs.toRealPath(Path.of(VFS_MOUNT_POINT + File.separator + "SomeFile")));
152152
// check to be extracted file
153153
checkExtractedFile(fs.toRealPath(Path.of(VFS_MOUNT_POINT + File.separator + "extractme")), new String[]{"text1", "text2"});
154-
assertEquals(VFS_MOUNT_POINT + File.separator + "does-not-exist/extractme", fs.toRealPath(Path.of(VFS_MOUNT_POINT + File.separator + "does-not-exist/extractme")).toString());
154+
assertEquals(Path.of(VFS_MOUNT_POINT + File.separator + "does-not-exist/extractme"), fs.toRealPath(Path.of(VFS_MOUNT_POINT + File.separator + "does-not-exist/extractme")));
155155
}
156156

157157
// from real FS
@@ -168,13 +168,13 @@ public void toAbsolutePath() throws Exception {
168168
// from VFS
169169
for (FileSystem fs : new FileSystem[]{rwHostIOVFS, rHostIOVFS, noHostIOVFS}) {
170170
// check regular resource dir
171-
assertEquals(VFS_MOUNT_POINT + File.separator + "dir1", fs.toAbsolutePath(Path.of(VFS_MOUNT_POINT + File.separator + "dir1")).toString());
171+
assertEquals(Path.of(VFS_MOUNT_POINT + File.separator + "dir1"), fs.toAbsolutePath(Path.of(VFS_MOUNT_POINT + File.separator + "dir1")));
172172
// check regular resource file
173-
assertEquals(VFS_MOUNT_POINT + File.separator + "SomeFile", fs.toAbsolutePath(Path.of(VFS_MOUNT_POINT + File.separator + "SomeFile")).toString());
173+
assertEquals(Path.of(VFS_MOUNT_POINT + File.separator + "SomeFile"), fs.toAbsolutePath(Path.of(VFS_MOUNT_POINT + File.separator + "SomeFile")));
174174
// check to be extracted file
175175
checkExtractedFile(fs.toAbsolutePath(Path.of(VFS_MOUNT_POINT + File.separator + "extractme")), new String[]{"text1", "text2"});
176176
checkExtractedFile(fs.toAbsolutePath(Path.of(VFS_MOUNT_POINT + File.separator + "dir1/extractme")), null);
177-
assertEquals(VFS_MOUNT_POINT + File.separator + "does-not-exist/extractme", fs.toAbsolutePath(Path.of(VFS_MOUNT_POINT + File.separator + "does-not-exist/extractme")).toString());
177+
assertEquals(Path.of(VFS_MOUNT_POINT + File.separator + "does-not-exist/extractme"), fs.toAbsolutePath(Path.of(VFS_MOUNT_POINT + File.separator + "does-not-exist/extractme")));
178178
}
179179

180180
// from real FS
@@ -364,8 +364,7 @@ public void newByteChannel() throws IOException {
364364
ByteBuffer buffer = ByteBuffer.allocate(1024);
365365
bch.read(buffer);
366366
String s = new String(buffer.array());
367-
368-
String[] ss = s.split("\n");
367+
String[] ss = s.split(System.lineSeparator());
369368
assertTrue(ss.length >= 2);
370369
assertEquals("text1", ss[0]);
371370
assertEquals("text2", ss[1]);
@@ -391,7 +390,7 @@ public void newByteChannel() throws IOException {
391390
ByteBuffer buffer = ByteBuffer.allocate(4);
392391
bch.read(buffer);
393392
String s = new String(buffer.array());
394-
String[] ss = s.split("\n");
393+
String[] ss = s.split(System.lineSeparator());
395394
assertTrue(ss.length >= 1);
396395
assertEquals("text", ss[0]);
397396
}
@@ -413,8 +412,8 @@ public void newDirectoryStream() throws Exception {
413412
s.add(p.toString());
414413
}
415414
assertEquals(2, s.size());
416-
assertTrue(s.contains(VFS_MOUNT_POINT + File.separator + "dir1/extractme"));
417-
assertTrue(s.contains(VFS_MOUNT_POINT + File.separator + "dir1/file2"));
415+
assertTrue(s.contains(VFS_MOUNT_POINT + File.separator + "dir1" + File.separator + "extractme"));
416+
assertTrue(s.contains(VFS_MOUNT_POINT + File.separator + "dir1" + File.separator + "file2"));
418417

419418
ds = fs.newDirectoryStream(Path.of(VFS_MOUNT_POINT + File.separator + "dir1"), (p) -> false);
420419
assertFalse(ds.iterator().hasNext());
@@ -730,8 +729,8 @@ assert len(dirs) == 8, 'expected 8 dirs, got ' + str(len(dirs))
730729
with open("/test_mount_point/file1", "r") as f:
731730
l = f.readlines()
732731
assert len(l) == 2, 'expect 2 lines, got ' + len(l)
733-
assert l[0] == "text1\\n", 'expected "text1", got ' + l[0]
734-
assert l[1] == "text2\\n", 'expected "text2", got ' + l[1]
732+
assert l[0].startswith("text1"), f'expected "text1", got "{l[0]}"'
733+
assert l[1].startswith("text2"), f'expected "text2", got "{l[1]}"'
735734
736735
with open("/test_mount_point/dir1/file2", "r") as f:
737736
l = f.readlines()

0 commit comments

Comments
 (0)