Received: by mail.netbsd.org (Postfix, from userid 605) id B976384DF9; Sat, 21 Mar 2020 12:47:14 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mail.netbsd.org (Postfix) with ESMTP id 3F60184D41 for ; Sat, 21 Mar 2020 12:47:14 +0000 (UTC) X-Virus-Scanned: amavisd-new at netbsd.org Received: from mail.netbsd.org ([IPv6:::1]) by localhost (mail.netbsd.org [IPv6:::1]) (amavisd-new, port 10025) with ESMTP id 4_O-0UTdlyPd for ; Sat, 21 Mar 2020 12:47:13 +0000 (UTC) Received: from cvs.NetBSD.org (ivanova.netbsd.org [199.233.217.197]) by mail.netbsd.org (Postfix) with ESMTP id A757284CD3 for ; Sat, 21 Mar 2020 12:47:13 +0000 (UTC) Received: by cvs.NetBSD.org (Postfix, from userid 500) id 9A2A3FB27; Sat, 21 Mar 2020 12:47:13 +0000 (UTC) Content-Transfer-Encoding: 7bit Content-Type: multipart/mixed; boundary="_----------=_1584794833258870" MIME-Version: 1.0 Date: Sat, 21 Mar 2020 12:47:13 +0000 From: "Roland Illig" Subject: CVS commit: pkgsrc/regress/infra-unittests To: pkgsrc-changes@NetBSD.org Reply-To: rillig@netbsd.org X-Mailer: log_accum Message-Id: <20200321124713.9A2A3FB27@cvs.NetBSD.org> Sender: pkgsrc-changes-owner@NetBSD.org List-Id: pkgsrc-changes.NetBSD.org Precedence: bulk List-Unsubscribe: This is a multi-part message in MIME format. --_----------=_1584794833258870 Content-Disposition: inline Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" Module Name: pkgsrc Committed By: rillig Date: Sat Mar 21 12:47:13 UTC 2020 Modified Files: pkgsrc/regress/infra-unittests: subst.sh Log Message: regress/infra-unittests: add more tests for subst.mk To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 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. --_----------=_1584794833258870 Content-Disposition: inline Content-Length: 2767 Content-Transfer-Encoding: binary Content-Type: text/x-diff; charset=us-ascii Modified files: Index: pkgsrc/regress/infra-unittests/subst.sh diff -u pkgsrc/regress/infra-unittests/subst.sh:1.8 pkgsrc/regress/infra-unittests/subst.sh:1.9 --- pkgsrc/regress/infra-unittests/subst.sh:1.8 Sat Mar 21 12:22:31 2020 +++ pkgsrc/regress/infra-unittests/subst.sh Sat Mar 21 12:47:13 2020 @@ -14,6 +14,7 @@ test_case_set_up() { # The tools that are used by subst.mk CHMOD= chmod-is-not-used CMP= cmp +DIFF= diff ECHO= echo MKDIR= mkdir -p MV= mv @@ -538,3 +539,91 @@ EOF test_case_end fi + + +if test_case_begin "several SUBST classes"; then + + # It's ok to have several SUBST classes that apply to the same file. + # The order of execution is not guaranteed though. + + create_file_lines "file" "zero one two three four" + + create_file "testcase.mk" < "$tmpdir/stdout" \ + 2> "$tmpdir/stderr" \ + && exitcode=0 || exitcode=$? + + # The order of the above output is not guaranteed. + LC_ALL=C sort < "$tmpdir/stdout" > "$tmpdir/stdout-sorted" + + assert_that "file" --file-is-lines "zero I II III four" + assert_that "stdout-sorted" --file-is-lines \ + "=> Substituting \"one\" in file" \ + "=> Substituting \"three\" in file" \ + "=> Substituting \"two\" in file" + assert_that "stderr" --file-is-empty + assert_that "$exitcode" --equals 0 + + test_case_end +fi + + +if test_case_begin "show diff"; then + + create_file_lines "file" "one" "two" "three" + + create_file "testcase.mk" < "$tmpdir/stdout" \ + 2> "$tmpdir/stderr" \ + && exitcode=0 || exitcode=$? + + awk '{ if (/^... \.\/.*/) { print $1 " " $2 " (filtered timestamp)" } else { print $0 } }' \ + < "$tmpdir/stdout" > "$tmpdir/stdout-filtered" + + assert_that "file" --file-is-lines "one" "II" "three" + assert_that "stdout-filtered" --file-is-lines \ + "=> Substituting \"two\" in file" \ + "--- ./file (filtered timestamp)" \ + "+++ ./file.subst.sav (filtered timestamp)" \ + "@@ -1,3 +1,3 @@" \ + " one" \ + "-two" \ + "+II" \ + " three" + assert_that "stderr" --file-is-empty + assert_that "$exitcode" --equals 0 + + test_case_end +fi --_----------=_1584794833258870--