git/list[1] front-page[2] threads[3] people[4] search[5] about
 

on broken command chains in tests (was: Re: [PATCH] status: show commit sha1 in "You are currently)

From
SZEDER Gábor <szeder@ira.uka.de>
Date
Oct 15, 2013, 13:35 UTC
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:
Show 6 quoted lines
> -- >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 :)
Show 22 quoted lines
> 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
Previous: Ralf Thielow
Message 5 of 5 in “status: show commit sha1 in "You are currently cherry-picking" message”
  1. status: show commit sha1 in "You are currently cherry-picking" messageRalf Thielow, Oct 11, 2013
  2. Matthieu MoyOct 11, 2013
  3. Jonathan NiederOct 11, 2013
  4. Ralf ThielowOct 11, 2013
  5. on broken command chains in tests (was: Re: [PATCH] status: show commit sha1 in "You are currently)SZEDER Gábor, Oct 15, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.