summaryrefslogtreecommitdiff
path: root/regress/show-all/spec
blob: b2a6b79366771607a27fa3cbfc477ddb7346eda0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# $NetBSD: spec,v 1.5 2020/07/01 07:39:52 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"
}