Skip to content

Commit 46b5d75

Browse files
committed
Merge branch 'ps/tests-with-ref-files-backend'
Prepare existing tests on refs to work better with non-default backends. * ps/tests-with-ref-files-backend: t: mark tests regarding git-pack-refs(1) to be backend specific t5526: break test submodule differently t1419: mark test suite as files-backend specific t1302: make tests more robust with new extensions t1301: mark test for `core.sharedRepository` as reffiles specific t1300: make tests more robust with non-default ref backends
2 parents 184c3b4 + bbd6106 commit 46b5d75

File tree

6 files changed

+79
-38
lines changed

6 files changed

+79
-38
lines changed

t/t1300-config.sh

Lines changed: 50 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,15 +1098,20 @@ test_expect_success SYMLINKS 'symlink to nonexistent configuration' '
10981098
test_must_fail git config --file=linktolinktonada --list
10991099
'
11001100

1101-
test_expect_success 'check split_cmdline return' "
1102-
git config alias.split-cmdline-fix 'echo \"' &&
1103-
test_must_fail git split-cmdline-fix &&
1104-
echo foo > foo &&
1105-
git add foo &&
1106-
git commit -m 'initial commit' &&
1107-
git config branch.main.mergeoptions 'echo \"' &&
1108-
test_must_fail git merge main
1109-
"
1101+
test_expect_success 'check split_cmdline return' '
1102+
test_when_finished "rm -rf repo" &&
1103+
git init repo &&
1104+
(
1105+
cd repo &&
1106+
git config alias.split-cmdline-fix "echo \"" &&
1107+
test_must_fail git split-cmdline-fix &&
1108+
echo foo >foo &&
1109+
git add foo &&
1110+
git commit -m "initial commit" &&
1111+
git config branch.main.mergeoptions "echo \"" &&
1112+
test_must_fail git merge main
1113+
)
1114+
'
11101115

11111116
test_expect_success 'git -c "key=value" support' '
11121117
cat >expect <<-\EOF &&
@@ -1157,10 +1162,16 @@ test_expect_success 'git -c works with aliases of builtins' '
11571162
'
11581163

11591164
test_expect_success 'aliases can be CamelCased' '
1160-
test_config alias.CamelCased "rev-parse HEAD" &&
1161-
git CamelCased >out &&
1162-
git rev-parse HEAD >expect &&
1163-
test_cmp expect out
1165+
test_when_finished "rm -rf repo" &&
1166+
git init repo &&
1167+
(
1168+
cd repo &&
1169+
test_commit A &&
1170+
git config alias.CamelCased "rev-parse HEAD" &&
1171+
git CamelCased >out &&
1172+
git rev-parse HEAD >expect &&
1173+
test_cmp expect out
1174+
)
11641175
'
11651176

11661177
test_expect_success 'git -c does not split values on equals' '
@@ -2009,11 +2020,11 @@ test_expect_success '--show-origin getting a single key' '
20092020
'
20102021

20112022
test_expect_success 'set up custom config file' '
2012-
CUSTOM_CONFIG_FILE="custom.conf" &&
2013-
cat >"$CUSTOM_CONFIG_FILE" <<-\EOF
2023+
cat >"custom.conf" <<-\EOF &&
20142024
[user]
20152025
custom = true
20162026
EOF
2027+
CUSTOM_CONFIG_FILE="$(test-tool path-utils real_path custom.conf)"
20172028
'
20182029

20192030
test_expect_success !MINGW 'set up custom config file with special name characters' '
@@ -2052,22 +2063,33 @@ test_expect_success '--show-origin stdin with file include' '
20522063
'
20532064

20542065
test_expect_success '--show-origin blob' '
2055-
blob=$(git hash-object -w "$CUSTOM_CONFIG_FILE") &&
2056-
cat >expect <<-EOF &&
2057-
blob:$blob user.custom=true
2058-
EOF
2059-
git config --blob=$blob --show-origin --list >output &&
2060-
test_cmp expect output
2066+
test_when_finished "rm -rf repo" &&
2067+
git init repo &&
2068+
(
2069+
cd repo &&
2070+
blob=$(git hash-object -w "$CUSTOM_CONFIG_FILE") &&
2071+
cat >expect <<-EOF &&
2072+
blob:$blob user.custom=true
2073+
EOF
2074+
git config --blob=$blob --show-origin --list >output &&
2075+
test_cmp expect output
2076+
)
20612077
'
20622078

20632079
test_expect_success '--show-origin blob ref' '
2064-
cat >expect <<-\EOF &&
2065-
blob:main:custom.conf user.custom=true
2066-
EOF
2067-
git add "$CUSTOM_CONFIG_FILE" &&
2068-
git commit -m "new config file" &&
2069-
git config --blob=main:"$CUSTOM_CONFIG_FILE" --show-origin --list >output &&
2070-
test_cmp expect output
2080+
test_when_finished "rm -rf repo" &&
2081+
git init repo &&
2082+
(
2083+
cd repo &&
2084+
cat >expect <<-\EOF &&
2085+
blob:main:custom.conf user.custom=true
2086+
EOF
2087+
cp "$CUSTOM_CONFIG_FILE" custom.conf &&
2088+
git add custom.conf &&
2089+
git commit -m "new config file" &&
2090+
git config --blob=main:custom.conf --show-origin --list >output &&
2091+
test_cmp expect output
2092+
)
20712093
'
20722094

20732095
test_expect_success '--show-origin with --default' '

t/t1301-shared-repo.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ test_expect_success POSIXPERM 'info/refs respects umask in unshared repo' '
137137
test_cmp expect actual
138138
'
139139

140-
test_expect_success POSIXPERM 'git reflog expire honors core.sharedRepository' '
140+
test_expect_success REFFILES,POSIXPERM 'git reflog expire honors core.sharedRepository' '
141141
umask 077 &&
142142
git config core.sharedRepository group &&
143143
git reflog expire --all &&

t/t1302-repo-version.sh

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ TEST_PASSES_SANITIZE_LEAK=true
99
. ./test-lib.sh
1010

1111
test_expect_success 'setup' '
12-
test_oid_cache <<-\EOF &&
13-
version sha1:0
14-
version sha256:1
15-
EOF
1612
cat >test.patch <<-\EOF &&
1713
diff --git a/test.txt b/test.txt
1814
new file mode 100644
@@ -28,7 +24,12 @@ test_expect_success 'setup' '
2824
'
2925

3026
test_expect_success 'gitdir selection on normal repos' '
31-
test_oid version >expect &&
27+
if test_have_prereq DEFAULT_REPO_FORMAT
28+
then
29+
echo 0
30+
else
31+
echo 1
32+
fi >expect &&
3233
git config core.repositoryformatversion >actual &&
3334
git -C test config core.repositoryformatversion >actual2 &&
3435
test_cmp expect actual &&
@@ -79,8 +80,13 @@ mkconfig () {
7980

8081
while read outcome version extensions; do
8182
test_expect_success "$outcome version=$version $extensions" "
82-
mkconfig $version $extensions >.git/config &&
83-
check_${outcome}
83+
test_when_finished 'rm -rf extensions' &&
84+
git init extensions &&
85+
(
86+
cd extensions &&
87+
mkconfig $version $extensions >.git/config &&
88+
check_${outcome}
89+
)
8490
"
8591
done <<\EOF
8692
allow 0
@@ -94,7 +100,8 @@ allow 1 noop-v1
94100
EOF
95101

96102
test_expect_success 'precious-objects allowed' '
97-
mkconfig 1 preciousObjects >.git/config &&
103+
git config core.repositoryFormatVersion 1 &&
104+
git config extensions.preciousObjects 1 &&
98105
check_allow
99106
'
100107

t/t1409-avoid-packing-refs.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ test_description='avoid rewriting packed-refs unnecessarily'
55
TEST_PASSES_SANITIZE_LEAK=true
66
. ./test-lib.sh
77

8+
if test_have_prereq !REFFILES
9+
then
10+
skip_all='skipping files-backend specific pack-refs tests'
11+
test_done
12+
fi
13+
814
# Add an identifying mark to the packed-refs file header line. This
915
# shouldn't upset readers, and it should be omitted if the file is
1016
# ever rewritten.

t/t1419-exclude-refs.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
88
TEST_PASSES_SANITIZE_LEAK=true
99
. ./test-lib.sh
1010

11+
if test_have_prereq !REFFILES
12+
then
13+
skip_all='skipping `git for-each-ref --exclude` tests; need files backend'
14+
test_done
15+
fi
16+
1117
for_each_ref__exclude () {
1218
GIT_TRACE2_PERF=1 test-tool ref-store main \
1319
for-each-ref--exclude "$@" >actual.raw

t/t5526-fetch-submodules.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -771,7 +771,7 @@ test_expect_success 'fetching submodule into a broken repository' '
771771
git -C dst fetch --recurse-submodules &&
772772
773773
# Break the receiving submodule
774-
test-tool -C dst/sub ref-store main delete-refs REF_NO_DEREF msg HEAD &&
774+
rm -r dst/sub/.git/objects &&
775775
776776
# NOTE: without the fix the following tests will recurse forever!
777777
# They should terminate with an error.

0 commit comments

Comments
 (0)