diff options
author | rillig <rillig@pkgsrc.org> | 2020-03-20 09:00:44 +0000 |
---|---|---|
committer | rillig <rillig@pkgsrc.org> | 2020-03-20 09:00:44 +0000 |
commit | a72047bce242fe4626ae4b728dc024356d4b08d2 (patch) | |
tree | 2f3178f8a078cd4cea052c3086c6dfcd9499d08d /regress | |
parent | 9106a5b08962f09612830118fdb60f16c090e1a0 (diff) | |
download | pkgsrc-a72047bce242fe4626ae4b728dc024356d4b08d2.tar.gz |
mk/subst.mk: evaluate SUBST_MESSAGE only once, and late
The default value of SUBST_MESSAGE is based on SUBST_FILES, and that
variable may use the :sh modifier to list files from WRKSRC, which may
not exist at load time.
Diffstat (limited to 'regress')
-rw-r--r-- | regress/infra-unittests/subst.sh | 52 |
1 files changed, 49 insertions, 3 deletions
diff --git a/regress/infra-unittests/subst.sh b/regress/infra-unittests/subst.sh index d96ce2e7adb..8091bdc9d77 100644 --- a/regress/infra-unittests/subst.sh +++ b/regress/infra-unittests/subst.sh @@ -379,9 +379,55 @@ EOF test_case_end 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. + +if test_case_begin "late evaluation of SUBST_FILES"; then + + # Ensure that 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. + + create_file "testcase.mk" <<EOF +REPLACE_FILES_CMD.class= \ + cd \${WRKSRC} && echo *r* + +SUBST_CLASSES+= class +SUBST_STAGE.class= pre-configure +SUBST_FILES.class= first third # \${REPLACE_FILES_CMD.class:sh} +SUBST_SED.class= -e 's,from,to,' + +.include "prepare-subst.mk" +RUN= @set -e; +WRKSRC= \${WRKDIR}/package-1.0 +.include "mk/subst.mk" + +# It is tricky that the dependency must use an internal implementation +# detail, but that's the only way to guarantee the correct ordering. +\${_SUBST_COOKIE.class}: prepare-subst-class +prepare-subst-class: + \${RUN} \${MKDIR} \${WRKSRC} + \${RUN} \${ECHO} "from" > "\${WRKSRC}/first" + \${RUN} \${ECHO} "from" > "\${WRKSRC}/second" + \${RUN} \${ECHO} "from" > "\${WRKSRC}/third" +EOF + + test_file "testcase.mk" "subst-class" \ + 1> "$tmpdir/actual-output" \ + 2> "$tmpdir/actual-stderr" \ + && exitcode=0 || exitcode=$? + + create_file_lines "expected-output" \ + '=> Substituting "class" in first third' + assert_that "actual-output" --file-equals "expected-output" + assert_that "actual-stderr" --file-is-empty + assert_that "package-1.0/first" --file-contains-exactly "to" + assert_that "package-1.0/second" --file-contains-exactly "from" + assert_that "package-1.0/third" --file-contains-exactly "to" + assert_that "$exitcode" --equals "0" + + test_case_end +fi + # TODO: Add tests for files having special characters, like space, dollar, # backticks, basically every ASCII character. |