diff options
author | rillig <rillig@pkgsrc.org> | 2020-04-23 18:30:37 +0000 |
---|---|---|
committer | rillig <rillig@pkgsrc.org> | 2020-04-23 18:30:37 +0000 |
commit | d91f3fa94ae16384f00713b3775b8e6667359f77 (patch) | |
tree | ff77c45d876e56729b835cf9f0b8e80f565b7a23 /regress | |
parent | f0f55f17ca1726f2e9d3a168e1877751c321eba0 (diff) | |
download | pkgsrc-d91f3fa94ae16384f00713b3775b8e6667359f77.tar.gz |
regress/infra-unittests: add more tests for subst.mk
Diffstat (limited to 'regress')
-rw-r--r-- | regress/infra-unittests/subst.sh | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/regress/infra-unittests/subst.sh b/regress/infra-unittests/subst.sh index a52ee9c3c07..d6de38f94e8 100644 --- a/regress/infra-unittests/subst.sh +++ b/regress/infra-unittests/subst.sh @@ -971,3 +971,97 @@ if test_case_begin "first filename pattern has no effect"; then test_case_end fi + + +if test_case_begin "empty SUBST_FILES"; then + + # An empty SUBST_FILES section is ok. + # It may have been produced by a shell command like find(1). + + create_file_lines "testcase.mk" \ + 'SUBST_CLASSES+= id' \ + 'SUBST_STAGE.id= pre-configure' \ + 'SUBST_FILES.id= # none' \ + 'SUBST_SED.id= -e s,from,to,' \ + 'SUBST_NOOP_OK.id= no' \ + '' \ + 'all:' \ + ' @printf "%s\n" ${PKG_FAIL_REASON:Uok}' \ + '' \ + '.include "prepare-subst.mk"' \ + '.include "mk/subst.mk"' + + run_bmake "testcase.mk" "pre-configure" "all" 1> "$tmpdir/out" 2>&1 \ + && exitcode=0 || exitcode=$? + + assert_that "out" --file-is-lines \ + '=> Substituting "id" in ' \ + 'ok' + + test_case_end +fi + + +if test_case_begin "empty SUBST_SED"; then + + create_file_lines "testcase.mk" \ + 'SUBST_CLASSES+= id' \ + 'SUBST_STAGE.id= pre-configure' \ + 'SUBST_FILES.id= file' \ + 'SUBST_SED.id= # none' \ + 'SUBST_NOOP_OK.id= no' \ + '' \ + 'all:' \ + ' @printf "%s\n" ${PKG_FAIL_REASON:Uok}' \ + '' \ + '.include "prepare-subst.mk"' \ + '.include "mk/subst.mk"' + + run_bmake "testcase.mk" "pre-configure" "all" 1> "$tmpdir/out" 2>&1 \ + && exitcode=0 || exitcode=$? + + assert_that "out" --file-is-lines \ + '=> Substituting "id" in file' \ + 'warning: [subst.mk:id] Ignoring non-existent file "./file".' \ + 'fail: [subst.mk:id] The filename pattern "file" has no effect.' \ + '*** Error code 1' \ + '' \ + 'Stop.' \ + "$make: stopped in $PWD" + + test_case_end +fi + + +if test_case_begin "typo in SUBST_CLASSES"; then + + # Look closely. The SUBST_CLASSES line contains a typo. + # subst.mk does not catch this, but pkglint does. + + create_file_lines "testcase.mk" \ + 'SUBST_CLASSES=+ id' \ + 'SUBST_STAGE.id= pre-configure' \ + 'SUBST_FILES.id= file' \ + 'SUBST_SED.id= # none' \ + 'SUBST_NOOP_OK.id= no' \ + '' \ + 'all:' \ + ' @printf "%s\n" ${PKG_FAIL_REASON:Uok}' \ + '' \ + '.include "prepare-subst.mk"' \ + '.include "mk/subst.mk"' + + run_bmake "testcase.mk" "pre-configure" "all" 1> "$tmpdir/out" 2>&1 \ + && exitcode=0 || exitcode=$? + + assert_that "out" --file-is-lines \ + '=> Substituting "id" in file' \ + 'warning: [subst.mk:id] Ignoring non-existent file "./file".' \ + 'fail: [subst.mk:id] The filename pattern "file" has no effect.' \ + '*** Error code 1' \ + '' \ + 'Stop.' \ + "$make: stopped in $PWD" + + test_case_end +fi |