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

Re: [PATCH] t9902: protect test from stray build artifacts

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 25, 2013, 04:19 UTC
Message-ID
<7vr4l97v3h.fsf@alter.siamese.dyndns.org>
In-Reply-To
<7vvcal7vhg.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
Show 22 quoted lines
> Jeff King <peff@peff.net> writes:
>
>> This looks good to me.
>>
>> The only thing I might add is a test just to double-check that "git help
>> -a" is parsed correctly. Like:
>>
>>   test_expect_success 'command completion works without test harness' '
>>            GIT_TESTING_COMMAND_COMPLETION= run_completion "git bun" &&
>>            grep "^bundle\$" out
>>   '
>>
>> (we know we are running bash here, so the one-shot variable is OK to be
>> used with a function).
>
> I think you meant "^bundle $" there, but don't we have the same
> problem when there is an end-user subcommand "git bunny"?
>
> Ahh, ok, we show one element per line and just make sure "bundle"
> is there, and we do not care what other buns appear in the output.
>
> Will squash in, then.

Not so quick, though. The lower level "read from help -a" is only run once and its output kept in a two-level cache hierarchy; we need to reset both.

It starts to look a bit too intimately tied to the implementation of what is being tested for my taste, though.

 t/t9902-completion.sh | 10 ++++++++++
 1 file changed, 10 insertions(+)
diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
index adc1372..bb6ee1a 100755
--- a/t/t9902-completion.sh
+++ b/t/t9902-completion.sh
@@ -286,4 +286,14 @@ test_expect_success 'send-email' '
 	test_completion "git send-email ma" "master "
 '
 
+# This is better to be at the end, as it resets the state by tweaking
+# the internals.
+test_expect_success 'help -a read correctly by command list generator' '
+	__git_all_commands= &&
+	__git_porcelain_commands= &&
+	GIT_TESTING_COMMAND_COMPLETION= &&
+	run_completion "git bun" &&
+	grep "^bundle $" out
+'
+
 test_done
-- 
1.8.1.1.525.gdace530
Previous: Jeff KingNext: Jeff King
Message 12 of 15 in “[RFC] Instruct git-completion.bash that we are in test mode”
  1. Jean-Noël AVILAJan 21, 2013
  2. Junio C HamanoJan 21, 2013
  3. Jeff KingJan 22, 2013
  4. Junio C HamanoJan 22, 2013
  5. Jean-Noël AvilaJan 22, 2013
  6. Junio C HamanoJan 22, 2013
  7. t9902: protect test from stray build artifactsJunio C Hamano, Jan 24, 2013
  8. Jeff KingJan 25, 2013
  9. Jonathan NiederJan 25, 2013
  10. Junio C HamanoJan 25, 2013
  11. Jeff KingJan 25, 2013
  12. Junio C HamanoJan 25, 2013
  13. Jeff KingJan 25, 2013
  14. Junio C HamanoJan 25, 2013
  15. Jeff KingJan 25, 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.