summaryrefslogtreecommitdiff
path: root/regress/env-vars/spec
blob: e7def8b6fbeced350ed96f9d10365477d8005904 (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
# $NetBSD: spec,v 1.2 2018/11/09 06:59:20 rillig Exp $
#

tmpdir=${TMPDIR:-/tmp}/pkgsrc-env-vars
rm -rf "$tmpdir"
mkdir -p "$tmpdir"

require_file_has_lines() { # filename line...
	rfhl_expected="$tmpdir/expected"
	rfhl_actual=$1
	shift

	printf '%s\n' "$@" > "$rfhl_expected"

	if diff -u "$rfhl_expected" "$rfhl_actual" > /dev/null; then
		:
	else
		regress_fail "Expected files to be equal."
		diff -u "$rfhl_expected" "$rfhl_actual" || true
	fi

	rm -f "$rfhl_expected"
}


do_test() {
	env REGRESS_TMPDIR="$tmpdir" $TEST_MAKE clean
	env REGRESS_TMPDIR="$tmpdir" $TEST_MAKE update
}

check_result() {

	# In the {pre,do,post}-* targets, only the PKGSRC_MAKE_ENV
	# variables are set.
	#
	require_file_has_lines "$tmpdir/do-build.vars" \
		"PKGSRC_MAKE_ENV"

	# In the configure script of the package, some more variables
	# are set.
	#
	require_file_has_lines "$tmpdir/configure.vars" \
		"ALL_ENV" \
		"CONFIGURE_ENV" \
		"PKGSRC_MAKE_ENV"

	# In the build phase, when the default do-build commands are
	# run, the Makefiles from the package have access to these
	# variables:
	#
	require_file_has_lines "$tmpdir/make-all.vars" \
		"ALL_ENV" \
		"MAKE_ENV" \
		"PKGSRC_MAKE_ENV"

	# In the install phase, when the default do-install commands are
	# run, the Makefiles from the package have access to these
	# variables:
	#
	require_file_has_lines "$tmpdir/make-install.vars" \
		"ALL_ENV" \
		"INSTALL_ENV" \
		"MAKE_ENV" \
		"PKGSRC_MAKE_ENV"
}