caf5567d50
Before, variables containing dollar characters displayed so wrong that it was hard to explain. To fix the problem, I typed almost random characters into the code until the output was exactly as expected. I still do not understand: * why the list variables need 8 dollars to survive the @x@ loop, * why the code only works if the dollars come from an external variable instead of being written inline, * why the backslash in the :C modifier needs to be doubled. Anyway, the output of "bmake show-all-extract" now contains the shell variable $${extract_file}, just as it should. The dollars are now doubled in the output and thereby match the source code from the Makefile exactly.
90 lines
2.4 KiB
Text
90 lines
2.4 KiB
Text
# $NetBSD: spec,v 1.4 2020/03/20 16:39:03 rillig Exp $
|
|
|
|
tmpdir=${TMPDIR:-/tmp}/pkgsrc-show-all
|
|
rm -rf "$tmpdir"
|
|
mkdir -p "$tmpdir"
|
|
|
|
require_file() {
|
|
if diff -u "$3" "$1" > /dev/null; then
|
|
:
|
|
else
|
|
regress_fail "Expected files to be equal."
|
|
diff -u "$3" "$1" || true
|
|
fi
|
|
}
|
|
|
|
|
|
do_test() {
|
|
$TEST_MAKE show-all-regress > "$tmpdir/show-all-regress.out"
|
|
$TEST_MAKE show-all-shellvar > "$tmpdir/show-all-shellvar.out"
|
|
}
|
|
|
|
check_result() {
|
|
exit_status 0
|
|
|
|
cat <<'EOF' > "$tmpdir/expected"
|
|
regress:
|
|
pkg REGRESS_ENV.undefined # undefined
|
|
pkg REGRESS_ENV.empty= # empty
|
|
pkg REGRESS_ENV.space= # empty
|
|
pkg REGRESS_ENV.value= \
|
|
*=all \
|
|
VAR1=value1 \
|
|
VAR2=`command \
|
|
backticks` \
|
|
execution \
|
|
via \
|
|
# end of REGRESS_ENV.value (sorted)
|
|
pkg REGRESS_ARGS.undefined # undefined
|
|
pkg REGRESS_ARGS.empty= # empty
|
|
pkg REGRESS_ARGS.space= # empty
|
|
pkg REGRESS_ARGS.value= \
|
|
VAR1=value1 \
|
|
VAR2=`command \
|
|
execution \
|
|
via \
|
|
backticks` \
|
|
*=all \
|
|
# end of REGRESS_ARGS.value
|
|
pkg REGRESS.undefined # undefined
|
|
pkg REGRESS.empty= # empty
|
|
pkg REGRESS.space= # ends with space
|
|
pkg REGRESS.value= All * kinds of `strange' \escape $$characters
|
|
pkg *= show-all-regress
|
|
pkg **= asterisk
|
|
|
|
EOF
|
|
|
|
# The "*" variable is built-in into bmake and expands to the current
|
|
# make target, which in this case is "show-all-regress".
|
|
|
|
# The "**" variable ensures that show-all doesn't accidentally expand
|
|
# filenames.
|
|
|
|
# It's a bit strange that bmake doesn't handle the backticks command
|
|
# as a single word. Luckily, this is a rare case.
|
|
#
|
|
# On the other hand, if it did, bmake would also have to handle
|
|
# variable expansion and all the other syntactic difficulties from
|
|
# parsing shell commands, and that would be just too much.
|
|
|
|
require_file "$tmpdir/show-all-regress.out" --equals "$tmpdir/expected"
|
|
|
|
|
|
# Up to 2020-03-20, the output of the ENV and ARGS variables differed
|
|
# a lot from the PLAIN variable.
|
|
#
|
|
cat <<'EOF' > "$tmpdir/expected"
|
|
shellvar:
|
|
pkg SHELLVAR_PLAIN= "$$var $${var} $$other $$$$"
|
|
pkg SHELLVAR_ENV= \
|
|
"$$var $${var} $$other $$$$" \
|
|
# end of SHELLVAR_ENV (sorted)
|
|
pkg SHELLVAR_ARGS= \
|
|
"$$var $${var} $$other $$$$" \
|
|
# end of SHELLVAR_ARGS
|
|
|
|
EOF
|
|
|
|
require_file "$tmpdir/show-all-shellvar.out" --equals "$tmpdir/expected"
|
|
}
|