diff --git a/t/t7900-maintenance.sh b/t/t7900-maintenance.sh index 00d29871e6..67052641d2 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 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 ' ' ' 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 @@ -600,6 +630,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 @@ -610,9 +642,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 ' @@ -679,6 +714,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 && @@ -775,6 +813,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