From: SZEDER Gábor Date: Tue, 15 Oct 2013 13:35:16 GMT Subject: on broken command chains in tests (was: Re: [PATCH] status: show commit sha1 in "You are currently) Message-ID: <20131015133516.GC26156@goldbirke> In-Reply-To: <20131011174210.GS9464@google.com> Hi, On Fri, Oct 11, 2013 at 10:42:10AM -0700, Jonathan Nieder wrote: > -- >8 -- > Subject: status test: add missing && to < > When a test forgets to include && after each command, it is possible > for an early command to succeed but the test to fail, which can hide > bugs. Surely you meant "succeed" and "fail" the other way around :) > Checked using the following patch to the test harness: > > --- a/t/test-lib.sh > +++ b/t/test-lib.sh > @@ -425,7 +425,17 @@ test_eval_ () { > eval &3 2>&4 "$*" > } > > +check_command_chaining_ () { > + eval >&3 2>&4 "(exit 189) && $*" > + eval_chain_ret=$? > + if test "$eval_chain_ret" != 189 > + then > + error 'bug in test script: missing "&&" in test commands' > + fi > +} > + > test_run_ () { > + check_command_chaining_ "$1" > test_cleanup=: > expecting_failure=$2 > setup_malloc_check Clever. If I do a - error 'bug in test script: missing "&&" in test commands' + say_color error 'error: bug in test script: missing "&&" in test commands' to avoid erroring out and skipping the rest of the test script on the first broken command chain, then we can see that we have a lot of broken command chains in the test suite: $ for t in t[0-9][0-9][0-9][0-9]*.sh ; do ./$t ; done |grep -c '^error:.*missing "&&" in test commands$' 345 After a cursory look most of them seem to be the simple "missing &&" type, but there are some funny ones, too. Gábor