pkg-config/check/check-version
Dan Nicholson a83a14c291 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
2012-05-10 05:51:35 -07:00

107 lines
2.3 KiB
Bash
Executable file

#! /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