Package org.apache.lucene.tests.util
Class TestRuleLimitSysouts
java.lang.Object
com.carrotsearch.randomizedtesting.rules.TestRuleAdapter
org.apache.lucene.tests.util.TestRuleLimitSysouts
- All Implemented Interfaces:
org.junit.rules.TestRule
public class TestRuleLimitSysouts
extends com.carrotsearch.randomizedtesting.rules.TestRuleAdapter
This test rule serves two purposes:
- it fails the test if it prints too much to stdout and stderr (tests that chatter too much are discouraged)
- the rule ensures an absolute hard limit of stuff written to stdout and stderr to prevent accidental infinite loops from filling all available disk space with persisted output.
isEnforced()
).-
Nested Class Summary
Modifier and TypeClassDescriptionstatic @interface
An annotation specifying the limit of bytes per class. -
Field Summary
Modifier and TypeFieldDescriptionstatic final long
Max hard limit of sysout bytes.static final long
Max limit of bytes printed to eitherSystem.out
orSystem.err
.static final int
Maximum limit allowed forTestRuleLimitSysouts.Limit.bytes()
before sysout check suppression is suggested. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
afterAlways
(List<Throwable> errors) protected void
We're only interested in failing the suite if it was successful (otherwise just propagate the original problem and don't bother doing anything else).protected void
before()
static void
EnsuresSystem.out
andSystem.err
point to delegate streams.protected boolean
Methods inherited from class com.carrotsearch.randomizedtesting.rules.TestRuleAdapter
apply
-
Field Details
-
DEFAULT_LIMIT
public static final long DEFAULT_LIMITMax limit of bytes printed to eitherSystem.out
orSystem.err
. This limit is enforced per-class (suite).- See Also:
-
DEFAULT_HARD_LIMIT
public static final long DEFAULT_HARD_LIMITMax hard limit of sysout bytes.- See Also:
-
MAX_LIMIT
public static final int MAX_LIMITMaximum limit allowed forTestRuleLimitSysouts.Limit.bytes()
before sysout check suppression is suggested.- See Also:
-
-
Constructor Details
-
TestRuleLimitSysouts
-
-
Method Details
-
before
- Overrides:
before
in classcom.carrotsearch.randomizedtesting.rules.TestRuleAdapter
- Throws:
Throwable
-
checkCaptureStreams
public static void checkCaptureStreams()EnsuresSystem.out
andSystem.err
point to delegate streams. -
isEnforced
protected boolean isEnforced() -
afterIfSuccessful
We're only interested in failing the suite if it was successful (otherwise just propagate the original problem and don't bother doing anything else).- Overrides:
afterIfSuccessful
in classcom.carrotsearch.randomizedtesting.rules.TestRuleAdapter
- Throws:
Throwable
-
afterAlways
- Overrides:
afterAlways
in classcom.carrotsearch.randomizedtesting.rules.TestRuleAdapter
- Throws:
Throwable
-