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

Re: [PATCH 1/3] test-terminal: give the child an empty stdin TTY

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 12, 2011, 19:07 UTC
Message-ID
<7vfwgp4niu.fsf@alter.siamese.dyndns.org>
In-Reply-To
<b97d14da67bd6097e5b04f6ae3057c0f1d536a0b.1323713230.git.trast@student.ethz.ch>
Thomas Rast <trast@student.ethz.ch> writes:
Show 17 quoted lines
> So far, test-terminal.perl did not care at all about the stdin (that
> is, leave it as-is).  This mostly works well, but git-shortlog is a
> problem:
>
> * It takes decisions based on isatty(0).  (No test checks this, but
>   compare 'git shortlog </dev/null' with 'git shortlog' in a
>   terminal.)
>
> * It reads all of stdin if !isatty(0) and no arguments were passed.
>
> Because of the latter, t7006.58ff cause unexpected results if you do:
>
>   git rev-list <range> |
>   while read sha; do
>     git checkout sha
>     make test
>   done

In the above, lack of dollar-sign in "git checkout $sha" is obvious ;-) but I think it is a bug that you are not running make with its stdin redirected from /dev/null in the first place.

Perhaps "make test" should do that for all tests, not just this terminal related one? Doing it this way we do not have to worry about other tests reading from the standard input by mistake.

-- >8 --
Subject: Do not let the tests read from standard input stream
Consider running a loop like this:
   git rev-list <range> |
   while read commit
   do
	git checkout $commit && make test || break
   done

If any of the test reads from the standard input, we may end up running a test for just one commit (and while running the test for that commit, the remainder of the rev-list output is consumed by the test). A workaround would be to redirect like this:

    git checkout $commit && make test </dev/null || break
but the Makefile should be doing that for us instead.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 Makefile |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/Makefile b/Makefile
index ed82320..7a85237 100644
--- a/Makefile
+++ b/Makefile
@@ -2239,7 +2239,7 @@ export NO_SVN_TESTS
 ### Testing rules
 
 test: all
-	$(MAKE) -C t/ all
+	$(MAKE) -C t/ all </dev/null
 
 test-ctype$X: ctype.o
 
Previous: Junio C HamanoNext: Thomas Rast
Message 12 of 16 in “test-terminal: give the child an empty stdin TTY”
  1. 1/3 test-terminal: give the child an empty stdin TTYThomas Rast, Dec 12, 2011
  2. 2/3 test-terminal: set output terminals to raw modeThomas Rast, Dec 12, 2011
  3. Jonathan NiederDec 12, 2011
  4. Thomas RastDec 12, 2011
  5. Jonathan NiederDec 13, 2011
  6. 3/3 t/lib-terminal: test test-terminal's sanityThomas Rast, Dec 12, 2011
  7. Jonathan NiederDec 12, 2011
  8. Jonathan NiederDec 12, 2011
  9. Thomas RastDec 12, 2011
  10. Jonathan NiederDec 12, 2011
  11. Junio C HamanoDec 12, 2011
  12. Junio C HamanoDec 12, 2011
  13. Thomas RastDec 12, 2011
  14. Jeff KingDec 12, 2011
  15. Junio C HamanoDec 12, 2011
  16. Jonathan NiederDec 12, 2011

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.