Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/regress/infra-unittests regress/infra-unittests: remov...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/801b0ea80150
branches:  trunk
changeset: 432104:801b0ea80150
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Tue May 19 05:14:18 2020 +0000

description:
regress/infra-unittests: remove unnecessary tmpdir handling

The test infrastructure from test.subr already takes care of setting up a
temporary directory.

diffstat:

 regress/infra-unittests/subst.sh |  28 ++++++++++++++--------------
 1 files changed, 14 insertions(+), 14 deletions(-)

diffs (77 lines):

diff -r 509013d6be6f -r 801b0ea80150 regress/infra-unittests/subst.sh
--- a/regress/infra-unittests/subst.sh  Tue May 19 05:14:01 2020 +0000
+++ b/regress/infra-unittests/subst.sh  Tue May 19 05:14:18 2020 +0000
@@ -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 @@
 . './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 @@
                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 @@
        # 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 @@
 \${_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



Home | Main Index | Thread Index | Old Index