Skip to content

Commit aca8568

Browse files
avargitster
authored andcommitted
submodule tests: test for init and update failure output
Amend some submodule tests to test for the failure output of "git submodule [update|init]". The lack of such tests hid a regression in an earlier version of a subsequent commit. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]> Signed-off-by: Glen Choo <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 715d08a commit aca8568

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

t/t7406-submodule-update.sh

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,18 @@ test_expect_success 'submodule update should fail due to local changes' '
205205
(cd submodule &&
206206
compare_head
207207
) &&
208-
test_must_fail git submodule update submodule
209-
)
208+
test_must_fail git submodule update submodule 2>../actual.raw
209+
) &&
210+
sed "s/^> //" >expect <<-\EOF &&
211+
> error: Your local changes to the following files would be overwritten by checkout:
212+
> file
213+
> Please commit your changes or stash them before you switch branches.
214+
> Aborting
215+
> fatal: Unable to checkout OID in submodule path '\''submodule'\''
216+
EOF
217+
sed -e "s/checkout $SQ[^$SQ]*$SQ/checkout OID/" <actual.raw >actual &&
218+
test_cmp expect actual
219+
210220
'
211221
test_expect_success 'submodule update should throw away changes with --force ' '
212222
(cd super &&

t/t7408-submodule-reference.sh

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,19 @@ test_expect_success 'missing nested submodule alternate fails clone and submodul
193193
cd supersuper-clone &&
194194
check_that_two_of_three_alternates_are_used &&
195195
# update of the submodule fails
196-
test_must_fail git submodule update --init --recursive
196+
cat >expect <<-\EOF &&
197+
fatal: submodule '\''sub'\'' cannot add alternate: path ... does not exist
198+
Failed to clone '\''sub'\''. Retry scheduled
199+
fatal: submodule '\''sub-dissociate'\'' cannot add alternate: path ... does not exist
200+
Failed to clone '\''sub-dissociate'\''. Retry scheduled
201+
fatal: submodule '\''sub'\'' cannot add alternate: path ... does not exist
202+
Failed to clone '\''sub'\'' a second time, aborting
203+
fatal: Failed to recurse into submodule path ...
204+
EOF
205+
test_must_fail git submodule update --init --recursive 2>err &&
206+
grep -e fatal: -e ^Failed err >actual.raw &&
207+
sed -e "s/path $SQ[^$SQ]*$SQ/path .../" <actual.raw >actual &&
208+
test_cmp expect actual
197209
)
198210
'
199211

0 commit comments

Comments
 (0)