Table of Contents
The pkgsrc infrastructure consists of a large codebase, and there are many corners where every little bit of a file is well thought out, making pkgsrc likely to fail as soon as anything is changed near those parts. To prevent most changes from breaking anything, a suite of regression tests should go along with every important part of the pkgsrc infrastructure. This chapter describes how regression tests work in pkgsrc and how you can add new tests.
You first need to install the
pkgtools/pkg_regress package, which
provides the pkg_regress command. Then you
can simply run that command, which will run all tests in the
Every directory in the
category that contains a file called
is considered a regression test. This file is a shell program
that is included by the pkg_regress command.
The following functions can be overridden to suit your
These functions do not take any parameters. They are all called in “set -e” mode, so you should be careful to check the exitcodes of any commands you run in the test.
This function prepares the environment for the test. By default it does nothing.
This function runs the actual test. By default,
TEST_MAKE with the arguments
MAKEARGS_TEST and writes its output including
error messages into the file
This function is run after the test and is typically used to compare the actual output from the one that is expected. It can make use of the various helper functions from the next section.
This function cleans everything up after the test has been run. By default it does nothing.
This function compares the exitcode of the do_test() function with its first parameter. If they differ, the test will fail.
This function checks for each of its parameters if the output from do_test() matches the extended regular expression. If it does not, the test will fail.
This function checks for each of its parameters if the output from do_test() does not match the extended regular expression. If any of the regular expressions matches, the test will fail.