summaryrefslogtreecommitdiff
path: root/check
diff options
context:
space:
mode:
authorDan Nicholson <dbn.lists@gmail.com>2012-04-21 11:08:12 -0700
committerDan Nicholson <dbn.lists@gmail.com>2012-05-10 05:51:35 -0700
commita83a14c2911d1969d5a79029ac1624bdf317373c (patch)
tree55ff006b5cd9a5aa087a4adabb19d47e5dfcd987 /check
parent5fc77a96b7a1114e296f968037342f060d4bc34b (diff)
downloadpkg-config-a83a14c2911d1969d5a79029ac1624bdf317373c.tar.gz
Unify handling of operator and command line option version checking
The code for --exact/atleast/max-version was taking a different path than the handling of operators like =/>=/<=. Make the long option versions override the operators and take place during the standard package checking stage. This also means that --print-errors is respected. Fixes Freedesktop #8653
Diffstat (limited to 'check')
-rw-r--r--check/Makefile.am2
-rwxr-xr-xcheck/check-version107
2 files changed, 108 insertions, 1 deletions
diff --git a/check/Makefile.am b/check/Makefile.am
index 29ec729..0ce476a 100644
--- a/check/Makefile.am
+++ b/check/Makefile.am
@@ -2,7 +2,7 @@
TESTS = check-cflags check-libs check-define-variable \
check-libs-private check-requires-private check-includedir \
check-conflicts check-missing check-idirafter check-whitespace \
- check-cmd-options
+ check-cmd-options check-version
EXTRA_DIST = $(TESTS) common simple.pc requires-test.pc public-dep.pc \
private-dep.pc includedir.pc missing-requires-private.pc \
diff --git a/check/check-version b/check/check-version
new file mode 100755
index 0000000..6e92077
--- /dev/null
+++ b/check/check-version
@@ -0,0 +1,107 @@
+#! /bin/sh
+
+# Make sure we're POSIX
+if [ "$PKG_CONFIG_SHELL_IS_POSIX" != "1" ]; then
+ PKG_CONFIG_SHELL_IS_POSIX=1 PATH=`getconf PATH` exec sh $0 "$@"
+fi
+
+set -e
+
+. ${srcdir}/common
+
+v1=0.9.9
+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
+
+ARGS="--exists --print-errors --exact-version=$v1 simple"
+EXPECT_RETURN=1
+RESULT="Requested 'simple = $v1' but version of Simple test is $v2"
+run_test
+
+ARGS="--exists --print-errors simple = $v2"
+EXPECT_RETURN=0
+RESULT=""
+run_test
+
+ARGS="--exists --print-errors --exact-version=$v2 simple"
+EXPECT_RETURN=0
+RESULT=""
+run_test
+
+ARGS="--exists --print-errors simple = $v3"
+EXPECT_RETURN=1
+RESULT="Requested 'simple = $v3' but version of Simple test is $v2"
+run_test
+
+ARGS="--exists --print-errors --exact-version=$v3 simple"
+EXPECT_RETURN=1
+RESULT="Requested 'simple = $v3' but version of Simple test is $v2"
+run_test
+
+# atleast version testing
+ARGS="--exists --print-errors simple >= $v1"
+EXPECT_RETURN=0
+RESULT=""
+run_test
+
+ARGS="--exists --print-errors --atleast-version=$v1 simple"
+EXPECT_RETURN=0
+RESULT=""
+run_test
+
+ARGS="--exists --print-errors simple >= $v2"
+EXPECT_RETURN=0
+RESULT=""
+run_test
+
+ARGS="--exists --print-errors --atleast-version=$v2 simple"
+EXPECT_RETURN=0
+RESULT=""
+run_test
+
+ARGS="--exists --print-errors simple >= $v3"
+EXPECT_RETURN=1
+RESULT="Requested 'simple >= $v3' but version of Simple test is $v2"
+run_test
+
+ARGS="--exists --print-errors --atleast-version=$v3 simple"
+EXPECT_RETURN=1
+RESULT="Requested 'simple >= $v3' but version of Simple test is $v2"
+run_test
+
+# 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
+
+ARGS="--exists --print-errors --max-version=$v1 simple"
+EXPECT_RETURN=1
+RESULT="Requested 'simple <= $v1' but version of Simple test is $v2"
+run_test
+
+ARGS="--exists --print-errors simple <= $v2"
+EXPECT_RETURN=0
+RESULT=""
+run_test
+
+ARGS="--exists --print-errors --max-version=$v2 simple"
+EXPECT_RETURN=0
+RESULT=""
+run_test
+
+ARGS="--exists --print-errors simple <= $v3"
+EXPECT_RETURN=0
+RESULT=""
+run_test
+
+ARGS="--exists --print-errors --max-version=$v3 simple"
+EXPECT_RETURN=0
+RESULT=""
+run_test