]>
Commit | Line | Data |
---|---|---|
5c2bd8b7 BW |
1 | #!/bin/sh |
2 | ||
3 | test_description='Test submodule--helper is-active | |
4 | ||
5 | This test verifies that `git submodue--helper is-active` correclty identifies | |
6 | submodules which are "active" and interesting to the user. | |
7 | ' | |
8 | ||
9 | . ./test-lib.sh | |
10 | ||
11 | test_expect_success 'setup' ' | |
12 | git init sub && | |
13 | test_commit -C sub initial && | |
14 | git init super && | |
15 | test_commit -C super initial && | |
16 | git -C super submodule add ../sub sub1 && | |
17 | git -C super submodule add ../sub sub2 && | |
18 | git -C super commit -a -m "add 2 submodules at sub{1,2}" | |
19 | ' | |
20 | ||
21 | test_expect_success 'is-active works with urls' ' | |
22 | git -C super submodule--helper is-active sub1 && | |
23 | git -C super submodule--helper is-active sub2 && | |
24 | ||
25 | git -C super config --unset submodule.sub1.URL && | |
26 | test_must_fail git -C super submodule--helper is-active sub1 && | |
27 | git -C super config submodule.sub1.URL ../sub && | |
28 | git -C super submodule--helper is-active sub1 | |
29 | ' | |
30 | ||
a086f921 BW |
31 | test_expect_success 'is-active works with submodule.<name>.active config' ' |
32 | test_when_finished "git -C super config --unset submodule.sub1.active" && | |
33 | test_when_finished "git -C super config submodule.sub1.URL ../sub" && | |
34 | ||
35 | git -C super config --bool submodule.sub1.active "false" && | |
36 | test_must_fail git -C super submodule--helper is-active sub1 && | |
37 | ||
38 | git -C super config --bool submodule.sub1.active "true" && | |
39 | git -C super config --unset submodule.sub1.URL && | |
40 | git -C super submodule--helper is-active sub1 | |
41 | ' | |
42 | ||
43 | test_expect_success 'is-active works with basic submodule.active config' ' | |
44 | test_when_finished "git -C super config submodule.sub1.URL ../sub" && | |
45 | test_when_finished "git -C super config --unset-all submodule.active" && | |
46 | ||
47 | git -C super config --add submodule.active "." && | |
48 | git -C super config --unset submodule.sub1.URL && | |
49 | ||
50 | git -C super submodule--helper is-active sub1 && | |
51 | git -C super submodule--helper is-active sub2 | |
52 | ' | |
53 | ||
54 | test_expect_success 'is-active correctly works with paths that are not submodules' ' | |
55 | test_when_finished "git -C super config --unset-all submodule.active" && | |
56 | ||
57 | test_must_fail git -C super submodule--helper is-active not-a-submodule && | |
58 | ||
59 | git -C super config --add submodule.active "." && | |
60 | test_must_fail git -C super submodule--helper is-active not-a-submodule | |
61 | ' | |
62 | ||
63 | test_expect_success 'is-active works with exclusions in submodule.active config' ' | |
64 | test_when_finished "git -C super config --unset-all submodule.active" && | |
65 | ||
66 | git -C super config --add submodule.active "." && | |
67 | git -C super config --add submodule.active ":(exclude)sub1" && | |
68 | ||
69 | test_must_fail git -C super submodule--helper is-active sub1 && | |
70 | git -C super submodule--helper is-active sub2 | |
71 | ' | |
72 | ||
73 | test_expect_success 'is-active with submodule.active and submodule.<name>.active' ' | |
74 | test_when_finished "git -C super config --unset-all submodule.active" && | |
75 | test_when_finished "git -C super config --unset submodule.sub1.active" && | |
76 | test_when_finished "git -C super config --unset submodule.sub2.active" && | |
77 | ||
78 | git -C super config --add submodule.active "sub1" && | |
79 | git -C super config --bool submodule.sub1.active "false" && | |
80 | git -C super config --bool submodule.sub2.active "true" && | |
81 | ||
82 | test_must_fail git -C super submodule--helper is-active sub1 && | |
83 | git -C super submodule--helper is-active sub2 | |
84 | ' | |
85 | ||
5c2bd8b7 | 86 | test_done |