Merge branch 'hx/push-atomic-with-cert'
[git] / t / t7900-maintenance.sh
1 #!/bin/sh
2
3 test_description='git maintenance builtin'
4
5 . ./test-lib.sh
6
7 GIT_TEST_COMMIT_GRAPH=0
8
9 test_expect_success 'help text' '
10         test_expect_code 129 git maintenance -h 2>err &&
11         test_i18ngrep "usage: git maintenance run" err &&
12         test_expect_code 128 git maintenance barf 2>err &&
13         test_i18ngrep "invalid subcommand: barf" err &&
14         test_expect_code 129 git maintenance 2>err &&
15         test_i18ngrep "usage: git maintenance" err
16 '
17
18 test_expect_success 'run [--auto|--quiet]' '
19         GIT_TRACE2_EVENT="$(pwd)/run-no-auto.txt" \
20                 git maintenance run 2>/dev/null &&
21         GIT_TRACE2_EVENT="$(pwd)/run-auto.txt" \
22                 git maintenance run --auto 2>/dev/null &&
23         GIT_TRACE2_EVENT="$(pwd)/run-no-quiet.txt" \
24                 git maintenance run --no-quiet 2>/dev/null &&
25         test_subcommand git gc --quiet <run-no-auto.txt &&
26         test_subcommand ! git gc --auto --quiet <run-auto.txt &&
27         test_subcommand git gc --no-quiet <run-no-quiet.txt
28 '
29
30 test_expect_success 'maintenance.<task>.enabled' '
31         git config maintenance.gc.enabled false &&
32         git config maintenance.commit-graph.enabled true &&
33         GIT_TRACE2_EVENT="$(pwd)/run-config.txt" git maintenance run 2>err &&
34         test_subcommand ! git gc --quiet <run-config.txt &&
35         test_subcommand git commit-graph write --split --reachable --no-progress <run-config.txt
36 '
37
38 test_expect_success 'run --task=<task>' '
39         GIT_TRACE2_EVENT="$(pwd)/run-commit-graph.txt" \
40                 git maintenance run --task=commit-graph 2>/dev/null &&
41         GIT_TRACE2_EVENT="$(pwd)/run-gc.txt" \
42                 git maintenance run --task=gc 2>/dev/null &&
43         GIT_TRACE2_EVENT="$(pwd)/run-commit-graph.txt" \
44                 git maintenance run --task=commit-graph 2>/dev/null &&
45         GIT_TRACE2_EVENT="$(pwd)/run-both.txt" \
46                 git maintenance run --task=commit-graph --task=gc 2>/dev/null &&
47         test_subcommand ! git gc --quiet <run-commit-graph.txt &&
48         test_subcommand git gc --quiet <run-gc.txt &&
49         test_subcommand git gc --quiet <run-both.txt &&
50         test_subcommand git commit-graph write --split --reachable --no-progress <run-commit-graph.txt &&
51         test_subcommand ! git commit-graph write --split --reachable --no-progress <run-gc.txt &&
52         test_subcommand git commit-graph write --split --reachable --no-progress <run-both.txt
53 '
54
55 test_expect_success 'run --task=bogus' '
56         test_must_fail git maintenance run --task=bogus 2>err &&
57         test_i18ngrep "is not a valid task" err
58 '
59
60 test_expect_success 'run --task duplicate' '
61         test_must_fail git maintenance run --task=gc --task=gc 2>err &&
62         test_i18ngrep "cannot be selected multiple times" err
63 '
64
65 test_done