summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Nicholson <dbn.lists@gmail.com>2012-09-29 08:50:57 -0700
committerDan Nicholson <dbn.lists@gmail.com>2012-09-29 08:50:57 -0700
commit397d414a6a6db328c610b0691fd0ce79e081eb99 (patch)
tree79b637095f7146e0dbe9746ceeac1f67a42eb401
parente68baa746395f4d5c7b8ab16093c044026b2d1fd (diff)
downloadpkg-config-397d414a6a6db328c610b0691fd0ce79e081eb99.tar.gz
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 "$@".
-rwxr-xr-xcheck/check-cflags7
-rwxr-xr-xcheck/check-cmd-options12
-rwxr-xr-xcheck/check-conflicts4
-rwxr-xr-xcheck/check-define-variable8
-rwxr-xr-xcheck/check-idirafter4
-rwxr-xr-xcheck/check-includedir4
-rwxr-xr-xcheck/check-libs6
-rwxr-xr-xcheck/check-libs-private4
-rwxr-xr-xcheck/check-missing36
-rwxr-xr-xcheck/check-requires-private14
-rwxr-xr-xcheck/check-version54
-rwxr-xr-xcheck/check-whitespace6
-rw-r--r--check/common10
13 files changed, 56 insertions, 113 deletions
diff --git a/check/check-cflags b/check/check-cflags
index f662687..2f8b5bd 100755
--- a/check/check-cflags
+++ b/check/check-cflags
@@ -4,11 +4,8 @@ set -e
. ${srcdir}/common
-ARGS="--cflags simple"
RESULT=""
-run_test
+run_test --cflags simple
-ARGS="--cflags fields-blank"
RESULT=""
-run_test
-
+run_test --cflags fields-blank
diff --git a/check/check-cmd-options b/check/check-cmd-options
index 8b5ef4c..654021f 100755
--- a/check/check-cmd-options
+++ b/check/check-cmd-options
@@ -7,22 +7,18 @@ set -e
# all of these should fail, but when '=' or ' ' aren't used consistently
# between the two options, broken popt sets the version to compare to be
# "a=b"
-ARGS="--define-variable=a=b --atleast-pkgconfig-version=999.999"
EXPECT_RETURN=1
RESULT=""
-run_test
+run_test --define-variable=a=b --atleast-pkgconfig-version=999.999
-ARGS="--define-variable=a=b --atleast-pkgconfig-version 999.999"
EXPECT_RETURN=1
RESULT=""
-run_test
+run_test --define-variable=a=b --atleast-pkgconfig-version 999.999
-ARGS="--define-variable a=b --atleast-pkgconfig-version 999.999"
EXPECT_RETURN=1
RESULT=""
-run_test
+run_test --define-variable a=b --atleast-pkgconfig-version 999.999
-ARGS="--define-variable a=b --atleast-pkgconfig-version=999.999"
EXPECT_RETURN=1
RESULT=""
-run_test
+run_test --define-variable a=b --atleast-pkgconfig-version=999.999
diff --git a/check/check-conflicts b/check/check-conflicts
index 7f160db..372c2a6 100755
--- a/check/check-conflicts
+++ b/check/check-conflicts
@@ -4,8 +4,6 @@ set -e
. ${srcdir}/common
-ARGS="--libs conflicts-test"
RESULT="-L/public-dep/lib -lpublic-dep"
-
-run_test
+run_test --libs conflicts-test
diff --git a/check/check-define-variable b/check/check-define-variable
index b0aaabd..89bbcc2 100755
--- a/check/check-define-variable
+++ b/check/check-define-variable
@@ -4,15 +4,13 @@ set -e
. ${srcdir}/common
+RESULT="-I/includedir/"
case ${MACHTYPE} in
*-msys)
# Make sure path doesn't get mangled on MSYS
- ARGS="--define-variable=includedir=\\/includedir/ --cflags simple"
+ run_test --define-variable=includedir=\\/includedir/ --cflags simple
;;
*)
- ARGS="--define-variable=includedir=/includedir/ --cflags simple"
+ run_test --define-variable=includedir=/includedir/ --cflags simple
;;
esac
-RESULT="-I/includedir/"
-
-run_test
diff --git a/check/check-idirafter b/check/check-idirafter
index 439d799..a41d11e 100755
--- a/check/check-idirafter
+++ b/check/check-idirafter
@@ -4,7 +4,5 @@ set -e
. ${srcdir}/common
-ARGS="--cflags idirafter"
RESULT="-idirafter -I/after -I/foo -I/bar"
-
-run_test
+run_test --cflags idirafter
diff --git a/check/check-includedir b/check/check-includedir
index 26d8ab5..d05cd9d 100755
--- a/check/check-includedir
+++ b/check/check-includedir
@@ -4,7 +4,5 @@ set -e
. ${srcdir}/common
-ARGS="--cflags includedir"
RESULT="-I/usr/include/somedir"
-
-run_test
+run_test --cflags includedir
diff --git a/check/check-libs b/check/check-libs
index 372314d..37d09b1 100755
--- a/check/check-libs
+++ b/check/check-libs
@@ -4,14 +4,12 @@ set -e
. ${srcdir}/common
-ARGS="--libs simple"
if [ "$list_indirect_deps" = "yes" ]; then
RESULT="-lsimple -lm"
else
RESULT="-lsimple"
fi
-run_test
+run_test --libs simple
-ARGS="--libs fields-blank"
RESULT=""
-run_test
+run_test --libs fields-blank
diff --git a/check/check-libs-private b/check/check-libs-private
index 0678fd7..736332d 100755
--- a/check/check-libs-private
+++ b/check/check-libs-private
@@ -4,7 +4,5 @@ set -e
. ${srcdir}/common
-ARGS="--static --libs simple"
RESULT="-lsimple -lm"
-
-run_test
+run_test --static --libs simple
diff --git a/check/check-missing b/check/check-missing
index 5616945..ef808e0 100755
--- a/check/check-missing
+++ b/check/check-missing
@@ -7,25 +7,21 @@ set -e
# non-existent package; call should fail and cause no output
EXPECT_RETURN=1
RESULT=""
-ARGS="--exists pkg-non-existent"
-run_test
+run_test --exists pkg-non-existent
# existing package, but with missing Requires
EXPECT_RETURN=1
RESULT=""
-ARGS="--exists missing-requires"
-run_test
+run_test --exists missing-requires
# tests below are on an existing package, but with missing Requires.private;
# when pkg-config outputs error, the actual error text isn't checked
# package exists, but should fail since deps can't be resolved
-ARGS="--exists missing-requires-private"
EXPECT_RETURN=1
RESULT=""
-run_test
+run_test --exists missing-requires-private
# get Libs
-ARGS="--libs missing-requires-private"
if [ "$list_indirect_deps" = "yes" ]; then
EXPECT_RETURN=1
RESULT='Package pkg-non-existent-private-dep was not found in the pkg-config search path.
@@ -36,54 +32,46 @@ else
EXPECT_RETURN=0
RESULT="-L/missing-requires-private/lib -lmissing-requires-private"
fi
-run_test
+run_test --libs missing-requires-private
# Libs.private should fail (verbosely, but the output isn't verified)
-ARGS="--silence-errors --static --libs missing-requires-private"
EXPECT_RETURN=1
RESULT=""
-run_test
+run_test --silence-errors --static --libs missing-requires-private
# Cflags.private should fail (verbosely, but the output isn't verified)
-ARGS="--silence-errors --static --cflags missing-requires-private"
EXPECT_RETURN=1
RESULT=""
-run_test
+run_test --silence-errors --static --cflags missing-requires-private
# Cflags should fail (verbosely, but the output isn't verified)
-ARGS="--silence-errors --cflags missing-requires-private"
EXPECT_RETURN=1
RESULT=""
-run_test
+run_test --silence-errors --cflags missing-requires-private
# get includedir var
-ARGS="--variable includedir missing-requires-private"
EXPECT_RETURN=0
RESULT="/usr/include/somedir"
-run_test
+run_test --variable includedir missing-requires-private
# tests below are on an existing package, but with missing Requires; when
# pkg-config outputs error, the actual error text isn't checked
# package exists
-ARGS="missing-requires"
EXPECT_RETURN=0
RESULT=""
-run_test
+run_test missing-requires
# Libs should fail
-ARGS="--silence-errors --libs missing-requires"
EXPECT_RETURN=1
RESULT=""
-run_test
+run_test --silence-errors --libs missing-requires
# Cflags should fail
-ARGS="--silence-errors --cflags missing-requires"
EXPECT_RETURN=1
RESULT=""
-run_test
+run_test --silence-errors --cflags missing-requires
# get includedir var
-ARGS="--variable includedir missing-requires"
EXPECT_RETURN=0
RESULT="/usr/include/somedir"
-run_test
+run_test --variable includedir missing-requires
diff --git a/check/check-requires-private b/check/check-requires-private
index e9ef2f2..27f88d6 100755
--- a/check/check-requires-private
+++ b/check/check-requires-private
@@ -5,27 +5,21 @@ set -e
. ${srcdir}/common
# expect cflags from requires-test and public-dep
-ARGS="--cflags requires-test"
RESULT="-I/requires-test/include -I/private-dep/include -I/public-dep/include"
-run_test
+run_test --cflags requires-test
# still expect those cflags for static linking case
-ARGS="--static --cflags requires-test"
RESULT="-I/requires-test/include -I/private-dep/include -I/public-dep/include"
-run_test
+run_test --static --cflags requires-test
# expect libs for just requires-test and public-dep
-ARGS="--libs requires-test"
if [ "$list_indirect_deps" = "yes" ]; then
RESULT="-L/requires-test/lib -L/private-dep/lib -L/public-dep/lib -lrequires-test -lprivate-dep -lpublic-dep"
else
RESULT="-L/requires-test/lib -L/public-dep/lib -lrequires-test -lpublic-dep"
fi
-run_test
+run_test --libs requires-test
# expect libs for requires-test, public-dep and private-dep in static case
-ARGS="--static --libs requires-test"
RESULT="-L/requires-test/lib -L/private-dep/lib -L/public-dep/lib -lrequires-test -lprivate-dep -lpublic-dep"
-run_test
-
-
+run_test --static --libs requires-test
diff --git a/check/check-version b/check/check-version
index 4254d65..6e0a766 100755
--- a/check/check-version
+++ b/check/check-version
@@ -9,94 +9,76 @@ v2=1.0.0
v3=1.0.1
# exact version testing
-ARGS="--exists --print-errors simple = $v1"
EXPECT_RETURN=1
RESULT="Requested 'simple = $v1' but version of Simple test is $v2"
-run_test
+run_test --exists --print-errors simple = $v1
-ARGS="--exists --print-errors --exact-version=$v1 simple"
EXPECT_RETURN=1
RESULT="Requested 'simple = $v1' but version of Simple test is $v2"
-run_test
+run_test --exists --print-errors --exact-version=$v1 simple
-ARGS="--exists --print-errors simple = $v2"
EXPECT_RETURN=0
RESULT=""
-run_test
+run_test --exists --print-errors simple = $v2
-ARGS="--exists --print-errors --exact-version=$v2 simple"
EXPECT_RETURN=0
RESULT=""
-run_test
+run_test --exists --print-errors --exact-version=$v2 simple
-ARGS="--exists --print-errors simple = $v3"
EXPECT_RETURN=1
RESULT="Requested 'simple = $v3' but version of Simple test is $v2"
-run_test
+run_test --exists --print-errors simple = $v3
-ARGS="--exists --print-errors --exact-version=$v3 simple"
EXPECT_RETURN=1
RESULT="Requested 'simple = $v3' but version of Simple test is $v2"
-run_test
+run_test --exists --print-errors --exact-version=$v3 simple
# atleast version testing
-ARGS="--exists --print-errors simple >= $v1"
EXPECT_RETURN=0
RESULT=""
-run_test
+run_test --exists --print-errors simple \>= $v1
-ARGS="--exists --print-errors --atleast-version=$v1 simple"
EXPECT_RETURN=0
RESULT=""
-run_test
+run_test --exists --print-errors --atleast-version=$v1 simple
-ARGS="--exists --print-errors simple >= $v2"
EXPECT_RETURN=0
RESULT=""
-run_test
+run_test --exists --print-errors simple \>= $v2
-ARGS="--exists --print-errors --atleast-version=$v2 simple"
EXPECT_RETURN=0
RESULT=""
-run_test
+run_test --exists --print-errors --atleast-version=$v2 simple
-ARGS="--exists --print-errors simple >= $v3"
EXPECT_RETURN=1
RESULT="Requested 'simple >= $v3' but version of Simple test is $v2"
-run_test
+run_test --exists --print-errors simple \>= $v3
-ARGS="--exists --print-errors --atleast-version=$v3 simple"
EXPECT_RETURN=1
RESULT="Requested 'simple >= $v3' but version of Simple test is $v2"
-run_test
+run_test --exists --print-errors --atleast-version=$v3 simple
# max version testing
-ARGS="--exists --print-errors simple <= $v1"
EXPECT_RETURN=1
RESULT="Requested 'simple <= $v1' but version of Simple test is $v2"
-run_test
+run_test --exists --print-errors simple \<= $v1
-ARGS="--exists --print-errors --max-version=$v1 simple"
EXPECT_RETURN=1
RESULT="Requested 'simple <= $v1' but version of Simple test is $v2"
-run_test
+run_test --exists --print-errors --max-version=$v1 simple
-ARGS="--exists --print-errors simple <= $v2"
EXPECT_RETURN=0
RESULT=""
-run_test
+run_test --exists --print-errors simple \<= $v2
-ARGS="--exists --print-errors --max-version=$v2 simple"
EXPECT_RETURN=0
RESULT=""
-run_test
+run_test --exists --print-errors --max-version=$v2 simple
-ARGS="--exists --print-errors simple <= $v3"
EXPECT_RETURN=0
RESULT=""
-run_test
+run_test --exists --print-errors simple \<= $v3
-ARGS="--exists --print-errors --max-version=$v3 simple"
EXPECT_RETURN=0
RESULT=""
-run_test
+run_test --exists --print-errors --max-version=$v3 simple
diff --git a/check/check-whitespace b/check/check-whitespace
index b26ec3d..aa551b5 100755
--- a/check/check-whitespace
+++ b/check/check-whitespace
@@ -5,11 +5,9 @@ set -e
. ${srcdir}/common
# expect cflags from whitespace
-ARGS="--cflags whitespace"
RESULT='-Dlala=misc -I/usr/white\ space/include -I$(top_builddir) -Iinclude\ dir -Iother\ include\ dir'
-run_test
+run_test --cflags whitespace
# expect libs from whitespace
-ARGS="--libs whitespace"
RESULT="-r:foo -L/usr/white\\ space/lib -lfoo\\ bar -lbar\\ baz"
-run_test
+run_test --libs whitespace
diff --git a/check/common b/check/common
index fe061cc..1115c2e 100644
--- a/check/common
+++ b/check/common
@@ -15,17 +15,17 @@ export LC_ALL=C
run_test () {
set +e
- ${pkgconfig} $ARGS >/dev/null 2>&1
+ ${pkgconfig} "$@" >/dev/null 2>&1
R=$?
if [ "$R" -ne "${EXPECT_RETURN:-0}" ]; then
- ${pkgconfig} --print-errors $ARGS
- echo "${pkgconfig} $ARGS exited with $R (expected ${EXPECT_RETURN:-0})" 1>&2
+ ${pkgconfig} --print-errors "$@"
+ echo "${pkgconfig} $@ exited with $R (expected ${EXPECT_RETURN:-0})" 1>&2
exit 1
fi
- R=$(${pkgconfig} $ARGS 2>&1 | sed -e 's,^[[:space:]]*,,' -e 's,[[:space:]]*$,,')
+ R=$(${pkgconfig} "$@" 2>&1 | sed -e 's,^[[:space:]]*,,' -e 's,[[:space:]]*$,,')
if [ "$R" != "$RESULT" ]; then
- echo "${pkgconfig} $ARGS :"
+ echo "${pkgconfig} $@ :"
echo "'$R' != '$RESULT'"
exit 1
fi