# $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" }