git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: "SZEDER Gábor" <szeder.dev@gmail.com>
Cc: git@vger.kernel.org, Denton Liu <liu.denton@gmail.com>
Subject: Re: [PATCH 1/2] tests: don't mess with fd 7 of test helper functions
Date: Sun, 21 Feb 2021 16:50:42 -0500	[thread overview]
Message-ID: <YDLVsjumwSXgEU7k@coredump.intra.peff.net> (raw)
In-Reply-To: <20210221192512.3096291-1-szeder.dev@gmail.com>

On Sun, Feb 21, 2021 at 08:25:11PM +0100, SZEDER Gábor wrote:

> The root of the issue stems from a5bf824f3b (t: prevent '-x' tracing
> from interfering with test helpers' stderr, 2018-02-25), where we
> started to use a couple of file descriptor duplications and
> redirections to separate the standard error of git commands exercised
> in test helper functions from the stderr containing the '-x' trace
> output of said helper functions.  To achieve that the git command's
> stderr is redirected to the test helper function's fd 7, which was
> previously duplicated from the helper's stderr.  Alas, fd 7 was not
> the right choice for this purpose, because fd 7 is the original
> standard error of the test script, and, consequently, we now can't
> send error messages from within such test helper functions directly to
> the test script's stderr.  Since BUG() does want to send its error
> message there it doesn't work as expected in such test helper
> functions, because:
> 
>   - If the test helper's stderr were redirected to a file (as is often
>     the case e.g. with 'test_must_fail'), then the "bug in the test
>     script" error message would end up in that file.
> 
>   - If the test script is invoked without any of the verbose options,
>     then that error message would get lost to /dev/null, leaving no
>     clues about why the test script aborted so suddenly.

Makes sense. Well explained.

> Use fd 6 instead of fd 7 for these '-x' tracing related duplications
> and redirections.  It is a better choice for this purpose, because fd
> 6 is the test script's original standard input, and neither these test
> helper functions not the git commands exercised by them should ever
> read from the test scipt's stdin, see 781f76b158 (test-lib: redirect
> stdin of tests, 2011-12-15).  Update the aforementioned error
> reporting in 'test_must_fail' to send the error message to fd 6 as
> well; the next patch will update it to use BUG() instead.

s/scipt/script/ in the paragraph above.

I agree that 6 is probably reasonable. I wonder if it is worth having a
master comment describing the function of various descriptors within the
test suite, so that people know which ones are available for which
purposes.  It is getting awfully crowded in that space. Sadly, I don't
think we can portably use numbers higher than 9 (bash is happy to, but
even dash cannot).

Of course people would have to know to look for said comment, which they
may not do. :)

-Peff

  parent reply	other threads:[~2021-02-21 21:53 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-21 19:25 [PATCH 1/2] tests: don't mess with fd 7 of test helper functions SZEDER Gábor
2021-02-21 19:25 ` [PATCH 2/2] test-lib-functions: use BUG() in 'test_must_fail' SZEDER Gábor
2021-02-21 21:58   ` Jeff King
2021-02-22 19:11     ` Jeff King
2021-02-22 19:17       ` Jeff King
2021-02-22 20:02         ` Junio C Hamano
2021-02-21 21:50 ` Jeff King [this message]
2021-02-22 17:45   ` [PATCH 1/2] tests: don't mess with fd 7 of test helper functions Junio C Hamano

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=YDLVsjumwSXgEU7k@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=liu.denton@gmail.com \
    --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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).