]>
Commit | Line | Data |
---|---|---|
5c2bd8b7 BW |
1 | #!/bin/sh |
2 | ||
9fb2a970 | 3 | test_description='Test with test-tool submodule is-active |
5c2bd8b7 | 4 | |
9fb2a970 | 5 | This test verifies that `test-tool submodule is-active` correctly identifies |
5c2bd8b7 | 6 | submodules which are "active" and interesting to the user. |
9fb2a970 ÆAB |
7 | |
8 | This is a unit test of the submodule.c is_submodule_active() function, | |
9 | which is also indirectly tested elsewhere. | |
5c2bd8b7 BW |
10 | ' |
11 | ||
fe4c750f | 12 | TEST_PASSES_SANITIZE_LEAK=true |
5c2bd8b7 BW |
13 | . ./test-lib.sh |
14 | ||
15 | test_expect_success 'setup' ' | |
16 | git init sub && | |
17 | test_commit -C sub initial && | |
18 | git init super && | |
19 | test_commit -C super initial && | |
20 | git -C super submodule add ../sub sub1 && | |
21 | git -C super submodule add ../sub sub2 && | |
1b614c07 BW |
22 | |
23 | # Remove submodule.<name>.active entries in order to test in an | |
24 | # environment where only URLs are present in the conifg | |
25 | git -C super config --unset submodule.sub1.active && | |
26 | git -C super config --unset submodule.sub2.active && | |
27 | ||
5c2bd8b7 BW |
28 | git -C super commit -a -m "add 2 submodules at sub{1,2}" |
29 | ' | |
30 | ||
31 | test_expect_success 'is-active works with urls' ' | |
9fb2a970 ÆAB |
32 | test-tool -C super submodule is-active sub1 && |
33 | test-tool -C super submodule is-active sub2 && | |
5c2bd8b7 BW |
34 | |
35 | git -C super config --unset submodule.sub1.URL && | |
9fb2a970 | 36 | test_must_fail test-tool -C super submodule is-active sub1 && |
5c2bd8b7 | 37 | git -C super config submodule.sub1.URL ../sub && |
9fb2a970 | 38 | test-tool -C super submodule is-active sub1 |
5c2bd8b7 BW |
39 | ' |
40 | ||
a086f921 BW |
41 | test_expect_success 'is-active works with submodule.<name>.active config' ' |
42 | test_when_finished "git -C super config --unset submodule.sub1.active" && | |
43 | test_when_finished "git -C super config submodule.sub1.URL ../sub" && | |
44 | ||
45 | git -C super config --bool submodule.sub1.active "false" && | |
9fb2a970 | 46 | test_must_fail test-tool -C super submodule is-active sub1 && |
a086f921 BW |
47 | |
48 | git -C super config --bool submodule.sub1.active "true" && | |
49 | git -C super config --unset submodule.sub1.URL && | |
9fb2a970 | 50 | test-tool -C super submodule is-active sub1 |
a086f921 BW |
51 | ' |
52 | ||
53 | test_expect_success 'is-active works with basic submodule.active config' ' | |
54 | test_when_finished "git -C super config submodule.sub1.URL ../sub" && | |
55 | test_when_finished "git -C super config --unset-all submodule.active" && | |
56 | ||
57 | git -C super config --add submodule.active "." && | |
58 | git -C super config --unset submodule.sub1.URL && | |
59 | ||
9fb2a970 ÆAB |
60 | test-tool -C super submodule is-active sub1 && |
61 | test-tool -C super submodule is-active sub2 | |
a086f921 BW |
62 | ' |
63 | ||
64 | test_expect_success 'is-active correctly works with paths that are not submodules' ' | |
65 | test_when_finished "git -C super config --unset-all submodule.active" && | |
66 | ||
9fb2a970 | 67 | test_must_fail test-tool -C super submodule is-active not-a-submodule && |
a086f921 BW |
68 | |
69 | git -C super config --add submodule.active "." && | |
9fb2a970 | 70 | test_must_fail test-tool -C super submodule is-active not-a-submodule |
a086f921 BW |
71 | ' |
72 | ||
73 | test_expect_success 'is-active works with exclusions in submodule.active config' ' | |
74 | test_when_finished "git -C super config --unset-all submodule.active" && | |
75 | ||
76 | git -C super config --add submodule.active "." && | |
77 | git -C super config --add submodule.active ":(exclude)sub1" && | |
78 | ||
9fb2a970 ÆAB |
79 | test_must_fail test-tool -C super submodule is-active sub1 && |
80 | test-tool -C super submodule is-active sub2 | |
a086f921 BW |
81 | ' |
82 | ||
83 | test_expect_success 'is-active with submodule.active and submodule.<name>.active' ' | |
84 | test_when_finished "git -C super config --unset-all submodule.active" && | |
85 | test_when_finished "git -C super config --unset submodule.sub1.active" && | |
86 | test_when_finished "git -C super config --unset submodule.sub2.active" && | |
87 | ||
88 | git -C super config --add submodule.active "sub1" && | |
89 | git -C super config --bool submodule.sub1.active "false" && | |
90 | git -C super config --bool submodule.sub2.active "true" && | |
91 | ||
9fb2a970 ÆAB |
92 | test_must_fail test-tool -C super submodule is-active sub1 && |
93 | test-tool -C super submodule is-active sub2 | |
a086f921 BW |
94 | ' |
95 | ||
1b614c07 BW |
96 | test_expect_success 'is-active, submodule.active and submodule add' ' |
97 | test_when_finished "rm -rf super2" && | |
98 | git init super2 && | |
99 | test_commit -C super2 initial && | |
100 | git -C super2 config --add submodule.active "sub*" && | |
101 | ||
102 | # submodule add should only add submodule.<name>.active | |
103 | # to the config if not matched by the pathspec | |
104 | git -C super2 submodule add ../sub sub1 && | |
105 | test_must_fail git -C super2 config --get submodule.sub1.active && | |
106 | ||
107 | git -C super2 submodule add ../sub mod && | |
108 | git -C super2 config --get submodule.mod.active | |
109 | ' | |
110 | ||
5c2bd8b7 | 111 | test_done |