All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: git@vger.kernel.org
Cc: "Junio C Hamano" <gitster@pobox.com>, "Jeff King" <peff@peff.net>,
	"Derrick Stolee" <derrickstolee@github.com>,
	"Taylor Blau" <me@ttaylorr.com>,
	"SZEDER Gábor" <szeder.dev@gmail.com>,
	"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Subject: [PATCH v3 0/2] test-lib.sh: have all tests pass under "-x", remove BASH_XTRACEFD
Date: Fri, 10 Dec 2021 11:07:53 +0100	[thread overview]
Message-ID: <cover-v3-0.2-00000000000-20211210T100512Z-avarab@gmail.com> (raw)
In-Reply-To: <cover-v2-0.2-00000000000-20211201T200801Z-avarab@gmail.com>

This re-roll fixes a stupid mistake of mine pointed out by SZEDER[1]
(thanks!): I was redirecting to "stderr" across function calls, but
some of those changed directories. Now we'll pass around an absolute
path from the top-level function.

That bug hid an issue where we'd include the trace output in that
stderr log still due to an interpolation of $(pwd), we can just change
that to $PWD, which won't have that issue.

1. https://lore.kernel.org/git/20211202192802.GC1991@szeder.dev/

Ævar Arnfjörð Bjarmason (2):
  t1510: remove need for "test_untraceable", retain coverage
  test-lib.sh: remove the now-unused "test_untraceable" facility

 t/README              |  3 --
 t/t1510-repo-setup.sh | 85 +++++++++++++++++++++----------------------
 t/test-lib.sh         | 66 ++++-----------------------------
 3 files changed, 49 insertions(+), 105 deletions(-)

Range-diff against v2:
1:  91402624777 ! 1:  7876202c5b0 t1510: remove need for "test_untraceable", retain coverage
    @@ Commit message
         use of "test_when_finished"), but the pattern enforces better test
         hygiene.
     
    +    The functions it calls might change directories, so we pass an
    +    absolute "$stderr_log_path" around. We also need to change a "$(pwd)"
    +    to "$PWD" in test_repo(), on e.g. "dash" that interpolation will be
    +    traced and part of the "2>>" redirection.
    +
    +    1. https://lore.kernel.org/git/YbMiK1wHzBfYvK2a@coredump.intra.peff.net/
    +
         Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
     
      ## t/t1510-repo-setup.sh ##
    @@ t/t1510-repo-setup.sh: test_repo () {
      		fi &&
      		rm -f trace &&
     -		GIT_TRACE_SETUP="$(pwd)/trace" git symbolic-ref HEAD >/dev/null &&
    -+		GIT_TRACE_SETUP="$(pwd)/trace" git symbolic-ref HEAD >/dev/null 2>>stderr &&
    ++		GIT_TRACE_SETUP="$PWD/trace" git symbolic-ref HEAD >/dev/null 2>>"$stderr_log_path" &&
      		grep '^setup: ' trace >result &&
      		test_cmp expected result
      	)
    @@ t/t1510-repo-setup.sh: maybe_config () {
      	if test "$value" != unset
      	then
     -		git config --file="$file" "$var" "$value"
    -+		git config --file="$file" "$var" "$value" 2>>stderr
    ++		git config --file="$file" "$var" "$value" 2>>"$stderr_log_path"
      	fi
      }
      
    @@ t/t1510-repo-setup.sh: setup_repo () {
      	sane_unset GIT_DIR GIT_WORK_TREE &&
      
     -	git -c init.defaultBranch=initial init "$name" &&
    -+	git -c init.defaultBranch=initial init "$name" 2>>stderr &&
    ++	git -c init.defaultBranch=initial init "$name" 2>>"$stderr_log_path" &&
      	maybe_config "$name/.git/config" core.worktree "$worktreecfg" &&
      	maybe_config "$name/.git/config" core.bare "$barecfg" &&
      	mkdir -p "$name/sub/sub" &&
    @@ t/t1510-repo-setup.sh: run_wt_tests () {
      #	(git dir) (work tree) (cwd) (prefix)	<-- from subdir
      try_repo () {
      	name=$1 worktreeenv=$2 gitdirenv=$3 &&
    -+	test_when_finished "rm stderr" &&
    ++	stderr_log_path="$PWD/stderr" &&
    ++
    ++	test_when_finished "rm \"$stderr_log_path\"" &&
      	setup_repo "$name" "$4" "$5" "$6" &&
      	shift 6 &&
      	try_case "$name" "$worktreeenv" "$gitdirenv" \
      		"$1" "$2" "$3" "$4" &&
    -+	test_must_be_empty stderr &&
    ++	test_must_be_empty "$stderr_log_path" &&
      	shift 4 &&
      	case "$gitdirenv" in
      	/* | ?:/* | unset) ;;
    @@ t/t1510-repo-setup.sh: try_repo () {
      	try_case "$name/sub" "$worktreeenv" "$gitdirenv" \
     -		"$1" "$2" "$3" "$4"
     +		"$1" "$2" "$3" "$4" &&
    -+	test_must_be_empty stderr
    ++	test_must_be_empty "$stderr_log_path"
      }
      
      # Bit 0 = GIT_WORK_TREE
2:  867d18d14bd = 2:  a7fc794e20d test-lib.sh: remove the now-unused "test_untraceable" facility
-- 
2.34.1.932.g36842105b61


  parent reply	other threads:[~2021-12-10 10:08 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-29 13:47 [PATCH 0/2] Set GIT_TRACE2_EVENT_NESTING in test-lib.sh Derrick Stolee via GitGitGadget
2021-11-29 13:47 ` [PATCH 1/2] test-lib.sh: set GIT_TRACE2_EVENT_NESTING Derrick Stolee via GitGitGadget
2021-11-29 14:12   ` Ævar Arnfjörð Bjarmason
2021-11-29 18:28     ` Junio C Hamano
2021-11-29 18:32     ` Junio C Hamano
2021-11-29 13:47 ` [PATCH 2/2] t/t*: remove custom GIT_TRACE2_EVENT_NESTING Derrick Stolee via GitGitGadget
2021-11-29 18:40 ` [PATCH 0/2] Set GIT_TRACE2_EVENT_NESTING in test-lib.sh Jeff King
2021-11-29 18:44   ` Jeff King
2021-11-30  0:04     ` Taylor Blau
2021-11-30 15:34   ` Derrick Stolee
2021-11-30 22:43     ` Jeff Hostetler
2021-12-01 19:46       ` Jeff King
2021-11-29 20:13 ` [PATCH] test-lib.sh: have all tests pass under "-x", remove BASH_XTRACEFD Ævar Arnfjörð Bjarmason
2021-11-29 23:23   ` Eric Sunshine
2021-11-30 21:08   ` Jeff King
2021-11-30 21:50     ` Ævar Arnfjörð Bjarmason
2021-11-30 22:44     ` SZEDER Gábor
2021-12-01 14:06       ` Ævar Arnfjörð Bjarmason
2021-12-01 19:38         ` Jeff King
2021-12-01 18:38   ` Junio C Hamano
2021-12-01 20:11   ` [PATCH v2 0/2] " Ævar Arnfjörð Bjarmason
2021-12-01 20:11     ` [PATCH v2 1/2] t1510: remove need for "test_untraceable", retain coverage Ævar Arnfjörð Bjarmason
2021-12-02 19:16       ` SZEDER Gábor
2021-12-02 19:28         ` SZEDER Gábor
2021-12-10  9:47         ` Jeff King
2021-12-10 10:08           ` Ævar Arnfjörð Bjarmason
2022-02-06 21:40           ` SZEDER Gábor
2021-12-01 20:11     ` [PATCH v2 2/2] test-lib.sh: remove the now-unused "test_untraceable" facility Ævar Arnfjörð Bjarmason
2021-12-10 10:07     ` Ævar Arnfjörð Bjarmason [this message]
2021-12-10 10:07       ` [PATCH v3 1/2] t1510: remove need for "test_untraceable", retain coverage Ævar Arnfjörð Bjarmason
2021-12-10 10:07       ` [PATCH v3 2/2] test-lib.sh: remove the now-unused "test_untraceable" facility Ævar Arnfjörð Bjarmason
2021-12-12 16:32         ` SZEDER Gábor
2021-12-12 17:06           ` Ævar Arnfjörð Bjarmason
2021-12-12 20:14             ` SZEDER Gábor
2021-12-13 18:51               ` Junio C Hamano
2021-12-14 16:43                 ` Jeff King
2021-12-15 17:05                   ` Junio C Hamano
2021-12-15 17:17                     ` Jeff King
2021-12-15 17:32                       ` Junio C Hamano
2021-12-16 13:04                         ` Ævar Arnfjörð Bjarmason
2021-12-13  1:38       ` [PATCH v4 0/3] test-lib.sh: have all tests pass under "-x", remove BASH_XTRACEFD Ævar Arnfjörð Bjarmason
2021-12-13  1:38         ` [PATCH v4 1/3] t1510: remove need for "test_untraceable", retain coverage Ævar Arnfjörð Bjarmason
2021-12-13  1:38         ` [PATCH v4 2/3] test-lib.sh: remove the now-unused "test_untraceable" facility Ævar Arnfjörð Bjarmason
2021-12-13  1:38         ` [PATCH v4 3/3] test-lib.sh: remove "BASH_XTRACEFD" Ævar Arnfjörð Bjarmason
2022-02-21 23:11           ` SZEDER Gábor
2022-02-22 15:14             ` Ævar Arnfjörð Bjarmason
2021-12-13  5:43         ` [PATCH v4 0/3] test-lib.sh: have all tests pass under "-x", remove BASH_XTRACEFD SZEDER Gábor
2022-02-21 19:52           ` Ævar Arnfjörð Bjarmason
2022-02-21 21:03             ` SZEDER Gábor
2022-02-21 22:41               ` Ævar Arnfjörð Bjarmason

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cover-v3-0.2-00000000000-20211210T100512Z-avarab@gmail.com \
    --to=avarab@gmail.com \
    --cc=derrickstolee@github.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=me@ttaylorr.com \
    --cc=peff@peff.net \
    --cc=szeder.dev@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.