diff options
author | rillig <rillig@pkgsrc.org> | 2020-05-19 05:14:18 +0000 |
---|---|---|
committer | rillig <rillig@pkgsrc.org> | 2020-05-19 05:14:18 +0000 |
commit | 084138c7f2cf501d4af620767d39c821d67ccf8b (patch) | |
tree | c5272bbf29ad31b93f3dea496ec05ebf05169f01 /regress | |
parent | 0724bb22bc46b825f5a96a2f18d63a2fa9368f52 (diff) | |
download | pkgsrc-084138c7f2cf501d4af620767d39c821d67ccf8b.tar.gz |
regress/infra-unittests: remove unnecessary tmpdir handling
The test infrastructure from test.subr already takes care of setting up a
temporary directory.
Diffstat (limited to 'regress')
-rw-r--r-- | regress/infra-unittests/subst.sh | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/regress/infra-unittests/subst.sh b/regress/infra-unittests/subst.sh index b99fe257cf5..e4e613af2c7 100644 --- a/regress/infra-unittests/subst.sh +++ b/regress/infra-unittests/subst.sh @@ -1,5 +1,5 @@ #! /bin/sh -# $NetBSD: subst.sh,v 1.42 2020/05/16 19:02:32 rillig Exp $ +# $NetBSD: subst.sh,v 1.43 2020/05/19 05:14:18 rillig Exp $ # # Tests for mk/subst.mk. # @@ -9,9 +9,6 @@ set -eu . './test.subr' test_case_set_up() { - wrkdir="$tmpdir/wrkdir" - mkdir "$wrkdir" - create_file 'prepare-subst.mk' <<-EOF # The tools that are used by subst.mk AWK= awk @@ -38,16 +35,11 @@ test_case_set_up() { WARNING_MSG= echo 'warning:' FAIL_MSG= sh $pkgsrcdir/mk/scripts/fail echo 'fail:' 1>&2 - WRKDIR= $tmpdir/wrkdir - WRKSRC= . + WRKDIR= $PWD + WRKSRC= $PWD EOF } -test_case_tear_down() { - # Clean up the .subst_*_done cookie files. - rm -r "$wrkdir" -} - if test_case_begin 'single file'; then @@ -528,6 +520,11 @@ if test_case_begin 'late evaluation of SUBST_FILES'; then # list of files is generated by a shell command. # See mk/configure/replace-localedir.mk. + # If SUBST_FILES were to be evaluated early, it would expand to + # "too-early", since that file exists when testcase.mk is parsed, + # as opposed to "first" "second" "third", which only exist when + # the subst-class target is run. + create_file 'testcase.mk' <<EOF REPLACE_FILES_CMD.class= \ cd \${WRKSRC} && echo *r* @@ -547,19 +544,22 @@ WRKSRC= \${WRKDIR}/package-1.0 \${_SUBST_COOKIE.class}: prepare-subst-class prepare-subst-class: \${RUN} \${MKDIR} \${WRKSRC} + \${RUN} \${RM} '\${WRKSRC}/too-early' \${RUN} \${ECHO} 'from' > '\${WRKSRC}/first' \${RUN} \${ECHO} 'from' > '\${WRKSRC}/second' \${RUN} \${ECHO} 'from' > '\${WRKSRC}/third' EOF + create_file_lines 'package-1.0/too-early' \ + 'from' run_bmake 'testcase.mk' 'subst-class' 1> "$tmpdir/output" 2>&1 \ && exitcode=0 || exitcode=$? assert_that "$tmpdir/output" --file-is-lines \ '=> Substituting "class" in first third' - assert_that "$wrkdir/package-1.0/first" --file-is-lines 'to' - assert_that "$wrkdir/package-1.0/second" --file-is-lines 'from' - assert_that "$wrkdir/package-1.0/third" --file-is-lines 'to' + assert_that "package-1.0/first" --file-is-lines 'to' + assert_that "package-1.0/second" --file-is-lines 'from' + assert_that "package-1.0/third" --file-is-lines 'to' assert_that "$exitcode" --equals '0' test_case_end |