Skip to content

Commit 53344aa

Browse files
authored
Merge pull request #117 from dflib/98x
PathsHandlerTest - proper glob handling on Windows
2 parents 31f1e97 + 0a74c41 commit 53344aa

2 files changed

Lines changed: 34 additions & 9 deletions

File tree

.github/workflows/maven.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,15 @@ on:
88

99
jobs:
1010
build:
11-
runs-on: ubuntu-latest
11+
runs-on: ${{ matrix.os }}
1212

1313
strategy:
1414
matrix:
15+
os: [ ubuntu-latest ]
1516
java: [ 11, 17, 21, 25 ]
17+
include:
18+
- os: windows-latest
19+
java: 25
1620

1721
steps:
1822
- name: Checkout
@@ -26,4 +30,11 @@ jobs:
2630
cache: 'maven'
2731

2832
- name: Build and test
29-
run: mvn clean verify -U
33+
shell: bash
34+
run: |
35+
if [ "${{ runner.os }}" == "Windows" ]; then
36+
# Testcontainers doesn't support Windows containers
37+
mvn clean test -U
38+
else
39+
mvn clean verify -U
40+
fi

jjava-jupyter/src/test/java/org/dflib/jjava/jupyter/kernel/util/PathsHandlerTest.java

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import java.nio.file.Path;
1010
import java.util.List;
1111
import java.util.stream.Collectors;
12+
import java.util.stream.Stream;
1213

1314
import static org.junit.jupiter.api.Assertions.assertEquals;
1415

@@ -30,16 +31,29 @@ public void testSpitAndResolveGlobs(@TempDir Path dir) throws IOException {
3031
Files.createFile(dir.resolve("b2.txt"));
3132
Files.createFile(dir.resolve("c1.txt"));
3233

33-
String basePath = dir + File.separator;
34+
String baseGlob = dir + "/"; // glob resolver only accepts "/" as splitter
3435

3536
assertEquals(List.of(), PathsHandler.splitAndResolveGlobs(""));
36-
assertEquals(List.of(), PathsHandler.splitAndResolveGlobs(basePath + "a"));
37-
assertEquals(List.of(), PathsHandler.splitAndResolveGlobs(basePath + "a" + File.pathSeparator + "b/c/d"));
37+
assertEquals(List.of(), PathsHandler.splitAndResolveGlobs(baseGlob + "a"));
38+
assertEquals(List.of(), PathsHandler.splitAndResolveGlobs(baseGlob + "a" + File.pathSeparator + "b/c/d"));
3839

39-
assertEquals(List.of(basePath + "a1.txt", basePath + "a2.txt"),
40-
PathsHandler.splitAndResolveGlobs(basePath + "a*").stream().map(p -> p.toAbsolutePath().toString()).sorted().collect(Collectors.toList()));
4140
assertEquals(
42-
List.of(basePath + "a1.txt", basePath + "a2.txt", basePath + "b1.txt", basePath + "b2.txt"),
43-
PathsHandler.splitAndResolveGlobs(basePath + "a*" + File.pathSeparator + basePath + "b*").stream().map(p -> p.toAbsolutePath().toString()).sorted().collect(Collectors.toList()));
41+
List.of(joinPath(dir, "a1.txt"), joinPath(dir, "a2.txt")),
42+
PathsHandler.splitAndResolveGlobs(baseGlob + "a*").stream()
43+
.map(p -> p.toAbsolutePath().toString())
44+
.sorted()
45+
.collect(Collectors.toList())
46+
);
47+
assertEquals(
48+
List.of(joinPath(dir, "a1.txt"), joinPath(dir, "a2.txt"), joinPath(dir, "b1.txt"), joinPath(dir, "b2.txt")),
49+
PathsHandler.splitAndResolveGlobs(baseGlob + "a*" + File.pathSeparator + baseGlob + "b*").stream()
50+
.map(p -> p.toAbsolutePath().toString())
51+
.sorted()
52+
.collect(Collectors.toList())
53+
);
54+
}
55+
56+
private static String joinPath(Object... elements) {
57+
return Stream.of(elements).map(String::valueOf).collect(Collectors.joining(File.separator));
4458
}
4559
}

0 commit comments

Comments
 (0)