Skip to content

Commit dcc0bde

Browse files
committed
t3070: skip ls-files tests with backslash patterns on Windows
On Windows (MINGW), backslashes in pathspecs are silently converted to forward slashes (directory separators), which changes the glob semantics. This causes 36 test failures in t3070-wildmatch when the "via ls-files" variants test patterns containing backslash escapes (e.g. '\[ab]', '[\-_]', '[A-\\]'). The wildmatch function itself handles these patterns correctly — only the ls-files code path fails because pathspec parsing converts the backslashes before they reach the glob matcher. Skip these ls-files tests on platforms where BSLASHPSPEC is not set, which is the existing prereq that captures exactly this semantic: "backslashes in pathspec are not directory separators." Signed-off-by: Kristofer Karlsson <krka@spotify.com>
1 parent c69baaf commit dcc0bde

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

t/t3070-wildmatch.sh

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,13 @@ match_with_ls_files() {
9999
match_function=$4
100100
ls_files_args=$5
101101

102+
prereqs=EXPENSIVE_ON_WINDOWS
103+
case "$pattern" in
104+
*\\*)
105+
prereqs="$prereqs,BSLASHPSPEC"
106+
;;
107+
esac
108+
102109
match_stdout_stderr_cmp="
103110
tr -d '\0' <actual.raw >actual &&
104111
test_must_be_empty actual.err &&
@@ -108,36 +115,36 @@ match_with_ls_files() {
108115
then
109116
if test -e .git/created_test_file
110117
then
111-
test_expect_success EXPENSIVE_ON_WINDOWS "$match_function (via ls-files): match dies on '$pattern' '$text'" "
118+
test_expect_success $prereqs "$match_function (via ls-files): match dies on '$pattern' '$text'" "
112119
printf '%s' '$text' >expect &&
113120
test_must_fail git$ls_files_args ls-files -z -- '$pattern'
114121
"
115122
else
116-
test_expect_failure EXPENSIVE_ON_WINDOWS "$match_function (via ls-files): match skip '$pattern' '$text'" 'false'
123+
test_expect_failure $prereqs "$match_function (via ls-files): match skip '$pattern' '$text'" 'false'
117124
fi
118125
elif test "$match_expect" = 1
119126
then
120127
if test -e .git/created_test_file
121128
then
122-
test_expect_success EXPENSIVE_ON_WINDOWS "$match_function (via ls-files): match '$pattern' '$text'" "
129+
test_expect_success $prereqs "$match_function (via ls-files): match '$pattern' '$text'" "
123130
printf '%s' '$text' >expect &&
124131
git$ls_files_args ls-files -z -- '$pattern' >actual.raw 2>actual.err &&
125132
$match_stdout_stderr_cmp
126133
"
127134
else
128-
test_expect_failure EXPENSIVE_ON_WINDOWS "$match_function (via ls-files): match skip '$pattern' '$text'" 'false'
135+
test_expect_failure $prereqs "$match_function (via ls-files): match skip '$pattern' '$text'" 'false'
129136
fi
130137
elif test "$match_expect" = 0
131138
then
132139
if test -e .git/created_test_file
133140
then
134-
test_expect_success EXPENSIVE_ON_WINDOWS "$match_function (via ls-files): no match '$pattern' '$text'" "
141+
test_expect_success $prereqs "$match_function (via ls-files): no match '$pattern' '$text'" "
135142
>expect &&
136143
git$ls_files_args ls-files -z -- '$pattern' >actual.raw 2>actual.err &&
137144
$match_stdout_stderr_cmp
138145
"
139146
else
140-
test_expect_failure EXPENSIVE_ON_WINDOWS "$match_function (via ls-files): no match skip '$pattern' '$text'" 'false'
147+
test_expect_failure $prereqs "$match_function (via ls-files): no match skip '$pattern' '$text'" 'false'
141148
fi
142149
else
143150
test_expect_success "PANIC: Test framework error. Unknown matches value $match_expect" 'false'

0 commit comments

Comments
 (0)