summaryrefslogtreecommitdiff
path: root/regress
diff options
context:
space:
mode:
authorrillig <rillig@pkgsrc.org>2020-03-20 06:17:48 +0000
committerrillig <rillig@pkgsrc.org>2020-03-20 06:17:48 +0000
commit916520ab2e354eb2d562e3bac88f1fe088c44247 (patch)
treecdd63b3e1e113d316ee88373eae9e8c2a39ee021 /regress
parent3748c0de6b7df853ea4b8252bddd7059ab43b55b (diff)
downloadpkgsrc-916520ab2e354eb2d562e3bac88f1fe088c44247.tar.gz
mk/subst.mk: fix early evaluation of SUBST_FILES
In the case of pkglocaledir, the SUBST_FILES are generated by a shell command. That command assumes that the WRKDIR already exists. Therefore SUBST_FILES must be evaluated as late as possible. See mk/configure/replace-localedir.mk; an example package that fails is devel/gettext-tools.
Diffstat (limited to 'regress')
-rw-r--r--regress/infra-unittests/subst.sh35
1 files changed, 21 insertions, 14 deletions
diff --git a/regress/infra-unittests/subst.sh b/regress/infra-unittests/subst.sh
index cb0c745325c..6bd1543fc09 100644
--- a/regress/infra-unittests/subst.sh
+++ b/regress/infra-unittests/subst.sh
@@ -9,7 +9,7 @@ set -eu
testcase() {
test_name="$1"
- rm -rf "$tmpdir/".subst_*_done
+ rm -rf "$tmpdir"/.subst_*_done "$tmpdir"/.subst-empty
rm -rf "$tmpdir"/*
ls -A "$tmpdir"
@@ -19,8 +19,10 @@ testcase() {
CHMOD= chmod-is-not-used
CMP= cmp
ECHO= echo
+MKDIR= mkdir -p
MV= mv
RM= rm
+RMDIR= rmdir
SED= sed
TEST= test
TOUCH= touch
@@ -29,7 +31,7 @@ TR= tr
TRUE= true
# Commands that are specific to pkgsrc
-RUN= @: set -x;
+RUN= @set -e;
STEP_MSG= echo "=>"
DO_NADA= : do-nada
INFO_MSG= echo "info:"
@@ -164,7 +166,7 @@ EOF
fi
-if testcase "single file noop"; then
+if testcase "single file noop, noop_ok=yes"; then
create_file "testcase.mk" <<EOF
SUBST_CLASSES+= class
@@ -182,17 +184,17 @@ EOF
create_file_lines "single" "already an example"
test_file "testcase.mk" > "$tmpdir/actual-output" && exitcode=0 || exitcode=$?
- assert_that "$exitcode" --equals "0"
+
create_file_lines "expected-output" \
'=> Substituting "class" in single' \
'info: [subst.mk:class] Nothing changed in ./single.'
-
assert_that "actual-output" --file-equals "expected-output"
assert_that "single" --file-contains-exactly "already an example"
+ assert_that "$exitcode" --equals "0"
fi
-if testcase "single file noop ok"; then
+if testcase "single file noop, noop_ok=no"; then
create_file "testcase.mk" <<EOF
SUBST_CLASSES+= class
@@ -210,7 +212,7 @@ EOF
create_file_lines "single" "already an example"
test_file "testcase.mk" > "$tmpdir/actual-output" && exitcode=0 || exitcode=$?
- assert_that "$exitcode" --equals "1"
+
create_file_lines "expected-output" \
'=> Substituting "class" in single' \
'info: [subst.mk:class] Nothing changed in ./single.' \
@@ -219,9 +221,9 @@ EOF
'' \
'Stop.' \
"$make: stopped in $PWD"
-
assert_that "actual-output" --file-equals "expected-output"
assert_that "single" --file-contains-exactly "already an example"
+ assert_that "$exitcode" --equals "1"
fi
@@ -241,7 +243,7 @@ all: subst-class
EOF
test_file "testcase.mk" > "$tmpdir/actual-output" && exitcode=0 || exitcode=$?
- assert_that "$exitcode" --equals "1"
+
create_file_lines "expected-output" \
'=> Substituting "class" in nonexistent' \
'warning: [subst.mk:class] Ignoring non-existent file "./nonexistent".' \
@@ -250,8 +252,8 @@ EOF
'' \
'Stop.' \
"$make: stopped in $PWD"
-
assert_that "actual-output" --file-equals "expected-output"
+ assert_that "$exitcode" --equals "1"
fi
@@ -271,12 +273,12 @@ all: subst-class
EOF
test_file "testcase.mk" > "$tmpdir/actual-output" && exitcode=0 || exitcode=$?
- assert_that "$exitcode" --equals "0"
+
create_file_lines "expected-output" \
'=> Substituting "class" in nonexistent' \
'warning: [subst.mk:class] Ignoring non-existent file "./nonexistent".'
-
assert_that "actual-output" --file-equals "expected-output"
+ assert_that "$exitcode" --equals "0"
fi
@@ -326,7 +328,6 @@ EOF
'warning: [subst.mk:class] Ignoring non-existent file "./does".' \
'warning: [subst.mk:class] Ignoring non-existent file "./not".' \
'warning: [subst.mk:class] Ignoring non-existent file "./exist".'
-
assert_that "actual-output" --file-equals "expected-output"
assert_that "$exitcode" --equals "0"
fi
@@ -354,7 +355,13 @@ EOF
'info: [subst.mk:class] Nothing changed in ./first.' \
'info: [subst.mk:class] Nothing changed in ./second.' \
'info: [subst.mk:class] Nothing changed in ./third.'
-
assert_that "actual-output" --file-equals "expected-output"
assert_that "$exitcode" --equals "0"
fi
+
+# TODO: Add test that ensures SUBST_FILES is evaluated as late as possible.
+# Evaluating it early breaks cases like _pkglocaledir where the list of files
+# is generated by a shell command. See mk/configure/replace-localedir.mk.
+
+# TODO: Add tests for files having special characters, like space, dollar,
+# backticks, basically every ASCII character.