public class ProcessCommand extends Command
Constructor and Description |
---|
ProcessCommand() |
Modifier and Type | Method and Description |
---|---|
Status |
exec(java.lang.String[] cmd,
java.lang.String[] cmdEnv,
java.io.PrintWriter log,
java.io.PrintWriter ref)
Execute a command, bypassing the standard argument decoding of 'run'.
|
java.io.File |
getExecDir()
Get the directory in which to execute the process,
or null if none set.
|
protected Status |
getStatus(int exitCode,
Status logStatus)
Generate a status for the command, based upon the command's exit code
and a status that may have been passed from the command by using
status.exit() . |
static void |
main(java.lang.String[] args)
A stand-alone entry point for this command.
|
Status |
run(java.lang.String[] args,
java.io.PrintWriter log,
java.io.PrintWriter ref)
Run the given command.
|
void |
setDefaultStatus(Status status)
Set the default status to be returned for all exit codes.
|
void |
setExecDir(java.io.File dir)
Set the directory in which to execute the process.
|
void |
setStatusForExit(int exitCode,
Status status)
Set a status to be returned for a specific exit code, overwriting any
previous setting for this exit code.
|
getClassLoader, setClassLoader
public static void main(java.lang.String[] args)
run
method invoked,
passing in the command line args and System.out
and
System.err
as the two streams.args
- command line arguments for this command.run(java.lang.String[], java.io.PrintWriter, java.io.PrintWriter)
public void setStatusForExit(int exitCode, Status status)
exitCode
- The process exit code for which to assign a status.status
- The status to associate with the exit code.public void setDefaultStatus(Status status)
status
- The default status to use when a specific status
has not been set for a particular process exit code.public void setExecDir(java.io.File dir)
dir
- the directory in which to execute the process.getExecDir()
public java.io.File getExecDir()
setExecDir(java.io.File)
public Status run(java.lang.String[] args, java.io.PrintWriter log, java.io.PrintWriter ref)
run
in class Command
args
- An array of strings composed of
command-options,
environment-variables,
command,
command-arguments.
=
VALUE.
log
- A stream for logging output.ref
- A stream for reference output, if the test requires it.
If not, it can be used as an additional logging stream.getStatus
after the command completes.
The default behaviour is to use the explicit or default
status given in the arguments, or via the API. If none
have been set up, then the following values are used:
Status.passed("exit code 0")
if the command exited with exit status 0, or
Status.failed("exit code " + exitCode)
otherwise. getStatus
may be overridden
to provide different behavior.getStatus(int, com.sun.javatest.Status)
public Status exec(java.lang.String[] cmd, java.lang.String[] cmdEnv, java.io.PrintWriter log, java.io.PrintWriter ref)
cmd
- The command to be executedcmdEnv
- The environment to be passed to the commandlog
- A stream for logging output.ref
- A stream for reference output, if the test requires it.
If not, it can be used as an additional logging stream.getStatus
after the command completes.run(java.lang.String[], java.io.PrintWriter, java.io.PrintWriter)
,
getStatus(int, com.sun.javatest.Status)
protected Status getStatus(int exitCode, Status logStatus)
status.exit()
.exitCode
- The exit code from the command that was executed.logStatus
- If the command that was executed was a test program
and exited by calling status.exit()
,
then logStatus will be set to `status'. Otherwise,
it will be null. The value of the status is passed
from the command by writing it as the last line to
stdout before exiting the process. If it is not
received as the last line, the value will be lost.Status.passed("exit code 0")
if the command exited with exit code 0, or
Status.failed("exit code " + exitCode)
otherwise.Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.