#!/bin/bash . ../init.sh || exit 1 set -e export ROOT=${as}/root export Q_VDB=/ mktmpdir test() { local num=$1 exp=$2 ret local cmd=( qdepends "${@:3}" ) "${cmd[@]}" >& list && ret=0 || ret=$? if [[ ${ret} -ne ${exp} ]] ; then tend 1 "exit code: wanted ${exp} but got ${ret}: ${cmd[*]}" elif [[ ${exp} -ne 0 ]] ; then # for errors, let the message be anything return fi # qdepends output is based on a hash, which may differ based on # endiannes, so sort the output so we get a deterministic set while IFS= read -r line ; do case "${line}" in *:*) pkg=${line%%:*} line=${line#*:} echo "${pkg}: $(echo "${line}" | tr ' ' '\n' | LC_ALL=C sort | xargs)" ;; *) echo "${line}" ;; esac done < list | diff list - | patch -s list local good="${as}/list${num}.good" if [[ ! -e ${good} ]] ; then cp list "${good}" fi diff -u list "${good}" tend $? "${num} ${cmd[*]}" } testf() { test "$1" "${3:-0}" -S "$2"; } # basic sanity checks testf 00 '|' 1 testf 01 '' testf 02 'a/b' testf 03 'foo? ( a/b )' testf 04 '|| ( a/b )' # a bit more complicated with or deps testf 05 '|| ( || ( || ( x ) a ) )' # hande use deps on atoms #470180 testf 06 'a[foo(+)]' testQ() { test "$1" "${3:-0}" -Q "$2"; } # reverse checks #504636 testQ 07 xinit testq() { test "$1" "${3:-0}" -q "$2"; } # forward checks #504636 testq 08 xdm cleantmpdir end