Skip to content

Commit ddfcb9d

Browse files
pks-tgitster
authored andcommitted
t: silence output from test_create_repo()
There are a couple users of `test_create_repo()` that use this function outside of any test case. This function is nowadays only a thin wrapper around `git init`, which by default prints a message to stdout that the repository has been initialized. The resulting output may thus confuse TAP parsers. Refactor these users to instead create the repository in a "setup" test case so that we don't explicitly have to silence them. There's one exception in t1007: we use `push_repo()` and its `pop_repo()` equivalent multiple times, so to reduce the noise introduced by this patch we instead silence this invocation. While at it, convert callsites to use git-init(1) directly as the `test_create_repo()` function has been deprecated in f0d4d39 (test-lib: split up and deprecate test_create_repo(), 2021-05-10). Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent faac9d4 commit ddfcb9d

File tree

4 files changed

+31
-20
lines changed

4 files changed

+31
-20
lines changed

t/t1007-hash-object.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ setup_repo() {
3030

3131
test_repo=test
3232
push_repo() {
33-
test_create_repo $test_repo
33+
git init --quiet $test_repo
3434
cd $test_repo
3535

3636
setup_repo

t/t4041-diff-submodule-option.sh

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,12 @@ commit_file () {
4848
git commit "$@" -m "Commit $*" >/dev/null
4949
}
5050

51-
test_create_repo sm1 &&
52-
add_file . foo >/dev/null
53-
54-
head1=$(add_file sm1 foo1 foo2)
55-
fullhead1=$(cd sm1; git rev-parse --verify HEAD)
51+
test_expect_success 'setup submodule' '
52+
git init sm1 &&
53+
add_file . foo &&
54+
head1=$(add_file sm1 foo1 foo2) &&
55+
fullhead1=$(cd sm1 && git rev-parse --verify HEAD)
56+
'
5657

5758
test_expect_success 'added submodule' '
5859
git add sm1 &&
@@ -235,10 +236,13 @@ test_expect_success 'typechanged submodule(submodule->blob)' '
235236
test_cmp expected actual
236237
'
237238

238-
rm -f sm1 &&
239-
test_create_repo sm1 &&
240-
head6=$(add_file sm1 foo6 foo7)
241-
fullhead6=$(cd sm1; git rev-parse --verify HEAD)
239+
test_expect_success 'setup submodule anew' '
240+
rm -f sm1 &&
241+
git init sm1 &&
242+
head6=$(add_file sm1 foo6 foo7) &&
243+
fullhead6=$(cd sm1 && git rev-parse --verify HEAD)
244+
'
245+
242246
test_expect_success 'nonexistent commit' '
243247
git diff-index -p --submodule=log HEAD >actual &&
244248
cat >expected <<-EOF &&

t/t4060-diff-submodule-option-diff-format.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -363,9 +363,12 @@ test_expect_success 'typechanged submodule(submodule->blob)' '
363363
diff_cmp expected actual
364364
'
365365

366-
rm -f sm1 &&
367-
test_create_repo sm1 &&
368-
head6=$(add_file sm1 foo6 foo7)
366+
test_expect_success 'setup' '
367+
rm -f sm1 &&
368+
git init sm1 &&
369+
head6=$(add_file sm1 foo6 foo7)
370+
'
371+
369372
test_expect_success 'nonexistent commit' '
370373
git diff-index -p --submodule=diff HEAD >actual &&
371374
cat >expected <<-EOF &&

t/t7401-submodule-summary.sh

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,11 @@ commit_file () {
3838
git commit "$@" -m "Commit $*" >/dev/null
3939
}
4040

41-
test_create_repo sm1 &&
42-
add_file . foo >/dev/null
43-
44-
head1=$(add_file sm1 foo1 foo2)
41+
test_expect_success 'setup submodule' '
42+
git init sm1 &&
43+
add_file . foo &&
44+
head1=$(add_file sm1 foo1 foo2)
45+
'
4546

4647
test_expect_success 'added submodule' "
4748
git add sm1 &&
@@ -214,9 +215,12 @@ test_expect_success 'typechanged submodule(submodule->blob)' "
214215
test_cmp expected actual
215216
"
216217

217-
rm -f sm1 &&
218-
test_create_repo sm1 &&
219-
head6=$(add_file sm1 foo6 foo7)
218+
test_expect_success 'setup submodule' '
219+
rm -f sm1 &&
220+
git init sm1 &&
221+
head6=$(add_file sm1 foo6 foo7)
222+
'
223+
220224
test_expect_success 'nonexistent commit' "
221225
git submodule summary >actual &&
222226
cat >expected <<-EOF &&

0 commit comments

Comments
 (0)