git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Eric Sunshine <sunshine@sunshineco.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, Derrick Stolee <stolee@gmail.com>
Subject: Re: [PATCH] do not set GIT_TEST_MAINT_SCHEDULER where it does not matter
Date: Thu, 28 Mar 2024 22:43:48 -0400	[thread overview]
Message-ID: <CAPig+cStHRX-wZKwdcO33wCjd4UU3MO-rVisyOFZ1vPbGaN51Q@mail.gmail.com> (raw)
In-Reply-To: <xmqqmsqhsvwk.fsf@gitster.g>

On Thu, Mar 28, 2024 at 8:51 PM Junio C Hamano <gitster@pobox.com> wrote:
> 31345d55 (maintenance: extract platform-specific scheduling,
> 2020-11-24) added code to t/test-lib.sh for everybody to set
> GIT_TEST_MAINT_SCHEDULER to a "safe" value and instructed the test
> writers to set the variable locally when their test wants to check
> the scheduler integration.
>
> But it did so without "export GIT_TEST_MAINT_SCHEDULER", so the
> setting does not seem to have any effect anyway.  Instead of setting
> it to a "safe" value, just unset it.

I agree that the missing `export` makes this a do-nothing assignment.
In fact, that problem traces back to the original 2fec604f8d
(maintenance: add start/stop subcommands, 2020-09-11).

> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> ---
> diff --git c/t/test-lib.sh w/t/test-lib.sh
> @@ -1959,9 +1959,9 @@ test_lazy_prereq DEFAULT_REPO_FORMAT '
>  # Ensure that no test accidentally triggers a Git command
>  # that runs the actual maintenance scheduler, affecting a user's
>  # system permanently.
> -# Tests that verify the scheduler integration must set this locally
> -# to avoid errors.
> -GIT_TEST_MAINT_SCHEDULER="none:exit 1"
> +# Tests that verify the scheduler integration must set and
> +# export this variable locally.
> +sane_unset GIT_TEST_MAINT_SCHEDULER

Clearly the idea was to protect the scheduler-configuration of the
person running the test in the event that the test author forgot to
set GIT_TEST_MAINT_SCHEDULER to one of the legitimate "testing values"
before invoking a "destructive" command, such as `git maintenance
start`. By defaulting to `none:exit 1`, the problem would be caught
and reported before any damage could be done to the configuration of
the person running the tests.

So, I'm somewhat skeptical of the new direction of simply unsetting
GIT_TEST_MAINT_SCHEDULER since that outright removes the intended
protection. I'd have expected this problem to be addressed by
exporting GIT_TEST_MAINT_SCHEDULER, not by making it easier for an
absent-minded test author to break his or her own configuration.

Having said that, it you do want to go the route of eliminating the
(intended) protection altogether, I have a couple additional
observations:

First, this change requires a corresponding update to the lead-in
comment ("Ensure that no test accidentally triggers a Git command that
runs the actual maintenance scheduler, affecting a user's system
permanently.") since it renders that comment incorrect.

Second, it seems very unlikely that GIT_TEST_MAINT_SCHEDULER will be
set in the user's environment anyhow before running the tests, so
unsetting it here seems unnecessary and pointless. Instead, a cleaner
approach would be to simply remove the entire hunk in t/test-lib.sh
dealing with GIT_TEST_MAINT_SCHEDULER, including the comment.


  reply	other threads:[~2024-03-29  2:44 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-29  0:51 [PATCH] do not set GIT_TEST_MAINT_SCHEDULER where it does not matter Junio C Hamano
2024-03-29  2:43 ` Eric Sunshine [this message]
2024-03-29  5:38   ` Junio C Hamano
2024-03-29 22:27 ` [PATCH] test-lib: fix non-functioning GIT_TEST_MAINT_SCHEDULER fallback Eric Sunshine
2024-03-31  6:51   ` Eric Sunshine

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=CAPig+cStHRX-wZKwdcO33wCjd4UU3MO-rVisyOFZ1vPbGaN51Q@mail.gmail.com \
    --to=sunshine@sunshineco.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=stolee@gmail.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).