git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Ramkumar Ramachandra <artagnon@gmail.com>
Cc: Andreas Schwab <schwab@linux-m68k.org>, Jeff King <peff@peff.net>,
	Git List <git@vger.kernel.org>
Subject: Re: [PATCH] t/test-lib.sh: do not trust $SHELL
Date: Sat, 22 Sep 2012 13:16:57 -0700	[thread overview]
Message-ID: <7vobkx3j9i.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <CALkWK0kWJ3ndEMGzyGGMEa+ko3BTShC7_o-HVsXzFCGwRem5Jw@mail.gmail.com> (Ramkumar Ramachandra's message of "Sat, 22 Sep 2012 10:27:01 +0530")

Ramkumar Ramachandra <artagnon@gmail.com> writes:

> Here's a patch.
>
> -- 8< --
> From: Ramkumar Ramachandra <artagnon@gmail.com>
> Date: Sat, 22 Sep 2012 10:25:10 +0530
> Subject: [PATCH] test-lib: do not trust $SHELL
>
> Do not trust $SHELL to be a bourne-compatible shell.  Instead, use the
> Makefile variable $SHELL_PATH.  This fixes a bug: when a test was run
> with --tee and $SHELL was set to ZSH, $PATH on line 479 was not
> getting split due to ZSH not respecting $IFS.
>
> Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
> ---

The part that this starts letting run, which the original "Re-run
the command under tee as early as possible" wanted to avoid running,
does not affect anything that would affect how we run that tee magic
(e.g. "mkdir -p test-results" will still create it directly inside
the directory the test script was started in), so I think this patch
is safe _for now_.

However, it forces people who need to update earlier parts of this
script to be extra careful; it has been true before the patch, and
the patch makes it even more so.

I am not opposed to queuing this as an interim solution, but I
wonder if we can get rid of that double-launch altogether.

Instead of re-launching the script with its output piped to "tee",
can't we do the same by redirecting our standard output to the file
in the file, and spawn a "tail -f" that reads from the file and
outputs to our original output?  Something along the lines of:

        mkdir -p test-results
        tee_base=test-results/$(basename "$0" .sh)

        # empty the file and start "tail -f" on it ...
        : >"$tee_base.out"
        ( tail -f "$tee_base.out" ) &
        tee_pid=$!
	trap 'kill $tee_pid; exit' 0 1 2 3
	# ... and then redirect our output to it
        exec >"$tee_base.out"

and wrap it in a shell helper function that is called from where the
parsing of the command line arguments for "--tee" happens, and don't
forget to kill $tee_pid when we exit.

Hrm?

  reply	other threads:[~2012-09-22 20:17 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-17 17:01 How do I run tests under Valgrind? Ramkumar Ramachandra
2012-09-17 17:20 ` Jeff King
2012-09-17 17:23   ` Ramkumar Ramachandra
2012-09-17 17:35     ` Jeff King
2012-09-17 17:39       ` Ramkumar Ramachandra
2012-09-17 17:44         ` Jeff King
2012-09-17 17:55           ` Johannes Sixt
2012-09-17 17:57             ` Jeff King
2012-09-17 18:28           ` Ramkumar Ramachandra
     [not found]           ` <CALkWK0mkBbY7dUyaZAqqKE3ZMfE_xU6em_KCOKM9nsTjUP-9pA@mail.gmail.com>
2012-09-17 18:29             ` Jeff King
2012-09-21 19:31               ` Ramkumar Ramachandra
2012-09-21 19:58                 ` Ramkumar Ramachandra
2012-09-21 20:13                   ` Stefano Lattarini
2012-09-21 20:17                     ` Ramkumar Ramachandra
2012-09-21 20:46                       ` Ramkumar Ramachandra
2012-09-21 20:49                     ` Jeff King
2012-09-22 13:03                       ` Stefano Lattarini
2012-09-22 17:47                         ` Jeff King
2012-09-22 18:20                           ` Stefano Lattarini
2012-09-22 20:24                           ` Junio C Hamano
2012-09-21 20:52                     ` [PATCH] t/test-lib.sh: do not trust $SHELL Ramkumar Ramachandra
2012-09-21 20:58                       ` Jeff King
2012-09-21 21:07                         ` Ramkumar Ramachandra
2012-09-21 21:12                           ` Jeff King
2012-09-21 21:34                             ` Ramkumar Ramachandra
2012-09-21 21:57                               ` Andreas Schwab
2012-09-21 22:30                                 ` Junio C Hamano
2012-09-22  4:26                                   ` Ramkumar Ramachandra
2012-09-22  4:52                                     ` Junio C Hamano
2012-09-22  4:54                                       ` Ramkumar Ramachandra
2012-09-22  4:57                                         ` Ramkumar Ramachandra
2012-09-22 20:16                                           ` Junio C Hamano [this message]
2012-09-26  3:49                                             ` Ramkumar Ramachandra
2012-09-21 21:59                               ` Junio C Hamano
2012-09-21 22:15                               ` Jeff King
2012-09-21 21:08                         ` Andreas Schwab
2012-09-21 21:13                           ` Jeff King

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=7vobkx3j9i.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=artagnon@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=peff@peff.net \
    --cc=schwab@linux-m68k.org \
    /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 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 NNTP newsgroup(s).