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

Re: [PATCH] t5310-pack-bitmaps: fix bogus 'pack-objects to file can use bitmap' test

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 17, 2018, 20:09 UTC
Message-ID
<xmqq4lfsbvru.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<eeb04c94-50c1-13ee-880b-ea380031a685@gmail.com>
Andrei Rybak <rybak.a.v@gmail.com> writes:
Show 8 quoted lines
> I think it would be a good trade-off to allow these helper functions to skip
> checking emptiness of arguments for test_cmp. Such patch will require only
> s/test_cmp/&_allow_empty/ for these helper functions and it will help catch
> cases as bogus test in t5310.
>
> I'll try something like the following on the weekend:
>
> 	test_cmp() {
Style: SP before and after ().
Show 12 quoted lines
> 		if test "$1" != - && ! test -s "$1"
> 		then
> 			echo >&4 "error: trying to compare empty file '$1'"
> 			return 1
> 		fi
> 		if test "$2" != - && ! test -s "$2"
> 		then
> 			echo >&4 "error: trying to compare empty file '$2'"
> 			return 1
> 		fi
> 		test_cmp_allow_empty "$@"
> 	}

I actually think the above gives way too confusing output, when the actual output is empty and we are expecting some output. I.e.

	: >expect &&
	git cmd >actual &&
	test_cmp expect actual

The tester wants to hear from test_cmp "your 'git cmd' produced some output when we are expecting none" as the primary message. We are trying to find bugs in "git" under development, and diagnosing iffy tests is secondary. But with your change, the first thing that is checked is if 'expect' is an empty file and that is what we get complaints about, without even looking at what is in 'actual'.

It's the same story, and it is even worse than the above, when we are expecting some output but the command produced no output, i.e.

	echo Everything up-to-date. >expect &&
	git cmd >actual &&
	test_cmp expect actual

We should get a complaint from test_cmp that 'actual' does not match the string we were expecting (and even better, we show how they are different by running them thru "diff -u"), not that 'actual' is an empty file.

Show 6 quoted lines
> 	test_cmp_allow_empty() {
> 		$GIT_TEST_CMP "$@"
> 	}
>
> (I'm not sure about redirections in test lib functions. The two if's would
> probably be in a separate function to be re-used by test_i18ncmp.)
Previous: Andrei RybakNext: Andrei Rybak
Message 7 of 17 in “t5310-pack-bitmaps: fix bogus 'pack-objects to file can use bitmap' test”
  1. t5310-pack-bitmaps: fix bogus 'pack-objects to file can use bitmap' testSZEDER Gábor, Aug 14, 2018
  2. Jeff KingAug 14, 2018
  3. Andrei RybakAug 16, 2018
  4. Junio C HamanoAug 16, 2018
  5. SZEDER GáborAug 17, 2018
  6. Andrei RybakAug 17, 2018
  7. Junio C HamanoAug 17, 2018
  8. Andrei RybakAug 19, 2018
  9. Jeff KingAug 19, 2018
  10. Andrei RybakAug 19, 2018
  11. Jeff KingAug 19, 2018
  12. Junio C HamanoAug 21, 2018
  13. SZEDER GáborAug 17, 2018
  14. Matthew DeVoreAug 22, 2018
  15. Kirill SmelkovAug 27, 2018
  16. Jeff KingAug 27, 2018
  17. Kirill SmelkovAug 28, 2018

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.