summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Nicholson <dbn.lists@gmail.com>2016-01-29 10:36:04 -0800
committerDan Nicholson <dbn.lists@gmail.com>2016-02-26 08:56:52 -0800
commita3e58e7d4d624eb5a7898fc550b30d4c9bdffe71 (patch)
tree31f32ec4ce003b78c14183276ea4a469e34948ea
parent1c564a358303a8396dc71cc92d79bd0ac304b15c (diff)
downloadpkg-config-a3e58e7d4d624eb5a7898fc550b30d4c9bdffe71.tar.gz
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
-rw-r--r--check/Makefile.am5
-rwxr-xr-xcheck/check-variables18
-rwxr-xr-xcheck/check-whitespace5
-rw-r--r--check/variables.pc11
4 files changed, 38 insertions, 1 deletions
diff --git a/check/Makefile.am b/check/Makefile.am
index 4f92e0d..d4000d8 100644
--- a/check/Makefile.am
+++ b/check/Makefile.am
@@ -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)
diff --git a/check/check-variables b/check/check-variables
new file mode 100755
index 0000000..356b375
--- /dev/null
+++ b/check/check-variables
@@ -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
diff --git a/check/check-whitespace b/check/check-whitespace
index e4388ba..6186c22 100755
--- a/check/check-whitespace
+++ b/check/check-whitespace
@@ -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
diff --git a/check/variables.pc b/check/variables.pc
new file mode 100644
index 0000000..b27ab78
--- /dev/null
+++ b/check/variables.pc
@@ -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}