pkg-config/check/common
Dan Nicholson 397d414a6a check: Pass args to test function instead of setting in variable
The run_test shell function was running pkg-config with arguments stored
in an environment variable. This has problems when trying to pass shell
special characters with the proper escaping. Instead, pass the arguments
to the test where they can maintain correct formatting through use of
the special variable "$@".
2012-09-29 08:50:57 -07:00

33 lines
701 B
Bash

# -*- sh -*-
#
# This file is sourced by the different test scripts. It needs to be
# valid POSIX sh.
#
pkgconfig=${PKG_CONFIG-../pkg-config}
. ./config.sh
unset PKG_CONFIG_PATH
PKG_CONFIG_LIBDIR=$srcdir
export PKG_CONFIG_LIBDIR
export LC_ALL=C
run_test () {
set +e
${pkgconfig} "$@" >/dev/null 2>&1
R=$?
if [ "$R" -ne "${EXPECT_RETURN:-0}" ]; then
${pkgconfig} --print-errors "$@"
echo "${pkgconfig} $@ exited with $R (expected ${EXPECT_RETURN:-0})" 1>&2
exit 1
fi
R=$(${pkgconfig} "$@" 2>&1 | sed -e 's,^[[:space:]]*,,' -e 's,[[:space:]]*$,,')
if [ "$R" != "$RESULT" ]; then
echo "${pkgconfig} $@ :"
echo "'$R' != '$RESULT'"
exit 1
fi
return
}