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

Re: [PATCH] squash! tests: fix overeager scrubbing of environment variables

From
Jeff King <peff@peff.net>
Date
Mar 28, 2011, 13:58 UTC
Message-ID
<20110328135803.GA14763@sigill.intra.peff.net>
In-Reply-To
<20110327221753.GB27445@elie>
On Sun, Mar 27, 2011 at 05:17:53PM -0500, Jonathan Nieder wrote:
Show 26 quoted lines
> How about something like this on top?  Would it still be safe on
> platforms with ancient perl?
> 
> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
> ---
>  t/test-lib.sh |   10 +++++++++-
>  1 files changed, 9 insertions(+), 1 deletions(-)
> 
> diff --git a/t/test-lib.sh b/t/test-lib.sh
> index 4a8c443..d28e647 100644
> --- a/t/test-lib.sh
> +++ b/t/test-lib.sh
> @@ -46,7 +46,15 @@ unset VISUAL
>  unset EMAIL
>  unset $(perl -e '
>  	my @env = keys %ENV;
> -	my @vars = grep(/^GIT_/ && !/^GIT_(TRACE|DEBUG|USE_LOOKUP|SKIP_TESTS|TEST|PROVE_OPTS)/, @env);
> +	my @vars = grep(/^GIT_/ && !m{^GIT_(
> +			TRACE |
> +			DEBUG |
> +			USE_LOOKUP |
> +			TEST |
> +			.*_TEST |
> +			PROVE |
> +			VALGRIND
> +		)}x, @env);

I think that should be fine. The most exotic thing you use is /x. I don't know when it was introduced, but perl5004delta refers to it as something that was already around before then.

I think it might be a little more readable to get rid of the "|" on each line like this:

    my $ok = join("|", qw(
      TRACE
      DEBUG
      USE_LOOKUP
      TEST
      .*_TEST
      PROVE
      VALGRIND
    ));
    my @vars = grep(/^GIT_/ && !/^GIT_($ok)/o) @env;

which is a little simpler syntax, and makes patches nicer (you don't have to add a trailing "|" on the line before). But that is a minor nit.

-Peff
Previous: Jonathan NiederNext: Jens Lehmann
Message 4 of 10 in “tests: fix overeager scrubbing of environment variables”
  1. tests: fix overeager scrubbing of environment variablesJens Lehmann, Mar 27, 2011
  2. Jonathan NiederMar 27, 2011
  3. squash! tests: fix overeager scrubbing of environment variablesJonathan Nieder, Mar 27, 2011
  4. Jeff KingMar 28, 2011
  5. tests: fix overeager scrubbing of environment variablesJens Lehmann, Mar 27, 2011
  6. tests: use the --long-tests facility to toggle some slow testsJonathan Nieder, Mar 27, 2011
  7. Junio C HamanoMar 28, 2011
  8. tests: fix overeager scrubbing of environment variablesJens Lehmann, Mar 28, 2011
  9. Jonathan NiederMar 28, 2011
  10. Junio C HamanoMar 28, 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.