The command.ExecTest
test class runs a
program from an ordinary executable file. Each test specifies the
program executable to run, its full command line, and the data to
feed to its standard input stream. ExecTest
collects the complete text of the program's standard output and
standard error streams and the program's exit code, and compares
these to expected values specified in the test. If the standard
output and error text and the exit code match the expected values,
the test passes.
A command.ExecTest
test supplies the
following arguments:
The name of the executable file to run.
command.ExecTest
attempts to locate the
program executable in the path specified by the
path property of the test context.
The argument list for the program. The elements of this
set are sequential items from which the program's argument list
is constructed. command.ExecTest
automatically prepends an implicit zeroth element, the full path
of the program.
Text or data to pass to the program's standard input stream. This data is written to a temporary file, and the contents of the file are directed to the program's standard input stream.
The environment (i.e. the set of environment variables)
available to the executing program. Each element of this
argument is a string of the form
"VARIABLE
=VALUE
".
command.ExecTest
adds additional
environment variables automatically.
In addition, every context property whose value is a string
is accessible as an environment variable; the name of the
environment variable is the name of the context property,
prefixed with "QMV_
" and with any dots
(".") replaced by a double underscore
("__"). For example, the value of the context property
"CompilerTable.c_path" is available as the value of the
environment variable
"QMV_CompilerTable__c_path
".
The exit code value expected from the program. If the program produces an exit code value different from this one, the test fails.
The text or data which the program is expected to produce
on its standard output stream. The actual text or data written
to standard output is captured, and
command.ExecTest
performs a bytewise
comparison to the expected text or data. If they do not match,
the test fails.
The text or data which the program is expected to produce
on its standard error stream. The actual text or data written to
standard error is captured, and
command.ExecTest
performs a bytewise
comparison to the expected text or data. If they do not match,
the test fails.
command.ShellCommandTest
is very
similar to command.ExecTest
, except that it
runs a program via the shell rather than directly. Instead of
specifying an executable to run and the elements of its argument
list, a test provides a single command line. The shell is
responsible for finding the executable and constructing its
argument list.
Standard input and the environment are specified in the test. The test passes if the command produces the expected standard output, standard error, and exit code.
Note that most shells create local shell variables to mirror
the contents of the environment when the shell starts up.
Therefore, the environment set up by a
command.ShellCommandTest
, including the contents
of the test context, are directly accessible via shell variables.
The syntax to use depends on the particular shell.
command.ShellCommandTest
has the same fields
as command.ExecTest
, except that the
Program and Argument List
properties are replaced with these:
The command to run. The command is delivered verbatim to the shell. The shell interprets the command according to its own quoting rules and syntax.
command.ShellScriptTest
is an extension of
command.CommandTest
that lets a test specify
an entire shell script instead of a single command. The script
specified in the test is written to a temporary file, and this file
is interpreted by the specified shell or command interpreter
program.
Standard input, the environment, and the argument list to pass to the script are specified in the test. The test passes if the script produces the expected standard output, standard error, and exit code.
Note that most shells create local shell variables to mirror
the contents of the environment when the shell starts up.
Therefore, the environment set up by a
command.ShellScriptTest
, including the contents of
the test context, are directly accessible via shell variables. The
syntax to use depends on the particular shell.
command.ShellScriptTest
has the same fields
as command.ExecTest
, except that the
Program property is replaced with:
The text of the script to run.
compilation_test.CompilationTest
compiles
a set of source files and optionally runs the compiled executable.
The compiler executable's name, as well as global compilation parameters are queried from these context variables:
The name of the compiler executable.
Compiler options.
Linker options.
The CompilationTest
takes the following parameters.
Test-specific options to pass to the compiler.
Test-specific linker flags to pass to the compiler.
Source files to be compiled..
The name of the executable to be compiled.
Whether or not to run the compiled executable.