From d714fa7ee5494a749a7e312a9d79f125df4c2aab Mon Sep 17 00:00:00 2001 From: Mathieu Barbin Date: Tue, 18 Aug 2026 14:58:26 +0200 Subject: [PATCH] Isolate test suite git commands from ambient global/system git config Central_test_helpers.init_repo already isolates the throwaway test repos from the local machine's user.name/user.email, but nothing else: a global commit.gpgsign (blocking on a hardware key or gpg-agent prompt) or a global core.hooksPath (running pre-commit/pre-push hooks) still apply to every commit and push the test suite makes, and can turn an otherwise ~1-2s test run into one that hangs or crawls for reasons that have nothing to do with central itself. Point GIT_CONFIG_GLOBAL and GIT_CONFIG_SYSTEM at /dev/null for the test process - git's documented way to load no config file there. The spawned central.exe subprocess (and any git it shells out to) inherits this process's environment, so this isolates every git invocation the suite makes, not just the ones issued directly. Verified with a fake HOME carrying commit.gpgsign pointed at a slow signer plus a sleeping core.hooksPath hook: one partition (todo.ml) went from 3.28s to 0.32s (~10x) with this change, and dune build @all @runtest / @fmt / @lint all still pass clean. Co-Authored-By: Claude Sonnet 5 --- src/test-helpers/central_test_helpers.ml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/test-helpers/central_test_helpers.ml b/src/test-helpers/central_test_helpers.ml index a56ca1b..42008d0 100644 --- a/src/test-helpers/central_test_helpers.ml +++ b/src/test-helpers/central_test_helpers.ml @@ -4,6 +4,23 @@ (* SPDX-License-Identifier: MIT *) (*********************************************************************************) +(* Every git invocation the test suite makes - both the ones issued directly + from this process and the ones the spawned [central] subprocess makes on + its own (see [Central_test_harness.run]; it inherits this process's + environment) - is pointed away from the ambient global/system git config. + Without this, [init_repo] below only isolates identity (user.name/email); + anything else set globally on the machine running the tests still applies + to these throwaway repos, e.g. commit/tag signing (which can block on a + hardware key or a gpg-agent prompt) or a global [core.hooksPath] running + pre-commit/pre-push hooks. Either can turn an otherwise-fast test suite + into one that hangs or crawls, for reasons that have nothing to do with + [central] itself and everything to do with the developer's own [~/.gitconfig]. + [/dev/null] is git's documented way to say "load no file here". *) +let () = + Unix.putenv "GIT_CONFIG_GLOBAL" "/dev/null"; + Unix.putenv "GIT_CONFIG_SYSTEM" "/dev/null" +;; + module Fake_subrepo = struct type t = { subrepo : Central.Subrepo.t