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' and notify regarding the above mentioned behaviour in t7401 itself. Mentored-by: Christian Couder <chriscool@tuxfamily.org> Mentored-by: Kaartic Sivaraam <kaartic.sivaraam@gmail.com> Signed-off-by: Shourya Shukla <shouryashukla.oo@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Shourya Shukla committed
Aug 13, 2020 at 01:14 UTC
ede8a5bb6b16af70542bc9d02d17371e83764837
2 files changed
+73
t/t7401-submodule-summary.sh
+4
@@ -7,6 +7,10 @@ test_description='Summary support for submodules
7
8
This test tries to verify the sanity of summary subcommand of git submodule.
9
'
10
+# NOTE: This test script uses 'git add' instead of 'git submodule add' to add
11
+# submodules to the superproject. Some submodule subcommands such as init and
12
+# deinit might not work as expected in this script. t7421 does not have this
13
+# caveat.
14
15
. ./test-lib.sh
16
t/t7421-submodule-summary-add.sh
new
+69
@@ -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