git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Patrick Steinhardt <ps@pks.im>
Cc: Michael J Gruber <git@grubix.eu>,  git@vger.kernel.org
Subject: Re: [BUG/WIP PATCH] unit-tests: use clean test environment
Date: Fri, 28 Feb 2025 06:15:42 -0800	[thread overview]
Message-ID: <xmqqseny40kx.fsf@gitster.g> (raw)
In-Reply-To: <Z8GVAjwZWOM7c2fR@pks.im> (Patrick Steinhardt's message of "Fri, 28 Feb 2025 11:50:42 +0100")

Patrick Steinhardt <ps@pks.im> writes:

> This to me is the biggest issue with the chosen approach. It would be
> great if we could find a way to sanitize the environment in the unit
> test executable directly instead of forcing users to run the unit tests
> via the provided script.

True.  What the end-to-end tests do is to have a central place (in
test-lib.sh if I recall correctly) to ensure a sane environment and
have everybody run that before their own code.  In theory we should
be able to do the same in C (otherwise we wouldn't rewriting things
done in scripts to the language ;-)).

> I suspect that most environment variables shouldn't matter (for now), so
> overall the duplication may be acceptable:
>
>   - We need to unset a couple of variables, but we can probably reuse
>     logic `git rev-parse --local-env-vars`.
>
>   - We need to ask Git to not read the configuration, which we can do by
>     setting a couple of envvars. This should be manageable.

"Provide a controlled environment where Git pretends this is the
$HOME and that is the $AUTHOR_NAME and so on" is much more
preferrable than "Tell it not to read", no?

Thanks.

  reply	other threads:[~2025-02-28 14:15 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-25 20:48 [BUG/WIP PATCH] unit-tests: use clean test environment Michael J Gruber
2025-02-28 10:50 ` Patrick Steinhardt
2025-02-28 14:15   ` Junio C Hamano [this message]
2025-03-03 10:33     ` Patrick Steinhardt
2025-03-03 10:49       ` Michael J Gruber
2025-03-03 14:07       ` Junio C Hamano
2025-03-04  7:30         ` Jeff King
2025-03-04  7:39           ` Patrick Steinhardt
2025-03-04  8:33             ` Jeff King
2025-03-04 15:54               ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqseny40kx.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@grubix.eu \
    --cc=git@vger.kernel.org \
    --cc=ps@pks.im \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).