Prevent intermittent test failure due to PSystemError creating different output at different times of the hour.

This commit is contained in:
matthew16550 2021-09-03 17:51:22 +10:00
parent 1f5ef7c9c1
commit 8903d5e689
2 changed files with 15 additions and 1 deletions

View File

@ -97,6 +97,13 @@ import net.sourceforge.plantuml.version.PSystemVersion;
import net.sourceforge.plantuml.version.Version;
public abstract class PSystemError extends PlainDiagram {
// Dodgy kludge for testing - we will need a different approach if we want to test addMessageDedication() etc.
private static boolean disableTimeBasedErrorDecorations = false;
public static void disableTimeBasedErrorDecorations() {
PSystemError.disableTimeBasedErrorDecorations = true;
}
protected List<StringLocated> trace;
protected ErrorUml singleError;
@ -249,7 +256,10 @@ public abstract class PSystemError extends PlainDiagram {
}
final int min = (int) (System.currentTimeMillis() / 60000L) % 60;
// udrawable = addMessageAdopt(udrawable);
if (min == 1 || min == 8 || min == 13 || min == 55) {
if (disableTimeBasedErrorDecorations) {
// do nothing
}
else if (min == 1 || min == 8 || min == 13 || min == 55) {
udrawable = addMessagePatreon(udrawable);
} else if (min == 15) {
udrawable = addMessageLiberapay(udrawable);

View File

@ -12,6 +12,8 @@ import java.nio.charset.Charset;
import java.util.LinkedList;
import java.util.List;
import net.sourceforge.plantuml.error.PSystemError;
import org.assertj.core.api.AutoCloseableSoftAssertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@ -29,6 +31,8 @@ class PipeTest {
@BeforeEach
void setup() {
PSystemError.disableTimeBasedErrorDecorations();
errorStatus = ErrorStatus.init();
baos = new ByteArrayOutputStream();