xbps-src: implement a 'check' stage

Add another stage 'check' between 'build' and 'install'. It is be enabled using the
variable XBPS_CHECK_PKGS=yes and disabled if unset, set to "0" or "no" in your
local etc/conf.

A new xbps-src option `-q` for `quick` will disable XBPS_CHECK_PKGS by overriding it to 0.
If enabled, `common/xbps-src/shutils/xbps-src-docheck.sh` checks for an existing
`do_check()` function in the package's template and, if it exists, calls it.

A new template variable `checkdepends` may be present and list packages required
to run the `do_check()` function. Example: `checkdepends="bc unittest-cpp"`.
This commit is contained in:
Jürgen Buchmüller 2017-02-23 22:03:31 +01:00
parent f9dface61c
commit c31dd888f6
14 changed files with 156 additions and 13 deletions

View file

@ -30,6 +30,9 @@ bootstrap-update
build <pkgname>
Build package source (fetch + extract + configure + build).
check <pkgname>
Run the package check(s) after building the package source.
consistency-check
Runs a consistency check on all packages
@ -412,7 +415,7 @@ readonly XBPS_GCC_VERSION=${XBPS_GCC_VERSION_MAJOR}.${XBPS_GCC_VERSION_MINOR}.${
# main()
#
XBPS_OPTIONS=
XBPS_OPTSTRING="a:CEfgGhH:Ij:Lm:No:r:tV"
XBPS_OPTSTRING="a:CEfgGhH:Ij:Lm:No:qr:tV"
# Preprocess arguments in order to allow options before and after XBPS_TARGET.
eval set -- $(getopt -- "$XBPS_OPTSTRING" "$@");
@ -433,6 +436,7 @@ while getopts "$XBPS_OPTSTRING" opt; do
m) readonly XBPS_MASTERDIR=$(readlink -m $OPTARG 2>/dev/null); XBPS_OPTIONS+=" -m $XBPS_MASTERDIR";;
N) readonly XBPS_SKIP_REMOTEREPOS=1; XBPS_OPTIONS+=" -N";;
o) readonly XBPS_PKG_OPTIONS="$OPTARG"; XBPS_OPTIONS+=" -o $OPTARG";;
q) export XBPS_CHECK_PKGS=0; XBPS_OPTIONS+=" -q";;
r) readonly XBPS_ALT_REPOSITORY="$OPTARG"; XBPS_OPTIONS+=" -r $OPTARG";;
t) export XBPS_TEMP_MASTERDIR=1; XBPS_OPTIONS+=" -t -C";;
V) echo $XBPS_SRC_VERSION && exit 0;;
@ -569,7 +573,7 @@ export XBPS_SHUTILSDIR XBPS_CROSSPFDIR XBPS_TRIGGERSDIR \
XBPS_CMPVER_CMD XBPS_FETCH_CMD XBPS_VERSION XBPS_APIVER \
XBPS_BUILDSTYLEDIR XBPS_CPPFLAGS XBPS_CFLAGS XBPS_CXXFLAGS XBPS_LDFLAGS \
XBPS_MAKEJOBS XBPS_BUILD_FORCEMODE XBPS_USE_GIT_REVS XBPS_DEBUG_PKGS \
XBPS_CCACHE XBPS_DISTCC XBPS_DISTCC_HOSTS XBPS_SKIP_DEPS \
XBPS_CHECK_PKGS XBPS_CCACHE XBPS_DISTCC XBPS_DISTCC_HOSTS XBPS_SKIP_DEPS \
XBPS_SKIP_REMOTEREPOS XBPS_CROSS_BUILD XBPS_PKG_OPTIONS XBPS_CONFIG_FILE \
XBPS_KEEP_ALL XBPS_HOSTDIR XBPS_MASTERDIR XBPS_SRC_VERSION \
XBPS_DESTDIR XBPS_MACHINE XBPS_TEMP_MASTERDIR XBPS_BINPKG_EXISTS \
@ -697,7 +701,7 @@ case "$XBPS_TARGET" in
remove_pkg_autodeps
fi
;;
fetch|extract|build|configure|install|pkg)
fetch|extract|build|check|configure|install|pkg)
read_pkg
if [ -n "$CHROOT_READY" -a -z "$IN_CHROOT" ]; then
chroot_handler $XBPS_TARGET $XBPS_TARGET_PKG