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

Re: [PATCH] t/test-lib.sh: do not trust $SHELL

From
Ramkumar Ramachandra <artagnon@gmail.com>
Date
Sep 26, 2012, 03:49 UTC
Message-ID
<CALkWK0=1Bep0gBJAQQefDiZ7LMkXqXt91jPkgYkac0QkMBgOGw@mail.gmail.com>
In-Reply-To
<7vobkx3j9i.fsf@alter.siamese.dyndns.org>
Hi Junio,
Junio C Hamano wrote:
Show 30 quoted lines
> Ramkumar Ramachandra <artagnon@gmail.com> writes:
>
>> Here's a patch.
>>
>> -- 8< --
>> From: Ramkumar Ramachandra <artagnon@gmail.com>
>> Date: Sat, 22 Sep 2012 10:25:10 +0530
>> Subject: [PATCH] test-lib: do not trust $SHELL
>>
>> Do not trust $SHELL to be a bourne-compatible shell.  Instead, use the
>> Makefile variable $SHELL_PATH.  This fixes a bug: when a test was run
>> with --tee and $SHELL was set to ZSH, $PATH on line 479 was not
>> getting split due to ZSH not respecting $IFS.
>>
>> Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
>> ---
>
> The part that this starts letting run, which the original "Re-run
> the command under tee as early as possible" wanted to avoid running,
> does not affect anything that would affect how we run that tee magic
> (e.g. "mkdir -p test-results" will still create it directly inside
> the directory the test script was started in), so I think this patch
> is safe _for now_.
>
> However, it forces people who need to update earlier parts of this
> script to be extra careful; it has been true before the patch, and
> the patch makes it even more so.
>
> I am not opposed to queuing this as an interim solution, but I
> wonder if we can get rid of that double-launch altogether.
I see you've queued it in `pu` after rewriting the commit message.
Show 21 quoted lines
> Instead of re-launching the script with its output piped to "tee",
> can't we do the same by redirecting our standard output to the file
> in the file, and spawn a "tail -f" that reads from the file and
> outputs to our original output?  Something along the lines of:
>
>         mkdir -p test-results
>         tee_base=test-results/$(basename "$0" .sh)
>
>         # empty the file and start "tail -f" on it ...
>         : >"$tee_base.out"
>         ( tail -f "$tee_base.out" ) &
>         tee_pid=$!
>         trap 'kill $tee_pid; exit' 0 1 2 3
>         # ... and then redirect our output to it
>         exec >"$tee_base.out"
>
> and wrap it in a shell helper function that is called from where the
> parsing of the command line arguments for "--tee" happens, and don't
> forget to kill $tee_pid when we exit.
>
> Hrm?

Good idea. I'll write a patch to do this once the interim solution graduates to `master`.

Ram
Previous: Junio C HamanoNext: Junio C Hamano
Message 33 of 37 in “How do I run tests under Valgrind?”
  1. Ramkumar RamachandraSep 17, 2012
  2. Jeff KingSep 17, 2012
  3. Ramkumar RamachandraSep 17, 2012
  4. Jeff KingSep 17, 2012
  5. Ramkumar RamachandraSep 17, 2012
  6. Jeff KingSep 17, 2012
  7. Johannes SixtSep 17, 2012
  8. Jeff KingSep 17, 2012
  9. Ramkumar RamachandraSep 17, 2012
  10. Jeff KingSep 17, 2012
  11. Ramkumar RamachandraSep 21, 2012
  12. Ramkumar RamachandraSep 21, 2012
  13. Stefano LattariniSep 21, 2012
  14. Ramkumar RamachandraSep 21, 2012
  15. Ramkumar RamachandraSep 21, 2012
  16. Jeff KingSep 21, 2012
  17. Stefano LattariniSep 22, 2012
  18. Jeff KingSep 22, 2012
  19. Stefano LattariniSep 22, 2012
  20. Junio C HamanoSep 22, 2012
  21. t/test-lib.sh: do not trust $SHELLRamkumar Ramachandra, Sep 21, 2012
  22. Jeff KingSep 21, 2012
  23. Ramkumar RamachandraSep 21, 2012
  24. Jeff KingSep 21, 2012
  25. Ramkumar RamachandraSep 21, 2012
  26. Andreas SchwabSep 21, 2012
  27. Junio C HamanoSep 21, 2012
  28. Ramkumar RamachandraSep 22, 2012
  29. Junio C HamanoSep 22, 2012
  30. Ramkumar RamachandraSep 22, 2012
  31. Ramkumar RamachandraSep 22, 2012
  32. Junio C HamanoSep 22, 2012
  33. Ramkumar RamachandraSep 26, 2012
  34. Junio C HamanoSep 21, 2012
  35. Jeff KingSep 21, 2012
  36. Andreas SchwabSep 21, 2012
  37. Jeff KingSep 21, 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.