Class SlaveMain
java.lang.Object
com.carrotsearch.ant.tasks.junit4.slave.SlaveMain
A slave process running the actual tests on the target JVM.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
Base for redirected streams. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate File
Debug stream to flush progress information to.static final int
Runtime exception.static final int
No JUnit on classpath.static final int
Old JUnit on classpath.static final int
OOMprivate boolean
Flush serialization stream frequently.(package private) static Object
Last resort memory pool released under low memory conditions.private static boolean
Multiplex calls to System streams to both event stream and the original streams?(package private) static Class
<OutOfMemoryError> Preallocate and load in advance.static final String
Should the debug stream from the runner be created? It's named after the events file with.debug
suffix.static final String
Name the sink for events.static final String
Frequent event strean flushing.static final String
Read class names from standard input.static final String
Multiplex sysout and syserr to original streams (aside from pumping them to event stream).private final Serializer
Event sink.static final String
Fire a runner failure after startup to verify messages are propagated properly.static final String
Delay the initial bootstrap event from the forked JVM (used in tests).private static PrintStream
A sink for warnings (non-event stream). -
Constructor Summary
ConstructorsConstructorDescriptionSlaveMain
(Serializer serializer) Creates a slave emitting events to the given serializer. -
Method Summary
Modifier and TypeMethodDescriptionprivate void
private void
Execute tests.private Class
<?> instantiate
(String className) Instantiate test classes (or try to).static void
Console entry point.private static String[]
readArgsFile
(String argsFile) Read arguments from a file.private static void
redirectStreams
(Serializer serializer, boolean flushFrequently) Redirect standard streams so that the output can be passed to listeners.private static void
Try waiting for a GC to happen.static void
Warning emitter.
-
Field Details
-
ERR_EXCEPTION
public static final int ERR_EXCEPTIONRuntime exception.- See Also:
-
ERR_NO_JUNIT
public static final int ERR_NO_JUNITNo JUnit on classpath.- See Also:
-
ERR_OLD_JUNIT
public static final int ERR_OLD_JUNITOld JUnit on classpath.- See Also:
-
ERR_OOM
public static final int ERR_OOMOOM- See Also:
-
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
Preallocate and load in advance. -
OPTION_FREQUENT_FLUSH
Frequent event strean flushing.- See Also:
-
OPTION_SYSOUTS
Multiplex sysout and syserr to original streams (aside from pumping them to event stream).- See Also:
-
OPTION_STDIN
Read class names from standard input.- See Also:
-
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:
-
OPTION_DEBUGSTREAM
Should the debug stream from the runner be created? It's named after the events file with.debug
suffix.- See Also:
-
SYSPROP_FIRERUNNERFAILURE
Fire a runner failure after startup to verify messages are propagated properly. Not really useful in practice... -
SYSPROP_FORKEDJVM_DELAY_MS
Delay the initial bootstrap event from the forked JVM (used in tests).- See Also:
-
serializer
Event sink. -
warnings
A sink for warnings (non-event stream). -
flushFrequently
private boolean flushFrequentlyFlush serialization stream frequently. -
debugMessagesFile
Debug stream to flush progress information to. -
multiplexStdStreams
private static boolean multiplexStdStreamsMultiplex calls to System streams to both event stream and the original streams?
-
-
Constructor Details
-
SlaveMain
Creates a slave emitting events to the given serializer.
-
-
Method Details
-
execute
Execute tests.- Throws:
Throwable
-
debug
- Throws:
IOException
-
instantiate
Instantiate test classes (or try to). -
main
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
Read arguments from a file. Newline delimited, UTF-8 encoded. No fanciness to avoid dependencies.- Throws:
IOException
-
redirectStreams
Redirect standard streams so that the output can be passed to listeners. -
warn
Warning emitter. Uses whatever alternative non-event communication channel is.
-