Skip to content

Commit fe454b1

Browse files
jrngitster
authored andcommitted
t7400: split setup into multiple tests
The setup in t7400-submodule-basic does a number of different things to support different tests. Splitting it up makes the test a little easier to read and should provide an opportunity to move each piece of setup closer to the tests that require it. Signed-off-by: Jonathan Nieder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b9aa901 commit fe454b1

File tree

1 file changed

+30
-28
lines changed

1 file changed

+30
-28
lines changed

t/t7400-submodule-basic.sh

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -11,40 +11,42 @@ subcommands of git submodule.
1111

1212
. ./test-lib.sh
1313

14-
#
15-
# Test setup:
16-
# -create a repository in directory init
17-
# -add a couple of files
18-
# -add directory init to 'superproject', this creates a DIRLINK entry
19-
# -add a couple of regular files to enable testing of submodule filtering
20-
# -mv init subrepo
21-
# -add an entry to .gitmodules for submodule 'example'
22-
#
23-
test_expect_success 'Prepare submodule testing' '
24-
: > t &&
14+
test_expect_success 'setup - initial commit' '
15+
>t &&
2516
git add t &&
2617
git commit -m "initial commit" &&
27-
git branch initial HEAD &&
18+
git branch initial
19+
'
20+
21+
test_expect_success 'setup - repository in init subdirectory' '
2822
mkdir init &&
29-
cd init &&
30-
git init &&
31-
echo a >a &&
32-
git add a &&
33-
git commit -m "submodule commit 1" &&
34-
git tag -a -m "rev-1" rev-1 &&
35-
rev1=$(git rev-parse HEAD) &&
36-
if test -z "$rev1"
37-
then
38-
echo "[OOPS] submodule git rev-parse returned nothing"
39-
false
40-
fi &&
41-
cd .. &&
23+
(
24+
cd init &&
25+
git init &&
26+
echo a >a &&
27+
git add a &&
28+
git commit -m "submodule commit 1" &&
29+
git tag -a -m "rev-1" rev-1
30+
)
31+
rev1=$(cd init && git rev-parse HEAD) &&
32+
printf "rev1: %s\n" "$rev1" &&
33+
test -n "$rev1"
34+
'
35+
36+
test_expect_success 'setup - commit with gitlink' '
4237
echo a >a &&
4338
echo z >z &&
4439
git add a init z &&
45-
git commit -m "super commit 1" &&
46-
mv init .subrepo &&
47-
GIT_CONFIG=.gitmodules git config submodule.example.url git://example.com/init.git
40+
git commit -m "super commit 1"
41+
'
42+
43+
test_expect_success 'setup - hide init subdirectory' '
44+
mv init .subrepo
45+
'
46+
47+
test_expect_success 'setup - add an example entry to .gitmodules' '
48+
GIT_CONFIG=.gitmodules \
49+
git config submodule.example.url git://example.com/init.git
4850
'
4951

5052
test_expect_success 'Prepare submodule add testing' '

0 commit comments

Comments
 (0)