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

Re: [RFC/PATCH] tests: add initial bash completion tests

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 6, 2012, 22:46 UTC
Message-ID
<7vk41szdev.fsf@alter.siamese.dyndns.org>
In-Reply-To
<CAMP44s0VWWuM6eeij_nys9OAqu6Jr87Wv4K56mbbqhuMbVXKaQ@mail.gmail.com>
Felipe Contreras <felipe.contreras@gmail.com> writes:
Show 10 quoted lines
> On Sat, Apr 7, 2012 at 12:34 AM, Jeff King <peff@peff.net> wrote:
>
>> But my point still stands that you cannot assume that you are running
>> bash, and you need to either find bash, or gracefully exit the test
>> script if it is not available. Anything else will cause "make test" to
>> fail on some systems (and indeed, applying and running your test, it
>> breaks "make test" on my debian box with dash as /bin/sh).
>
> So? 'make test' fails on my Arch Linux box which doesn't have
> /usr/bin/python, which is presumably why there is NO_PYTHON.

If you "git grep NO_PYTHON", you would notice that t/test-lib.sh does have a provision to set PYTHON prerequisite, so fixing it presumably is just the matter of marking appropriate tests with the prerequisite, no? Which ones are broken for you? Complaining about it in a thread that does not directly related to that "on a box without python some tests are broken" issue is a very good way to leave it unfixed.

> Instead
> of doing some nasty hacks such as 'bash <<\END_OF_BASH_SCRIPT', it
> would be much easier to have a NO_BASH option. And in fact, when zsh
> completion tests are available, NO_ZSH (probably on by default).

"The box does not have bash" and "The builder does not wish to let the scripts run with bash" are two separate things. SHELL_PATH is often set to /bin/dash even on a box that has /bin/bash because it is much faster to run scripted Porcelains with, but the end user of the resulting build may still want to use bash in her interactive session.

For this "the rest of the script is all meant to test stuff written for bash" test, I think the right approach is to explicitly detect the presense of bash (i.e. "Can the end user run bash for her interactive session? Otherwise we cannot test and there is no point testing"), and feed these tests explicitly to bash. Perhaps by putting your bash specific test in t/t9902/bash-completion-test.bash and calling it from the t9902-completionl.sh script that is meant to be run with $SHELL_PATH, like this:

== t/t9902-completion.sh == #!/bin/sh

. ./test-lib.sh
if bash is available ;# do *not* check if we are running under bash!!
then
	bash "$TEST_DIRECTORY/t9902/bash-comletion-test.bash"
fi
if zsh is available ;# do *not* check if we are running under zsh!!
then
	zsh "$TEST_DIRECTORY/t9902/zsh-comletion-test.zsh"
fi
test_done
Previous: Felipe ContrerasNext: Felipe Contreras
Message 11 of 18 in “tests: add initial bash completion tests”
  1. tests: add initial bash completion testsFelipe Contreras, Apr 6, 2012
  2. Jeff KingApr 6, 2012
  3. Junio C HamanoApr 6, 2012
  4. Felipe ContrerasApr 6, 2012
  5. Jeff KingApr 6, 2012
  6. Felipe ContrerasApr 6, 2012
  7. Junio C HamanoApr 6, 2012
  8. Felipe ContrerasApr 6, 2012
  9. Jeff KingApr 6, 2012
  10. Felipe ContrerasApr 6, 2012
  11. Junio C HamanoApr 6, 2012
  12. Felipe ContrerasApr 6, 2012
  13. Jeff KingApr 6, 2012
  14. Felipe ContrerasApr 6, 2012
  15. Junio C HamanoApr 6, 2012
  16. Junio C HamanoApr 6, 2012
  17. Felipe ContrerasApr 7, 2012
  18. Jeff KingApr 6, 2012

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.