Skip to content

Commit 354e06e

Browse files
authored
fix: Windows compatibility — portable test-pack paths, tolerant assertions (#355)
* fix: make test-pack writing and transform assertions Windows-compatible - PipelineTestPackWriter: store sample input/output paths in the test-pack model with '/' separators via UrlUtils.toPortableString; Path.toString() wrote backslashes on Windows into JSON that is later resolved as classpath resources - TransformTestExtension: normalise line endings before comparing the expected output file with the freshly serialised output, matching the existing assertJsonEquals convention - LatestSchemesImportTest: zip entry names always use '/' per the ZIP spec, so do not test them against File.separator - Add .gitattributes pinning LF so expectation files survive core.autocrlf on Windows Relies on rune-common pinning '\n' in its pretty printers, so writers in this library now produce identical output on every platform. * chore: update Rune DSL to 10.2.3 10.2.3 includes the Windows-compatibility fixes from finos/rune-dsl#1324. * ci: add PR checks on Ubuntu and Windows Mirrors the check-pr workflow in finos/rune-dsl so Windows regressions are caught at PR time. Long paths are enabled on Windows before checkout.
1 parent ab7da17 commit 354e06e

5 files changed

Lines changed: 47 additions & 4 deletions

File tree

.github/workflows/check-pr.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: PR Checks
2+
3+
on:
4+
pull_request:
5+
6+
# Cancel previous jobs
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
9+
cancel-in-progress: true
10+
11+
jobs:
12+
build-on-ubuntu:
13+
name: Maven Build on Ubuntu
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v6
17+
- uses: actions/setup-java@v5
18+
with:
19+
java-version: '21'
20+
distribution: temurin
21+
cache: maven
22+
- name: Build with Maven
23+
run: mvn -B clean package
24+
25+
build-on-windows:
26+
name: Maven Build on Windows
27+
runs-on: windows-latest
28+
steps:
29+
- name: Enable git long paths
30+
run: git config --system core.longpaths true
31+
- uses: actions/checkout@v6
32+
- uses: actions/setup-java@v5
33+
with:
34+
java-version: '21'
35+
distribution: temurin
36+
cache: maven
37+
- name: Build with Maven
38+
run: mvn -B clean package

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
<java.enforced.version>[21,22)</java.enforced.version>
9393
<maven.compiler.release>21</maven.compiler.release>
9494

95-
<rune.dsl.version>10.2.2</rune.dsl.version>
95+
<rune.dsl.version>10.2.3</rune.dsl.version>
9696
<rune.common.version>0.0.0.main-SNAPSHOT</rune.common.version>
9797

9898
<xtext.version>2.38.0</xtext.version>

src/main/java/com/regnosys/testing/pipeline/PipelineTestPackWriter.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
import java.util.stream.Stream;
6161

6262
import static com.regnosys.rosetta.common.util.UrlUtils.getBaseFileName;
63+
import static com.regnosys.rosetta.common.util.UrlUtils.toPortableString;
6364

6465
public class PipelineTestPackWriter {
6566

@@ -207,7 +208,9 @@ private TestPackModel writeTestPackSamples(Path resourcesPath,
207208
String baseFileName = getBaseFileName(inputSample.toUri().toURL());
208209
String displayName = baseFileName.replace("-", " ");
209210

210-
TestPackModel.SampleModel sampleModel = new TestPackModel.SampleModel(baseFileName.toLowerCase(), displayName, inputSample.toString(), outputPath.toString(), assertions);
211+
// Sample paths are stored in the test-pack model and resolved as classpath
212+
// resources, so they always use "/" regardless of the platform separator
213+
TestPackModel.SampleModel sampleModel = new TestPackModel.SampleModel(baseFileName.toLowerCase(), displayName, toPortableString(inputSample), toPortableString(outputPath), assertions);
211214
sampleModels.add(sampleModel);
212215

213216
Files.createDirectories(resourcesPath.resolve(outputPath).getParent());

src/main/java/com/regnosys/testing/transform/TransformTestExtension.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
import static com.regnosys.rosetta.common.transform.TestPackUtils.*;
6464
import static com.regnosys.rosetta.common.transform.TestPackUtils.getPipelineModel;
6565
import static com.regnosys.testing.TestingExpectationUtil.readStringFromResources;
66+
import static com.regnosys.testing.TestingExpectationUtil.normaliseLineEndings;
6667
import static org.junit.jupiter.api.Assertions.assertEquals;
6768
import static org.junit.jupiter.api.Assertions.assertNotNull;
6869

@@ -197,7 +198,7 @@ private void runTransformAndAssert(String testPackId, TestPackModel.SampleModel
197198
}
198199

199200
String expectedOutput = readStringFromResources(Path.of(sampleModel.getOutputPath()));
200-
assertEquals(expectedOutput, actualOutput);
201+
assertEquals(normaliseLineEndings(expectedOutput), normaliseLineEndings(actualOutput));
201202

202203
TestPackModel.SampleModel.Assertions expectedAssertions = sampleModel.getAssertions();
203204
assertEquals(expectedAssertions, actualAssertions);

src/test/java/com/regnosys/testing/schemeimport/LatestSchemesImportTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ private static void unzip() {
8484

8585
boolean isDirectory = false;
8686
//check for files or directory
87-
if (zipEntry.getName().endsWith(File.separator)) {
87+
// Zip entry names always use "/" regardless of the platform separator
88+
if (zipEntry.getName().endsWith("/")) {
8889
isDirectory = true;
8990
}
9091

0 commit comments

Comments
 (0)