Class SlaveMain
- java.lang.Object
-
- com.carrotsearch.ant.tasks.junit4.slave.SlaveMain
-
public class SlaveMain extends java.lang.ObjectA slave process running the actual tests on the target JVM.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classSlaveMain.ChunkedStreamBase for redirected streams.
-
Field Summary
Fields Modifier and Type Field Description private java.io.FiledebugMessagesFileDebug stream to flush progress information to.static intERR_EXCEPTIONRuntime exception.static intERR_NO_JUNITNo JUnit on classpath.static intERR_OLD_JUNITOld JUnit on classpath.static intERR_OOMOOMprivate booleanflushFrequentlyFlush serialization stream frequently.(package private) static java.lang.ObjectlastResortMemoryLast resort memory pool released under low memory conditions.private static booleanmultiplexStdStreamsMultiplex calls to System streams to both event stream and the original streams?(package private) static java.lang.Class<java.lang.OutOfMemoryError>oomClassPreallocate and load in advance.static java.lang.StringOPTION_DEBUGSTREAMShould the debug stream from the runner be created? It's named after the events file with.debugsuffix.static java.lang.StringOPTION_EVENTSFILEName the sink for events.static java.lang.StringOPTION_FREQUENT_FLUSHFrequent event strean flushing.static java.lang.StringOPTION_STDINRead class names from standard input.static java.lang.StringOPTION_SYSOUTSMultiplex sysout and syserr to original streams (aside from pumping them to event stream).private SerializerserializerEvent sink.static java.lang.StringSYSPROP_FIRERUNNERFAILUREFire a runner failure after startup to verify messages are propagated properly.static java.lang.StringSYSPROP_FORKEDJVM_DELAY_MSDelay the initial bootstrap event from the forked JVM (used in tests).private static java.io.PrintStreamwarningsA sink for warnings (non-event stream).
-
Constructor Summary
Constructors Constructor Description SlaveMain(Serializer serializer)Creates a slave emitting events to the given serializer.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private voiddebug(java.io.Writer w, java.lang.String msg)private voidexecute(java.util.Iterator<java.lang.String> classNames)Execute tests.private java.lang.Class<?>instantiate(java.lang.String className)Instantiate test classes (or try to).static voidmain(java.lang.String[] allArgs)Console entry point.private static java.lang.String[]readArgsFile(java.lang.String argsFile)Read arguments from a file.private static voidredirectStreams(Serializer serializer, boolean flushFrequently)Redirect standard streams so that the output can be passed to listeners.private static voidtryWaitingForGC()Try waiting for a GC to happen.static voidwarn(java.lang.String message, java.lang.Throwable t)Warning emitter.
-
-
-
Field Detail
-
ERR_EXCEPTION
public static final int ERR_EXCEPTION
Runtime exception.- See Also:
- Constant Field Values
-
ERR_NO_JUNIT
public static final int ERR_NO_JUNIT
No JUnit on classpath.- See Also:
- Constant Field Values
-
ERR_OLD_JUNIT
public static final int ERR_OLD_JUNIT
Old JUnit on classpath.- See Also:
- Constant Field Values
-
ERR_OOM
public static final int ERR_OOM
OOM- See Also:
- Constant Field Values
-
lastResortMemory
static volatile java.lang.Object lastResortMemory
Last resort memory pool released under low memory conditions. This is not a solution, it's a terrible hack. I know this. Everyone knows this. Even monkeys in Madagaskar know this. If you know a better solution, patches welcome.Approximately 5mb is reserved. Really, smaller values don't make any difference and the JVM fails to even return the status passed to Runtime.halt().
-
oomClass
static java.lang.Class<java.lang.OutOfMemoryError> oomClass
Preallocate and load in advance.
-
OPTION_FREQUENT_FLUSH
public static final java.lang.String OPTION_FREQUENT_FLUSH
Frequent event strean flushing.- See Also:
- Constant Field Values
-
OPTION_SYSOUTS
public static final java.lang.String OPTION_SYSOUTS
Multiplex sysout and syserr to original streams (aside from pumping them to event stream).- See Also:
- Constant Field Values
-
OPTION_STDIN
public static final java.lang.String OPTION_STDIN
Read class names from standard input.- See Also:
- Constant Field Values
-
OPTION_EVENTSFILE
public static final java.lang.String OPTION_EVENTSFILE
Name the sink for events. If given, accepts one argument - name of a file to which events should be dumped. The file has to be initially empty!- See Also:
- Constant Field Values
-
OPTION_DEBUGSTREAM
public static final java.lang.String OPTION_DEBUGSTREAM
Should the debug stream from the runner be created? It's named after the events file with.debugsuffix.- See Also:
- Constant Field Values
-
SYSPROP_FIRERUNNERFAILURE
public static final java.lang.String SYSPROP_FIRERUNNERFAILURE
Fire a runner failure after startup to verify messages are propagated properly. Not really useful in practice...
-
SYSPROP_FORKEDJVM_DELAY_MS
public static final java.lang.String SYSPROP_FORKEDJVM_DELAY_MS
Delay the initial bootstrap event from the forked JVM (used in tests).- See Also:
- Constant Field Values
-
serializer
private final Serializer serializer
Event sink.
-
warnings
private static java.io.PrintStream warnings
A sink for warnings (non-event stream).
-
flushFrequently
private boolean flushFrequently
Flush serialization stream frequently.
-
debugMessagesFile
private java.io.File debugMessagesFile
Debug stream to flush progress information to.
-
multiplexStdStreams
private static boolean multiplexStdStreams
Multiplex calls to System streams to both event stream and the original streams?
-
-
Constructor Detail
-
SlaveMain
public SlaveMain(Serializer serializer)
Creates a slave emitting events to the given serializer.
-
-
Method Detail
-
execute
private void execute(java.util.Iterator<java.lang.String> classNames) throws java.lang.ThrowableExecute tests.- Throws:
java.lang.Throwable
-
debug
private void debug(java.io.Writer w, java.lang.String msg) throws java.io.IOException- Throws:
java.io.IOException
-
instantiate
private java.lang.Class<?> instantiate(java.lang.String className)
Instantiate test classes (or try to).
-
main
public static void main(java.lang.String[] allArgs)
Console entry point.
-
tryWaitingForGC
private static void tryWaitingForGC()
Try waiting for a GC to happen. This is a dirty heuristic but if we're here we're neck deep in sh*t anyway (OOMs all over).
-
readArgsFile
private static java.lang.String[] readArgsFile(java.lang.String argsFile) throws java.io.IOExceptionRead arguments from a file. Newline delimited, UTF-8 encoded. No fanciness to avoid dependencies.- Throws:
java.io.IOException
-
redirectStreams
private static void redirectStreams(Serializer serializer, boolean flushFrequently)
Redirect standard streams so that the output can be passed to listeners.
-
warn
public static void warn(java.lang.String message, java.lang.Throwable t)Warning emitter. Uses whatever alternative non-event communication channel is.
-
-