pkgsrc-Changes archive

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

CVS commit: pkgsrc/regress/infra-unittests



Module Name:    pkgsrc
Committed By:   rillig
Date:           Tue May 19 05:14:18 UTC 2020

Modified Files:
        pkgsrc/regress/infra-unittests: subst.sh

Log Message:
regress/infra-unittests: remove unnecessary tmpdir handling

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


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 pkgsrc/regress/infra-unittests/subst.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: pkgsrc/regress/infra-unittests/subst.sh
diff -u pkgsrc/regress/infra-unittests/subst.sh:1.42 pkgsrc/regress/infra-unittests/subst.sh:1.43
--- pkgsrc/regress/infra-unittests/subst.sh:1.42        Sat May 16 19:02:32 2020
+++ pkgsrc/regress/infra-unittests/subst.sh     Tue May 19 05:14:18 2020
@@ -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 S
        # 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



Home | Main Index | Thread Index | Old Index