Class SlaveMain

java.lang.Object
com.carrotsearch.ant.tasks.junit4.slave.SlaveMain

public class SlaveMain extends Object
A slave process running the actual tests on the target JVM.
  • Field Details

    • ERR_EXCEPTION

      public static final int ERR_EXCEPTION
      Runtime exception.
      See Also:
    • ERR_NO_JUNIT

      public static final int ERR_NO_JUNIT
      No JUnit on classpath.
      See Also:
    • ERR_OLD_JUNIT

      public static final int ERR_OLD_JUNIT
      Old JUnit on classpath.
      See Also:
    • ERR_OOM

      public static final int ERR_OOM
      OOM
      See Also:
    • lastResortMemory

      static volatile 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 Class<OutOfMemoryError> oomClass
      Preallocate and load in advance.
    • OPTION_FREQUENT_FLUSH

      public static final String OPTION_FREQUENT_FLUSH
      Frequent event strean flushing.
      See Also:
    • OPTION_SYSOUTS

      public static final String OPTION_SYSOUTS
      Multiplex sysout and syserr to original streams (aside from pumping them to event stream).
      See Also:
    • OPTION_STDIN

      public static final String OPTION_STDIN
      Read class names from standard input.
      See Also:
    • OPTION_EVENTSFILE

      public static final 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:
    • OPTION_DEBUGSTREAM

      public static final String 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

      public static final 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 String SYSPROP_FORKEDJVM_DELAY_MS
      Delay the initial bootstrap event from the forked JVM (used in tests).
      See Also:
    • serializer

      private final Serializer serializer
      Event sink.
    • warnings

      private static PrintStream warnings
      A sink for warnings (non-event stream).
    • flushFrequently

      private boolean flushFrequently
      Flush serialization stream frequently.
    • debugMessagesFile

      private 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 Details

    • SlaveMain

      public SlaveMain(Serializer serializer)
      Creates a slave emitting events to the given serializer.
  • Method Details

    • execute

      private void execute(Iterator<String> classNames) throws Throwable
      Execute tests.
      Throws:
      Throwable
    • debug

      private void debug(Writer w, String msg) throws IOException
      Throws:
      IOException
    • instantiate

      private Class<?> instantiate(String className)
      Instantiate test classes (or try to).
    • main

      public static void main(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 String[] readArgsFile(String argsFile) throws IOException
      Read arguments from a file. Newline delimited, UTF-8 encoded. No fanciness to avoid dependencies.
      Throws:
      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(String message, Throwable t)
      Warning emitter. Uses whatever alternative non-event communication channel is.