diff mbox series

test-lib: fix non-functioning GIT_TEST_MAINT_SCHEDULER fallback

Message ID 20240329222703.9343-1-ericsunshine@charter.net (mailing list archive)
State Accepted
Commit 73cb87773b6dd4818d0bf485f53a43baeda88145
Headers show
Series test-lib: fix non-functioning GIT_TEST_MAINT_SCHEDULER fallback | expand

Commit Message

Eric Sunshine March 29, 2024, 10:27 p.m. UTC
From: Eric Sunshine <sunshine@sunshineco.com>

When environment variable GIT_TEST_MAINT_SCHEDULER is set, `git
maintenance` invokes the command specified as the variable's value
rather than invoking the actual underlying platform-specific scheduler
management command. By setting GIT_TEST_MAINT_SCHEDULER to some suitable
value, test authors can therefore validate behavior of "destructive"
`git maintenance` commands without having to worry about clobbering the
user's own local scheduler configuration.

In order to protect an absent-minded test author from forgetting to set
GIT_TEST_MAINT_SCHEDULER in the local test script (and thus clobbering
his or her own scheduler configuration), t/test-lib.sh assigns an
"immediately error-out" value to GIT_TEST_MAINT_SCHEDULER by default
which should ensure that the problem will be caught and reported before
any damage can be done to the configuration of the person running the
tests.

Unfortunately, however, t/test-lib.sh neglects to export
GIT_TEST_MAINT_SCHEDULER, which renders the default "error-out"
assignment worthles. Fix this by exporting the variable as originally
intended.

Reported-by: Junio C Hamano <gitster@pobox.com>
Signed-of-by: Eric Sunshine <sunshine@sunshineco.com>
---

This is a replacement for Junio's [1]. That attempt made it easier for a
test author to shoot him or herself in the foot. This replacement patch
instead fixes the foot-shooting guard.

[1]: https://lore.kernel.org/git/xmqqmsqhsvwk.fsf@gitster.g/

 t/test-lib.sh | 1 +
 1 file changed, 1 insertion(+)

Comments

Eric Sunshine March 31, 2024, 6:51 a.m. UTC | #1
On Fri, Mar 29, 2024 at 6:27 PM Eric Sunshine <ericsunshine@charter.net> wrote:
> When environment variable GIT_TEST_MAINT_SCHEDULER is set, `git
> maintenance` invokes the command specified as the variable's value
> rather than invoking the actual underlying platform-specific scheduler
> management command. By setting GIT_TEST_MAINT_SCHEDULER to some suitable
> value, test authors can therefore validate behavior of "destructive"
> `git maintenance` commands without having to worry about clobbering the
> user's own local scheduler configuration.
>
> In order to protect an absent-minded test author from forgetting to set
> GIT_TEST_MAINT_SCHEDULER in the local test script (and thus clobbering
> his or her own scheduler configuration), t/test-lib.sh assigns an
> "immediately error-out" value to GIT_TEST_MAINT_SCHEDULER by default
> which should ensure that the problem will be caught and reported before
> any damage can be done to the configuration of the person running the
> tests.
>
> Unfortunately, however, t/test-lib.sh neglects to export
> GIT_TEST_MAINT_SCHEDULER, which renders the default "error-out"
> assignment worthles. Fix this by exporting the variable as originally
> intended.

s/worthles/worthless/

(I won't reroll just for this minor typo.)
diff mbox series

Patch

diff --git a/t/test-lib.sh b/t/test-lib.sh
index c8af8dab79..79d3e0e7d9 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -1962,6 +1962,7 @@  test_lazy_prereq DEFAULT_REPO_FORMAT '
 # Tests that verify the scheduler integration must set this locally
 # to avoid errors.
 GIT_TEST_MAINT_SCHEDULER="none:exit 1"
+export GIT_TEST_MAINT_SCHEDULER
 
 # Does this platform support `git fsmonitor--daemon`
 #