Class ExternalProcess

  • All Implemented Interfaces:
    TCProcess

    public class ExternalProcess
    extends java.lang.Object
    implements TCProcess
    Launches external commands.
    • Constructor Summary

      Constructors 
      Constructor Description
      ExternalProcess​(java.nio.file.Path cwd, java.lang.String commandLine, int timeLimit, java.io.File stdInFile, java.lang.String description)
      Create a external process runner.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean crashed()
      Did the prior execution exit with a non-zero status code?
      void execute()
      Runs the external command.
      void execute​(boolean quiet)
      Runs the external command.
      java.lang.String getErr()
      Return the captured error stream.
      boolean getOnTime()  
      java.lang.String getOutput()
      Return the captured output.
      int getStatusCode()  
      int getTime()
      Time in seconds of execution.
      boolean timedOut()
      Did the prior execution go too long?
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ExternalProcess

        public ExternalProcess​(java.nio.file.Path cwd,
                               java.lang.String commandLine,
                               int timeLimit,
                               java.io.File stdInFile,
                               java.lang.String description)
        Create a external process runner.
        Parameters:
        cwd - working directory in which to run the process
        commandLine - the command to run
        timeLimit - max time in seconds to allow this to run
        stdInFile - file to supply as standard input. Null if no input is desired.
        description - description of the process (used only in error messages and log entries). If "", uses commandLine.
    • Method Detail

      • execute

        public void execute​(boolean quiet)
        Runs the external command. Standard out and standard err are captured and available as getOutput() and getErr(). The status code is also available.
        Specified by:
        execute in interface TCProcess
        Parameters:
        quiet - do not log failures to run program
      • execute

        public void execute()
        Runs the external command. Equivalent to execute(false);
        Specified by:
        execute in interface TCProcess
      • getOutput

        public java.lang.String getOutput()
        Return the captured output.
        Specified by:
        getOutput in interface TCProcess
        Returns:
        captured std out
      • getErr

        public java.lang.String getErr()
        Return the captured error stream.
        Specified by:
        getErr in interface TCProcess
        Returns:
        captured std err
      • getTime

        public int getTime()
        Time in seconds of execution.
        Specified by:
        getTime in interface TCProcess
        Returns:
        time
      • timedOut

        public boolean timedOut()
        Did the prior execution go too long?
        Specified by:
        timedOut in interface TCProcess
        Returns:
        true iff execution was killed after exceeding time limit
      • crashed

        public boolean crashed()
        Did the prior execution exit with a non-zero status code?
        Specified by:
        crashed in interface TCProcess
        Returns:
        true iff prior execution failed/crashed
      • getOnTime

        public boolean getOnTime()
        Specified by:
        getOnTime in interface TCProcess
        Returns:
        true iff last test execution finished in an acceptable time.
      • getStatusCode

        public int getStatusCode()
        Specified by:
        getStatusCode in interface TCProcess
        Returns:
        status code of last execution (usually 0 if successful)