Skip to content

Commit 21cabc7

Browse files
periperidipgitster
authored andcommitted
t7421: introduce a test script for verifying 'summary' output
't7401-submodule-summary.sh' uses 'git add' to add submodules. Therefore, some commands such as 'git submodule init' and 'git submodule deinit' do not work as expected. So, introduce a test script for verifying the 'summary' output for submodules added using 'git submodule add'. Mentored-by: Christian Couder <[email protected]> Mentored-by: Kaartic Sivaraam <[email protected]> Signed-off-by: Shourya Shukla <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f311886 commit 21cabc7

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

t/t7421-submodule-summary-add.sh

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#!/bin/sh
2+
#
3+
# Copyright (C) 2020 Shourya Shukla
4+
#
5+
6+
test_description='Summary support for submodules, adding them using git submodule add
7+
8+
This test script tries to verify the sanity of summary subcommand of git submodule
9+
while making sure to add submodules using `git submodule add` instead of
10+
`git add` as done in t7401.
11+
'
12+
13+
. ./test-lib.sh
14+
15+
test_expect_success 'summary test environment setup' '
16+
git init sm &&
17+
test_commit -C sm "add file" file file-content file-tag &&
18+
19+
git submodule add ./sm my-subm &&
20+
test_tick &&
21+
git commit -m "add submodule"
22+
'
23+
24+
test_expect_success 'submodule summary output for initialized submodule' '
25+
test_commit -C sm "add file2" file2 file2-content file2-tag &&
26+
git submodule update --remote &&
27+
test_tick &&
28+
git commit -m "update submodule" my-subm &&
29+
git submodule summary HEAD^ >actual &&
30+
rev1=$(git -C sm rev-parse --short HEAD^) &&
31+
rev2=$(git -C sm rev-parse --short HEAD) &&
32+
cat >expected <<-EOF &&
33+
* my-subm ${rev1}...${rev2} (1):
34+
> add file2
35+
36+
EOF
37+
test_cmp expected actual
38+
'
39+
40+
test_expect_success 'submodule summary output for deinitialized submodule' '
41+
git submodule deinit my-subm &&
42+
git submodule summary HEAD^ >actual &&
43+
test_must_be_empty actual &&
44+
git submodule update --init my-subm &&
45+
git submodule summary HEAD^ >actual &&
46+
rev1=$(git -C sm rev-parse --short HEAD^) &&
47+
rev2=$(git -C sm rev-parse --short HEAD) &&
48+
cat >expected <<-EOF &&
49+
* my-subm ${rev1}...${rev2} (1):
50+
> add file2
51+
52+
EOF
53+
test_cmp expected actual
54+
'
55+
56+
test_expect_success 'submodule summary output for submodules with changed paths' '
57+
git mv my-subm subm &&
58+
git commit -m "change submodule path" &&
59+
rev=$(git -C sm rev-parse --short HEAD^) &&
60+
git submodule summary HEAD^^ -- my-subm >actual 2>err &&
61+
test_i18ngrep "fatal:.*my-subm" err &&
62+
cat >expected <<-EOF &&
63+
* my-subm ${rev}...0000000:
64+
65+
EOF
66+
test_cmp expected actual
67+
'
68+
69+
test_done

0 commit comments

Comments
 (0)