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

[PATCH] t7900: fix host-dependent behaviour when testing git-maintenance(1)

From
Patrick Steinhardt <ps@pks.im>
Date
Nov 25, 2024, 05:33 UTC
Message-ID
<eb504a75147d8609be66e131d239a69d192d693d.1732511129.git.ps@pks.im>
In-Reply-To
<20241122153033.GA1737136@coredump.intra.peff.net>

We have recently added a new test to t7900 that exercises whether git-maintenance(1) fails as expected when the "schedule.lock" file exists. The test depends on whether or not the host has the required executables present to schedule maintenance tasks in the first place, like systemd or launchctl -- if not, the test fails with an unrelated error before even checking for the lock file. This fails for example in our CI systems, where macOS images do not have launchctl available.

Fix this issue by creating a stub systemctl(1) binary and using the systemd scheduler.

Reported-by: Jeff King <peff@peff.net>
Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
Oh, true, thanks for reporting. This here should fix it.
Patrick
 t/t7900-maintenance.sh | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/t/t7900-maintenance.sh b/t/t7900-maintenance.sh
index 6d6ffaaf37..4bbc171958 100755
--- a/t/t7900-maintenance.sh
+++ b/t/t7900-maintenance.sh
@@ -1012,10 +1012,15 @@ test_expect_success 'repacking loose objects is quiet' '
 '
 
 test_expect_success 'maintenance aborts with existing lock file' '
-	test_when_finished "rm -rf repo" &&
+	test_when_finished "rm -rf repo script" &&
+	mkdir script &&
+	write_script script/systemctl <<-\EOF &&
+	true
+	EOF
+
 	git init repo &&
 	: >repo/.git/objects/schedule.lock &&
-	test_must_fail git -C repo maintenance start 2>err &&
+	test_must_fail env PATH="$PWD/script:$PATH" git -C repo maintenance start --scheduler=systemd 2>err &&
 	test_grep "Another scheduled git-maintenance(1) process seems to be running" err
 '
 

base-commit: 2f2daa412d02135a1f1f00da3f424217467f8d16
-- 
2.47.0.274.g962d0b743d.dirty
Previous: Jeff KingNext: Jeff King
Message 4 of 5 in “builtin/gc: provide hint when maintenance hits a stale schedule lock”
  1. builtin/gc: provide hint when maintenance hits a stale schedule lockPatrick Steinhardt, Nov 19, 2024
  2. Justin ToblerNov 19, 2024
  3. Jeff KingNov 22, 2024
  4. t7900: fix host-dependent behaviour when testing git-maintenance(1)Patrick Steinhardt, Nov 25, 2024
  5. Jeff KingNov 25, 2024

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.