From a0a14a3d41fa6694a2b2d7ac3805f0f313caf402 Mon Sep 17 00:00:00 2001 From: Kristoffer Haugsbakk Date: Sat, 14 Oct 2023 23:45:52 +0200 Subject: [PATCH 1/9] t7900: remove register dependency MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `stop from existing schedule` depends on the preceding test `start from empty cron table` because the preceding test registers the repository. Without it, the “stop” test fails because `config` fails to get the repository: git config --get --global --fixed-value maintenance.repo "$(pwd)" Remove this dependency by setting up the state and tearing it down independently. Signed-off-by: Kristoffer Haugsbakk Signed-off-by: Junio C Hamano --- t/t7900-maintenance.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/t/t7900-maintenance.sh b/t/t7900-maintenance.sh index 487e326b3f..ca86b2ba68 100755 --- a/t/t7900-maintenance.sh +++ b/t/t7900-maintenance.sh @@ -588,6 +588,7 @@ test_expect_success 'start --scheduler=' ' ' test_expect_success 'start from empty cron table' ' + test_when_finished git maintenance unregister && GIT_TEST_MAINT_SCHEDULER="crontab:test-tool crontab cron.txt" git maintenance start --scheduler=crontab && # start registers the repo @@ -599,6 +600,8 @@ test_expect_success 'start from empty cron table' ' ' test_expect_success 'stop from existing schedule' ' + test_when_finished git maintenance unregister && + git maintenance register && GIT_TEST_MAINT_SCHEDULER="crontab:test-tool crontab cron.txt" git maintenance stop && # stop does not unregister the repo From 091cc553d3feeb4107c868dda30360bb8b1cad03 Mon Sep 17 00:00:00 2001 From: Kristoffer Haugsbakk Date: Sat, 14 Oct 2023 23:45:53 +0200 Subject: [PATCH 2/9] t7900: setup and tear down clones Test `loose-objects task` depends on the two clones setup in `prefetch multiple remotes`. Reuse the two clones setup and tear down the clones afterwards in both tests. Signed-off-by: Kristoffer Haugsbakk Signed-off-by: Junio C Hamano --- t/t7900-maintenance.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/t/t7900-maintenance.sh b/t/t7900-maintenance.sh index ca86b2ba68..ebc207f1a5 100755 --- a/t/t7900-maintenance.sh +++ b/t/t7900-maintenance.sh @@ -145,6 +145,12 @@ test_expect_success 'run --task=prefetch with no remotes' ' ' test_expect_success 'prefetch multiple remotes' ' + test_when_finished rm -r clone1 && + test_when_finished rm -r clone2 && + test_when_finished git remote remove remote1 && + test_when_finished git remote remove remote2 && + test_when_finished git tag --delete one && + test_when_finished git tag --delete two && git clone . clone1 && git clone . clone2 && git remote add remote1 "file://$(pwd)/clone1" && @@ -175,6 +181,22 @@ test_expect_success 'prefetch multiple remotes' ' ' test_expect_success 'loose-objects task' ' + test_when_finished rm -r clone1 && + test_when_finished rm -r clone2 && + test_when_finished git remote remove remote1 && + test_when_finished git remote remove remote2 && + test_when_finished git tag --delete one && + test_when_finished git tag --delete two && + git clone . clone1 && + git clone . clone2 && + git remote add remote1 "file://$(pwd)/clone1" && + git remote add remote2 "file://$(pwd)/clone2" && + git -C clone1 switch -c one && + git -C clone2 switch -c two && + test_commit -C clone1 one && + test_commit -C clone2 two && + git fetch --all && + # Repack everything so we know the state of the object dir git repack -adk && From 9332d43ccc7d3fe8c1c55dcac5b890ae7d0dacef Mon Sep 17 00:00:00 2001 From: Kristoffer Haugsbakk Date: Sat, 14 Oct 2023 23:45:54 +0200 Subject: [PATCH 3/9] t7900: create commit so that branch is born `pack-refs task` cannot be run in isolation but does pass if `maintenance.auto config option` is run first. Create a commit so that `HEAD` does not point to an unborn branch. Signed-off-by: Kristoffer Haugsbakk Signed-off-by: Junio C Hamano --- t/t7900-maintenance.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/t/t7900-maintenance.sh b/t/t7900-maintenance.sh index ebc207f1a5..4bfb4ec5cf 100755 --- a/t/t7900-maintenance.sh +++ b/t/t7900-maintenance.sh @@ -388,6 +388,7 @@ test_expect_success 'maintenance.incremental-repack.auto (when config is unset)' ' test_expect_success 'pack-refs task' ' + test_commit message && for n in $(test_seq 1 5) do git branch -f to-pack/$n HEAD || return 1 From 1053634f097c9a58953bd23df6cc33609a877280 Mon Sep 17 00:00:00 2001 From: Kristoffer Haugsbakk Date: Sat, 14 Oct 2023 23:45:55 +0200 Subject: [PATCH 4/9] t7900: factor out inheritance test dependency Factor out the dependency that test `maintenance.strategy inheritance` has on test `--schedule inheritance weekly -> daily -> hourly`. Signed-off-by: Kristoffer Haugsbakk Signed-off-by: Junio C Hamano --- t/t7900-maintenance.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/t/t7900-maintenance.sh b/t/t7900-maintenance.sh index 4bfb4ec5cf..6e3ee365cc 100755 --- a/t/t7900-maintenance.sh +++ b/t/t7900-maintenance.sh @@ -408,14 +408,16 @@ test_expect_success 'invalid --schedule value' ' test_i18ngrep "unrecognized --schedule" err ' -test_expect_success '--schedule inheritance weekly -> daily -> hourly' ' +test_expect_success 'setup for inheritance' ' git config maintenance.loose-objects.enabled true && git config maintenance.loose-objects.schedule hourly && git config maintenance.commit-graph.enabled true && git config maintenance.commit-graph.schedule daily && git config maintenance.incremental-repack.enabled true && - git config maintenance.incremental-repack.schedule weekly && + git config maintenance.incremental-repack.schedule weekly +' +test_expect_success '--schedule inheritance weekly -> daily -> hourly' ' GIT_TRACE2_EVENT="$(pwd)/hourly.txt" \ git maintenance run --schedule=hourly 2>/dev/null && test_subcommand git prune-packed --quiet Date: Sat, 14 Oct 2023 23:45:56 +0200 Subject: [PATCH 5/9] t7900: factor out common schedule setup Tests `magic markers are correct` and `stop preserves surrounding schedule` depend on some setup in `start preserves existing schedule`. Factor out the setup code. Signed-off-by: Kristoffer Haugsbakk Signed-off-by: Junio C Hamano --- t/t7900-maintenance.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/t/t7900-maintenance.sh b/t/t7900-maintenance.sh index 6e3ee365cc..ebde3e8a21 100755 --- a/t/t7900-maintenance.sh +++ b/t/t7900-maintenance.sh @@ -637,9 +637,12 @@ test_expect_success 'stop from existing schedule' ' test_must_be_empty cron.txt ' -test_expect_success 'start preserves existing schedule' ' +test_expect_success 'setup important information for schedule' ' echo "Important information!" >cron.txt && - GIT_TEST_MAINT_SCHEDULER="crontab:test-tool crontab cron.txt" git maintenance start --scheduler=crontab && + GIT_TEST_MAINT_SCHEDULER="crontab:test-tool crontab cron.txt" git maintenance start --scheduler=crontab +' + +test_expect_success 'start preserves existing schedule' ' grep "Important information!" cron.txt ' From 4489382a5b90216b381cca0e4e1ceed228f634f2 Mon Sep 17 00:00:00 2001 From: Kristoffer Haugsbakk Date: Sat, 14 Oct 2023 23:45:57 +0200 Subject: [PATCH 6/9] t7900: fix `pfx` dependency Test `start and stop when several schedulers are available` depends on `pfx` from `start and stop macOS maintenance`. Duplicate the behavior. Signed-off-by: Kristoffer Haugsbakk Signed-off-by: Junio C Hamano --- t/t7900-maintenance.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/t/t7900-maintenance.sh b/t/t7900-maintenance.sh index ebde3e8a21..15a8653b58 100755 --- a/t/t7900-maintenance.sh +++ b/t/t7900-maintenance.sh @@ -794,6 +794,7 @@ test_expect_success 'start and stop Linux/systemd maintenance' ' ' test_expect_success 'start and stop when several schedulers are available' ' + pfx=$(cd "$HOME" && pwd) && write_script print-args <<-\EOF && printf "%s\n" "$*" | sed "s:gui/[0-9][0-9]*:gui/[UID]:; s:\(schtasks /create .* /xml\).*:\1:;" >>args EOF From df169ebf3b510f220f3093042fd2b39049d93d8f Mon Sep 17 00:00:00 2001 From: Kristoffer Haugsbakk Date: Sat, 14 Oct 2023 23:45:58 +0200 Subject: [PATCH 7/9] t7900: fix `print-args` dependency Test `use launchctl list to prevent extra work` depends on `print-args` from `start and stop macOS maintenance`. Duplicate the script writing. Signed-off-by: Kristoffer Haugsbakk Signed-off-by: Junio C Hamano --- t/t7900-maintenance.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/t/t7900-maintenance.sh b/t/t7900-maintenance.sh index 15a8653b58..99279e4178 100755 --- a/t/t7900-maintenance.sh +++ b/t/t7900-maintenance.sh @@ -709,6 +709,9 @@ test_expect_success 'start and stop macOS maintenance' ' ' test_expect_success 'use launchctl list to prevent extra work' ' + write_script print-args <<-\EOF && + echo $* | sed "s:gui/[0-9][0-9]*:gui/[UID]:" >>args + EOF # ensure we are registered GIT_TEST_MAINT_SCHEDULER=launchctl:./print-args git maintenance start --scheduler=launchctl && From bf236ef83410c91fa00daa83c51ea6e5ba1a7c23 Mon Sep 17 00:00:00 2001 From: Kristoffer Haugsbakk Date: Sat, 14 Oct 2023 23:45:59 +0200 Subject: [PATCH 8/9] t7900: factor out packfile dependency Tests `'--schedule inheritance weekly -> daily -> hourly` and `maintenance.strategy inheritance` depend on the packfile made in `incremental-repack task`. Factor out the packfile creation. Signed-off-by: Kristoffer Haugsbakk Signed-off-by: Junio C Hamano --- t/t7900-maintenance.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/t/t7900-maintenance.sh b/t/t7900-maintenance.sh index 99279e4178..bc417b518b 100755 --- a/t/t7900-maintenance.sh +++ b/t/t7900-maintenance.sh @@ -257,13 +257,15 @@ test_expect_success 'maintenance.loose-objects.auto' ' test_subcommand git prune-packed --quiet Date: Sun, 15 Oct 2023 01:00:44 +0200 Subject: [PATCH 9/9] t7900: fix register dependency The test `maintenance.auto config option` will fail if any preceding test has run `git maintenance register` since that turns `maintenance.auto` off for that repository and later calls to `unregister` will not turn it back to the default `true` value. Start with a fresh repository in this test. Signed-off-by: Kristoffer Haugsbakk Signed-off-by: Junio C Hamano --- t/t7900-maintenance.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/t/t7900-maintenance.sh b/t/t7900-maintenance.sh index bc417b518b..dbc5e1eb44 100755 --- a/t/t7900-maintenance.sh +++ b/t/t7900-maintenance.sh @@ -55,6 +55,8 @@ test_expect_success 'run [--auto|--quiet]' ' ' test_expect_success 'maintenance.auto config option' ' + rm -rf .git && + git init && GIT_TRACE2_EVENT="$(pwd)/default" git commit --quiet --allow-empty -m 1 && test_subcommand git maintenance run --auto --quiet