30.3 Running test functions

Function: dotest-final-report

This function must be invoked as last command in the test file to report errors and correctly exit the test script, in a way compatible with the requirements of GNU Automake, See Scripts-based Testsuites.

Function: dotest PATTERN

Run all the functions matching PATTERN. Usually PATTERN is the first part of the name of the functions to be executed; the function names are selected with the following code:

compgen -A function PATTERN

There’s no constraint on function names, but they must be one–word names.

Before running a test function: the current process working directory is saved, and it is restored after the execution is terminated.

The return value of the test functions is used as result of the test: true, the test succeeded; false, the test failed. Remembering that the return value of a function is the return value of its last executed command, the functions dotest-equal() and dotest-output(), and of course the Bash built–in test, might be used to return the correct value.

Messages are printed before and after the execution of each function, according to the mode selected with: dotest-set-report-success(), dotest-set-report-start(), … Configuring the package

The following environment variables will influence the behaviour of dotest().

Variable: TESTMATCH

Restrict the PATTERN argument to dotest(). First function names are matched against PATTERN, then, the ones that match, are matched against TESTMATCH.

Variable: TESTSTART

If yes: It is equivalent to invoking dotest-set-report-start(). If no: It is equivalent to invoking dotest-unset-report-start().

Variable: TESTSUCCESS

If yes: It is equivalent to invoking dotest-set-report-success(). If no: It is equivalent to invoking dotest-unset-report-success().


This document describes version 3.0.0-devel.9 of Marcos Bash Functions Library.