git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "SZEDER Gábor" <szeder@ira.uka.de>
To: Jonathan Nieder <jrnieder@gmail.com>
Cc: "Ralf Thielow" <ralf.thielow@gmail.com>,
	git@vger.kernel.org, gitster@pobox.com, Matthieu.Moy@imag.fr,
	"Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: on broken command chains in tests (was: Re: [PATCH] status: show commit sha1 in "You are currently)
Date: Tue, 15 Oct 2013 15:35:16 +0200	[thread overview]
Message-ID: <20131015133516.GC26156@goldbirke> (raw)
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 <<EOF blocks
> 
> 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 </dev/null >&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

      parent reply	other threads:[~2013-10-15 13:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-11 15:58 [PATCH] status: show commit sha1 in "You are currently cherry-picking" message Ralf Thielow
2013-10-11 16:03 ` Matthieu Moy
2013-10-11 17:42 ` Jonathan Nieder
2013-10-11 18:14   ` Ralf Thielow
2013-10-15 13:35   ` SZEDER Gábor [this message]

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=20131015133516.GC26156@goldbirke \
    --to=szeder@ira.uka.de \
    --cc=Matthieu.Moy@imag.fr \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jrnieder@gmail.com \
    --cc=pclouds@gmail.com \
    --cc=ralf.thielow@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 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).