diff options
author | Jeff King <peff@peff.net> | 2011-12-15 01:55:29 -0500 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2011-12-15 10:15:07 -0800 |
commit | 781f76b15824bb929b6f3f007d8e43894e4980cd (patch) | |
tree | 5873470b30878d48656d8a0d5e96f3cef0651069 /git-rebase--interactive.sh | |
parent | Git 1.7.7 (diff) | |
download | tgif-781f76b15824bb929b6f3f007d8e43894e4980cd.tar.xz |
test-lib: redirect stdin of tests
We want to run tests in a predictable, sterile environment
so we can get repeatable results. They should take as
little input as possible from the environment outside the
test script. We already sanitize environment variables, but
leave stdin untouched. This means that scripts can
accidentally be impacted by content on stdin, or whether
stdin isatty().
Furthermore, scripts reading from stdin can be annoying to
outer loops which care about their stdin offset, like:
while read sha1; do
make test
done
A test which accidentally reads stdin would soak up all of
the rest of the input intended for the outer shell loop.
Let's redirect stdin from /dev/null, which solves both
of these problems. It won't detect tests accidentally
reading from stdin, but since doing so now gives a
deterministic result, we don't need to consider that an
error.
We'll also leave file descriptor 6 as a link to the original
stdin. Tests shouldn't need to look at this, but it can be
convenient for inserting interactive commands while
debugging tests (e.g., you could insert "bash <&6 >&3 2>&4"
to run interactive commands in the environment of the test
script).
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-rebase--interactive.sh')
0 files changed, 0 insertions, 0 deletions