From 48fa9fdf7c6bb8c850373294f87edf7141a79049 Mon Sep 17 00:00:00 2001 From: Dan Nicholson Date: Fri, 29 Jan 2016 10:36:04 -0800 Subject: [PATCH] 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 --- check/Makefile.am | 8 ++++++-- check/check-variables | 18 ++++++++++++++++++ check/check-whitespace | 5 +++++ check/variables.pc | 11 +++++++++++ 4 files changed, 40 insertions(+), 2 deletions(-) create mode 100755 check/check-variables create mode 100644 check/variables.pc diff --git a/check/Makefile.am b/check/Makefile.am index 34d0e34..f370839 100644 --- a/check/Makefile.am +++ b/check/Makefile.am @@ -26,7 +26,9 @@ TESTS = \ check-debug \ check-gtk \ check-tilde \ - check-relocatable + check-relocatable \ + check-variables \ + $(NULL) EXTRA_DIST = \ $(TESTS) \ @@ -97,4 +99,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} -- 2.5.0