Skip to content

Commit

Permalink
Fixed error reporting bug introduced in #2006
Browse files Browse the repository at this point in the history
  • Loading branch information
cmnrd committed Sep 25, 2023
1 parent c623210 commit 470e8ee
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 10 additions & 4 deletions core/src/testFixtures/java/org/lflang/tests/LFTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ public class LFTest implements Comparable<LFTest> {
/** String builder for collecting issues encountered during test execution. */
private final StringBuilder issues = new StringBuilder();

/** Reference to System.out for restoring the default output. */
private static final PrintStream out = System.out;

/** Reference to System.err for restoring the default output. */
private static final PrintStream err = System.err;

private long executionTimeNanoseconds;

/**
Expand Down Expand Up @@ -71,11 +77,11 @@ public void redirectOutputs() {
}

/** End output redirection. */
public void restoreOutputs() {
public static void restoreOutputs() {
System.out.flush();
System.err.flush();
System.setOut(System.out);
System.setErr(System.err);
System.setOut(out);
System.setErr(err);
}

/**
Expand Down Expand Up @@ -130,7 +136,7 @@ public boolean hasPassed() {
return result == Result.TEST_PASS;
}

/** Compile a string that contains all collected errors and return it. */
/** Print a report of all the collected errors. */
public void reportErrors() {
if (this.hasFailed()) {
System.out.println(
Expand Down
2 changes: 1 addition & 1 deletion core/src/testFixtures/java/org/lflang/tests/TestBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ private static void checkAndReportFailures(Set<LFTest> tests) {
var passed = tests.stream().filter(LFTest::hasPassed).toList();
var s = new StringBuffer();
s.append(THIN_LINE);
s.append("Passing: ").append(passed.size()).append("/").append(tests.size()).append("%n");
s.append(String.format("Passing: %d/%d%n", passed.size(), tests.size()));
s.append(THIN_LINE);
passed.forEach(
test ->
Expand Down

0 comments on commit 470e8ee

Please sign in to comment.