๐ test
โก test::exec
Call this function to execute a command and write the command and its output to the report file.
The command can fail, in which case the returned exit code is written to the report file.
However, the command must not call exit
(in which case, use test::exit).
Inputs:
$@
: command as string:The command to execute.
Example usage:
test::exec echo "Hello, world!"
โก test::exit
Call this function to execute a command that can call exit
and write the command and its output to the report file.
The command is executed in a subshell to catch the exit.
Inputs:
$@
: command as string:The command to execute.
Example usage:
test::exit exit 3
โก test::fail
Call this function to log a message and exit with the status 142, which indicates to the self test command that the test failed and that we know the reason (it is a bad implementation of the test itself).
Inputs:
$@
: message as string:The message to log.
Example usage:
test::fail "This is a failure message with a clear reason."
โก test::flush
Call this function to flush the standard and error outputs to the report file. They will be added as code blocks in the report file (one for the standard output, one for the standard error).
Example usage:
test::flush
โก test::flushStderr
Call this function to flush the standard error to the report file. It will be added as a code block in the report file.
Inputs:
${blockTitle}
as string:(optional) Add a ’title’ to the code block (
**title**:
before the code block).(defaults to “”)
Example usage:
test::flushStderr
โก test::flushStdout
Call this function to flush the standard output to the report file. It will be added as a code block in the report file.
Inputs:
${blockTitle}
as string:(optional) Add a ’title’ to the code block (
**title**:
before the code block).(defaults to “”)
Example usage:
test::flushStdout
โก test::func
Call this function to test a function that returns a value using the valet conventions (REPLY, REPLY2, REPLY_ARRAY, etc…).
It will write the command and its output to the report file. It will also print the REPLY values.
Inputs:
$@
: command as string:The command to execute (function and its arguments).
Example usage:
test::func myFunction
โก test::log
Call this function to log a message during a test. This log will only show in case of a script error or when the debug log level is enabled when running the tests.
Inputs:
$@
: messages as string:The messages to log.
Example usage:
test::log "This is a log message."
โก test::markdown
Call this function to add some markdown in the report file.
Inputs:
$@
: markdown as string:The markdown to add in the report file.
Example usage:
test::markdown "> This is a **quote**."
โก test::printReplyVars
This function can be called to print the REPLY values, e.g. REPLY, REPLY2, REPLY_ARRAY… They will each be printed in a code block in the report file.
Example usage:
test::printReplyVars
โก test::printVars
This function can be called to print the global variables in the report file. They will printed in a code block in the report file.
Inputs:
$@
: variables as string:The variables to print.
Example usage:
test::printVars myVar
โก test::prompt
Call this function to print a ‘prompt’ (markdown that looks like a prompt) in the report file.
Inputs:
$@
: command as string:The command to print as a prompt.
Example usage:
test::prompt "echo 'Hello, world!'"
โก test::resetReplyVars
Resets the value of each REPLY variable.
Example usage:
test::resetReplyVars
โก test::scrubOutput
This function can be defined to modify the flushed text (both stdout and stderr) before adding it to the report.
Scrubbers are required when we need to convert non-deterministic text to something stable so that tests are reproducible.
The text to transform is in the global variable GLOBAL_TEST_OUTPUT_CONTENT
.
You can also use GLOBAL_TEST_FD_NUMBER
to know which file descriptor is being flushed (1 for stdout, 2 for stderr).
Returns:
GLOBAL_TEST_OUTPUT_CONTENT
: The modified text.
You can define this function directly in the test script, or in a test hook if you need it to be available for multiple tests. Note however that this function can be called very often, so it should be optimized.
โก test::scrubReplyVars
This function can be defined to modify the REPLY variables before printing them in the report.
Scrubbers are required when we need to convert non-deterministic text to something stable so that tests are reproducible.
You can define this function directly in the test script, or in a test hook if you need it to be available for multiple tests. Note however that this function can be called very often, so it should be optimized.
โก test::setTerminalInputs
Replaces the functions terminal::waitForChar
and terminal::waitForKeyPress
by custom functions
that return keys defined as an input of this function.
Inputs:
$@
: keys as string:The keys to return when
terminal::waitForChar
orterminal::waitForKeyPress
are called. Keys are consumed in the order they are provided.
Example usage:
test::setTerminalInputs "a" "b" "c"
โก test::setupBashForConsistency
This function is used to set up the Bash environment for maximum consistency during testing. It will override important dynamic bash variables to have more static results.
Example usage:
test::setupBashForConsistency
โก test::title
Call this function to add an H3 title in the report file.
Inputs:
$1
: title as string:The title of the test.
Example usage:
test::title "Testing something"
Important
Documentation generated for the version 0.33.0 (2025-08-31).