Received: by mail.netbsd.org (Postfix, from userid 605) id E2FAD84D97; Fri, 20 Mar 2020 21:27:05 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mail.netbsd.org (Postfix) with ESMTP id 6AE4384D86 for ; Fri, 20 Mar 2020 21:27:05 +0000 (UTC) X-Virus-Scanned: amavisd-new at netbsd.org Received: from mail.netbsd.org ([127.0.0.1]) by localhost (mail.netbsd.org [127.0.0.1]) (amavisd-new, port 10025) with ESMTP id fa66nNjz8Afu for ; Fri, 20 Mar 2020 21:27:04 +0000 (UTC) Received: from cvs.NetBSD.org (ivanova.netbsd.org [199.233.217.197]) by mail.netbsd.org (Postfix) with ESMTP id A891484CD3 for ; Fri, 20 Mar 2020 21:27:04 +0000 (UTC) Received: by cvs.NetBSD.org (Postfix, from userid 500) id A2715FB27; Fri, 20 Mar 2020 21:27:04 +0000 (UTC) Content-Transfer-Encoding: 7bit Content-Type: multipart/mixed; boundary="_----------=_158473962436180" MIME-Version: 1.0 Date: Fri, 20 Mar 2020 21:27:04 +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: <20200320212704.A2715FB27@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. --_----------=_158473962436180 Content-Disposition: inline Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" Module Name: pkgsrc Committed By: rillig Date: Fri Mar 20 21:27:04 UTC 2020 Modified Files: pkgsrc/regress/infra-unittests: subst.sh test.subr Log Message: regress/infra-unittests: add tests for special characters in subst.mk To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 pkgsrc/regress/infra-unittests/subst.sh cvs rdiff -u -r1.3 -r1.4 pkgsrc/regress/infra-unittests/test.subr Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. --_----------=_158473962436180 Content-Disposition: inline Content-Length: 4842 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.5 pkgsrc/regress/infra-unittests/subst.sh:1.6 --- pkgsrc/regress/infra-unittests/subst.sh:1.5 Fri Mar 20 09:00:45 2020 +++ pkgsrc/regress/infra-unittests/subst.sh Fri Mar 20 21:27:04 2020 @@ -7,9 +7,7 @@ set -eu . "./test.subr" test_case_set_up() { - rm -rf "$tmpdir"/.subst_*_done "$tmpdir"/.subst-empty - rm -rf "$tmpdir"/* - ls -A "$tmpdir" + rm -rf "$tmpdir"/.??* "$tmpdir"/* create_file "prepare-subst.mk" <?" "before" + create_file_lines "@ABCDEFGHIJKLMNO" "before" + create_file_lines "PQRSTUVWXYZ[\\]^_" "before" + create_file_lines "\`abcdefghijklmno" "before" + create_file_lines "pqrstuvwxyz{|}~" "before" + create_file_lines "--no-option" "before" + create_file_lines ".hidden" "before" + + test_file "testcase.mk" "subst-class" \ + 1> "$tmpdir/stdout" \ + 2> "$tmpdir/stderr" \ + && exitcode=0 || exitcode=$? + + assert_that "stdout" --file-is-lines \ + '=> Substituting "class" in *' \ + 'info: [subst.mk:class] Nothing changed in ./prepare-subst.mk.' \ + 'info: [subst.mk:class] Nothing changed in ./stderr.' \ + 'info: [subst.mk:class] Nothing changed in ./stdout.' \ + 'info: [subst.mk:class] Nothing changed in ./test.subr.main.mk.' + assert_that "stderr" --file-is-empty + assert_that "$exitcode" --equals "0" + + assert_that " !\"#\$%&'()*+,-." --file-is-lines "after" + assert_that "0123456789:;<=>?" --file-is-lines "after" + assert_that "@ABCDEFGHIJKLMNO" --file-is-lines "after" + assert_that "PQRSTUVWXYZ[\\]^_" --file-is-lines "after" + assert_that "\`abcdefghijklmno" --file-is-lines "after" + assert_that "pqrstuvwxyz{|}~" --file-is-lines "after" + assert_that "--no-option" --file-is-lines "after" + assert_that ".hidden" --file-is-lines "before" + + test_case_end +fi + +if test_case_begin "brackets in filename patterns"; then + + create_file "testcase.mk" < "$tmpdir/stdout" \ + 2> "$tmpdir/stderr" \ + && exitcode=0 || exitcode=$? + + assert_that "stdout" --file-is-lines \ + '=> Substituting "class" in *' \ + 'info: [subst.mk:class] Nothing changed in ./prepare-subst.mk.' \ + 'info: [subst.mk:class] Nothing changed in ./stderr.' \ + 'info: [subst.mk:class] Nothing changed in ./stdout.' \ + 'info: [subst.mk:class] Nothing changed in ./test.subr.main.mk.' + assert_that "stderr" --file-is-empty + assert_that "$exitcode" --equals "0" + + assert_that "any" --file-is-lines "before" + assert_that "x" --file-is-lines "before" + assert_that "*" --file-is-lines "after" + assert_that "[*]" --file-is-lines "before" + + test_case_end +fi Index: pkgsrc/regress/infra-unittests/test.subr diff -u pkgsrc/regress/infra-unittests/test.subr:1.3 pkgsrc/regress/infra-unittests/test.subr:1.4 --- pkgsrc/regress/infra-unittests/test.subr:1.3 Fri Mar 20 08:56:42 2020 +++ pkgsrc/regress/infra-unittests/test.subr Fri Mar 20 21:27:04 2020 @@ -1,5 +1,5 @@ #! /bin/sh -# $NetBSD: test.subr,v 1.3 2020/03/20 08:56:42 rillig Exp $ +# $NetBSD: test.subr,v 1.4 2020/03/20 21:27:04 rillig Exp $ set -eu # This file defines utilities for testing Makefile fragments in a mocked @@ -148,6 +148,7 @@ EOF } create_file() { + assert_that "$#" --equals 1 cat > "$tmpdir/$1" } @@ -230,6 +231,20 @@ assert_that() { diff -u "/dev/null" "$tmpdir/$1" 1>&2 || true ;; + (--file-is-lines) + _assert_that_tmp_actual="$tmpdir/$1" + _assert_that_tmp_expected="$tmpdir/$1" + _assert_that_filename="$1"; shift + + printf '%s\n' "$@" > "$_assert_that_tmp_expected" + if diff -u "$_assert_that_tmp_expected" "$_assert_that_tmp_actual" > /dev/null; then + assert_succeed + return 0 + fi + assert_fail 'file "%s" has unexpected content:\n' "$_assert_that_filename" + diff -u "$_assert_that_tmp_expected" "$_assert_that_tmp_actual" 1>&2 || true + ;; + (*) printf 'usage: assert_that --equals \n' 1>&2 exit 1 --_----------=_158473962436180--