diff mbox series

[1/5] t7300: work around platform-specific behaviour with long paths on MinGW

Message ID bdaf16a06168b7320e8dd1115258f00745a104c7.1728480039.git.ps@pks.im (mailing list archive)
State New
Headers show
Series Wire up Windows-based jobs in GitLab CI | expand

Commit Message

Patrick Steinhardt Oct. 9, 2024, 1:25 p.m. UTC
Windows by default has a restriction in place to only allow paths up to
260 characters. This restriction can nowadays be lifted by setting a
registry key, but is still active by default.

In t7300 we have one test that exercises the behaviour of git-clean(1)
with such long paths. Interestingly enough, this test fails on my system
that uses Windows 10 with mingw-w64 installed via MSYS2: instead of
observing ENAMETOOLONG, we observe ENOENT. This behaviour is consistent
across multiple different environments I have tried.

I cannot say why exactly we observe a different error here, but I would
not be surprised if this was either dependent on the Windows version,
the version of MinGW, the current working directory of Git or any kind
of combination of these.

Work around the issue by handling both errors.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 t/t7300-clean.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Junio C Hamano Oct. 9, 2024, 6:31 p.m. UTC | #1
Patrick Steinhardt <ps@pks.im> writes:

> diff --git a/t/t7300-clean.sh b/t/t7300-clean.sh
> index 0aae0dee67..12ab25296b 100755
> --- a/t/t7300-clean.sh
> +++ b/t/t7300-clean.sh
> @@ -747,7 +747,7 @@ test_expect_success MINGW 'handle clean & core.longpaths = false nicely' '
>  	test_must_fail git clean -xdf 2>.git/err &&
>  	# grepping for a strerror string is unportable but it is OK here with
>  	# MINGW prereq

I find it amusing that this talks about limiting the test to MINGW
yet we need to accept two variants ;-)

> -	test_grep "too long" .git/err
> +	test_grep -e "too long" -e "No such file or directory" .git/err
>  '

The solution looks obviously good enough.

Thanks.
Patrick Steinhardt Oct. 10, 2024, 5:56 a.m. UTC | #2
On Wed, Oct 09, 2024 at 11:31:25AM -0700, Junio C Hamano wrote:
> Patrick Steinhardt <ps@pks.im> writes:
> 
> > diff --git a/t/t7300-clean.sh b/t/t7300-clean.sh
> > index 0aae0dee67..12ab25296b 100755
> > --- a/t/t7300-clean.sh
> > +++ b/t/t7300-clean.sh
> > @@ -747,7 +747,7 @@ test_expect_success MINGW 'handle clean & core.longpaths = false nicely' '
> >  	test_must_fail git clean -xdf 2>.git/err &&
> >  	# grepping for a strerror string is unportable but it is OK here with
> >  	# MINGW prereq
> 
> I find it amusing that this talks about limiting the test to MINGW
> yet we need to accept two variants ;-)

Agreed, I was quite confused by this. I hope that Johannes may shed a
bit more light on this, as I couldn't make much sense of it. Was this a
change on our side? Did MinGW change? Is it something else entirely? No
idea.

Patrick
diff mbox series

Patch

diff --git a/t/t7300-clean.sh b/t/t7300-clean.sh
index 0aae0dee67..12ab25296b 100755
--- a/t/t7300-clean.sh
+++ b/t/t7300-clean.sh
@@ -747,7 +747,7 @@  test_expect_success MINGW 'handle clean & core.longpaths = false nicely' '
 	test_must_fail git clean -xdf 2>.git/err &&
 	# grepping for a strerror string is unportable but it is OK here with
 	# MINGW prereq
-	test_grep "too long" .git/err
+	test_grep -e "too long" -e "No such file or directory" .git/err
 '
 
 test_expect_success 'clean untracked paths by pathspec' '