Skip to content

Commit

Permalink
Fixed regression tests, which only worked on Linux due to linux line …
Browse files Browse the repository at this point in the history
…endings
  • Loading branch information
svanteschubert committed May 6, 2024
1 parent 64aef19 commit 3c5b09c
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/test/java/net/sf/saxon/DecimalBasedFloatingPointTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,11 @@ void testRounding() {
if (refFile.exists()) {
String referenceResult = Files.readString(Paths.get(refFile.toURI()), Charset.forName("UTF-8"));
if (!resultReloaded.equals(referenceResult)) {
compareTextFiles(TARGET_DIR + reportFileName, REFERENCES_DIR + reportFileName);
Assertions.fail("\nRegression test fails as reference was different!\nNote: If the test fails due to a new output (e.g. programming update) copy the new result over the old reference:\n\t" + TARGET_DIR + reportFileName + "\n\t\tto" + "\n\t" + REFERENCES_DIR + reportFileName);
Boolean hasDifference = Boolean.FALSE;
hasDifference = compareTextFiles(TARGET_DIR + reportFileName, REFERENCES_DIR + reportFileName);
if(hasDifference){
Assertions.fail("\nRegression test fails as reference was different!\nNote: If the test fails due to a new output (e.g. programming update) copy the new result over the old reference:\n\t" + TARGET_DIR + reportFileName + "\n\t\tto" + "\n\t" + REFERENCES_DIR + reportFileName);
}
}
}
} catch (IOException ex) {
Expand Down Expand Up @@ -141,8 +144,11 @@ void testPrecision() {
if (refFile.exists()) {
String referenceResult = Files.readString(Paths.get(refFile.toURI()), Charset.forName("UTF-8"));
if (!resultReloaded.equals(referenceResult)) {
compareTextFiles(TARGET_DIR + reportFileName, REFERENCES_DIR + reportFileName);
Assertions.fail("\nRegression test fails as reference was different!\nNote: If the test fails due to a new output (e.g. programming update) copy the new result over the old reference:\n\t" + TARGET_DIR + reportFileName + "\n\t\tto" + "\n\t" + REFERENCES_DIR + reportFileName);
Boolean hasDifference = Boolean.FALSE;
hasDifference = compareTextFiles(TARGET_DIR + reportFileName, REFERENCES_DIR + reportFileName);
if(hasDifference){
Assertions.fail("\nRegression test fails as reference was different!\nNote: If the test fails due to a new output (e.g. programming update) copy the new result over the old reference:\n\t" + TARGET_DIR + reportFileName + "\n\t\tto" + "\n\t" + REFERENCES_DIR + reportFileName);
}
}
}

Expand All @@ -162,7 +168,8 @@ public static void main(String[] args) {
* Just for showing the different lines, in case the test and reference
* files as strings are unequal!
*/
private static void compareTextFiles(String firstFilePath, String secondFilePath) {
private static Boolean compareTextFiles(String firstFilePath, String secondFilePath) {
Boolean hasDifference = Boolean.FALSE;
try (
BufferedReader bfr1 = Files.newBufferedReader(Paths.get(firstFilePath)); BufferedReader bfr2 = Files.newBufferedReader(Paths.get(secondFilePath));) {
String line1;
Expand All @@ -173,10 +180,13 @@ private static void compareTextFiles(String firstFilePath, String secondFilePath
if (!line1.equals(line2)) {
System.err.println("### Unmatched Line1: '" + line1 + "'\n");
System.err.println("### Unmatched Line2: '" + line2 + "'\n\n");
hasDifference = Boolean.TRUE;
}
}
} catch (Exception e) {
System.err.println(e.getMessage() + e.toString());
hasDifference = Boolean.TRUE;
}
return hasDifference;
}
}

0 comments on commit 3c5b09c

Please sign in to comment.