check: More thoroughly test variable usage

Add some more tests for handling unusual variables such as those that
are quoted or that contain shell characters. This should help make the
--variable output more reliable in the future.

https://bugs.freedesktop.org/show_bug.cgi?id=93284
This commit is contained in:
Dan Nicholson 2016-01-29 10:36:04 -08:00
parent 1c564a3583
commit a3e58e7d4d
4 changed files with 38 additions and 1 deletions

View file

@ -28,6 +28,7 @@ TESTS = \
check-tilde \
check-relocatable \
check-variable-override \
check-variables \
$(NULL)
EXTRA_DIST = \
@ -99,4 +100,6 @@ EXTRA_DIST = \
tilde.pc \
pkgconfig/prefixdef.pc \
pkgconfig/prefixdef-expanded.pc \
pcfiledir.pc
pcfiledir.pc \
variables.pc \
$(NULL)

18
check/check-variables Executable file
View file

@ -0,0 +1,18 @@
#! /bin/sh
set -e
. ${srcdir}/common
# Check quoted variables are stripped. In 0.28 and earlier, this would
# contain the "" quotes.
RESULT='/local/include'
run_test --variable=includedir variables
# Non-quoted variables are output as is. In 0.29, the \ would be stripped.
RESULT='-I"/local/include"/foo -DFOO=\"/bar\"'
run_test --variable=cppflags variables
# Check the entire cflags output
RESULT='-DFOO=\"/bar\" -I/local/include -I/local/include/foo'
run_test --cflags variables

View file

@ -4,6 +4,11 @@ set -e
. ${srcdir}/common
# variables come out unquoted. In 0.28 and earlier, this would also
# contain the ""s quoting the variable.
RESULT='/usr/white space/include'
run_test --variable=includedir whitespace
# expect cflags from whitespace
RESULT='-Dlala=misc -I/usr/white\ space/include -I$(top_builddir) -Iinclude\ dir -Iother\ include\ dir'
run_test --cflags whitespace

11
check/variables.pc Normal file
View file

@ -0,0 +1,11 @@
prefix=/local
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir="${prefix}/include"
cppflags=-I${includedir}/foo \
-DFOO=\"/bar\"
Name: Complex variables
Description: Test complex variable output
Version: 1.0
Cflags: -I${includedir} ${cppflags}