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

[PATCH 2/3] t921*: test scalar behavior starting maintenance

From
Derrick Stolee via GitGitGadget <gitgitgadget@gmail.com>
Date
Jan 27, 2023, 20:06 UTC
Message-ID
<f05325c862b618067c67e727c81dafdf4463e4fc.1674849963.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.1473.git.1674849963.gitgitgadget@gmail.com>
From: Derrick Stolee <derrickstolee@github.com>

A user recently reported issues with 'scalar register' and 'scalar clone' in that they failed when the system had permissions locked down so both 'crontab' and 'systemctl' commands failed when trying to enable background maintenance.

This hard error is undesirable, but let's create tests that demonstrate this behavior before modiying the behavior. We can use GIT_TEST_MAINT_SCHEDULER to guarantee failure and check the exit code and error message.

Signed-off-by: Derrick Stolee <derrickstolee@github.com>
---
 t/t9210-scalar.sh       | 7 +++++++
 t/t9211-scalar-clone.sh | 6 ++++++
 2 files changed, 13 insertions(+)
diff --git a/t/t9210-scalar.sh b/t/t9210-scalar.sh
index 25f500cf682..13a4f6dbcf4 100755
--- a/t/t9210-scalar.sh
+++ b/t/t9210-scalar.sh
@@ -104,6 +104,13 @@ test_expect_success FSMONITOR_DAEMON 'scalar register starts fsmon daemon' '
 	test_cmp_config -C test/src true core.fsmonitor
 '
 
+test_expect_success 'scalar register fails when background maintenance fails' '
+	git init register-repo &&
+	GIT_TEST_MAINT_SCHEDULER="crontab:false,launchctl:false,schtasks:false" \
+		test_must_fail scalar register register-repo 2>err &&
+	grep "could not turn on maintenance" err
+'
+
 test_expect_success 'scalar unregister' '
 	git init vanish/src &&
 	scalar register vanish/src &&
diff --git a/t/t9211-scalar-clone.sh b/t/t9211-scalar-clone.sh
index 02d32fb6ede..a6156da29ac 100755
--- a/t/t9211-scalar-clone.sh
+++ b/t/t9211-scalar-clone.sh
@@ -174,4 +174,10 @@ test_expect_success 'progress without tty' '
 	cleanup_clone $enlistment
 '
 
+test_expect_success 'scalar clone fails when background maintenance fails' '
+	GIT_TEST_MAINT_SCHEDULER="crontab:false,launchctl:false,schtasks:false" \
+		test_must_fail scalar clone "file://$(pwd)/to-clone" maint-fail 2>err &&
+	grep "could not turn on maintenance" err
+'
+
 test_done
-- 
gitgitgadget
Previous: Derrick StoleeNext: Derrick Stolee via GitGitGadget
Message 15 of 16 in “Allow scalar to succeed despite maintenance failures”
  1. 0/3 Allow scalar to succeed despite maintenance failuresDerrick Stolee via GitGitGadget, Jan 27, 2023
  2. 3/3 scalar: only warn when background maintenance failsDerrick Stolee via GitGitGadget, Jan 27, 2023
  3. Junio C HamanoJan 27, 2023
  4. Derrick StoleeJan 27, 2023
  5. Junio C HamanoJan 28, 2023
  6. Derrick StoleeJan 30, 2023
  7. Junio C HamanoJan 30, 2023
  8. Victoria DyeJan 30, 2023
  9. Junio C HamanoJan 30, 2023
  10. Derrick StoleeJan 30, 2023
  11. Victoria DyeJan 27, 2023
  12. Derrick StoleeJan 30, 2023
  13. Victoria DyeJan 27, 2023
  14. Derrick StoleeJan 27, 2023
  15. 2/3 t921*: test scalar behavior starting maintenanceDerrick Stolee via GitGitGadget, Jan 27, 2023
  16. 1/3 t: allow 'scalar' in test_must_failDerrick Stolee via GitGitGadget, Jan 27, 2023

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.