From 9e833f09bb7d410f692ed0fe40a08611830a59e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20H=C3=A6gland?= Date: Sat, 19 Nov 2022 22:25:55 +0100 Subject: [PATCH] Fix forward slashes in symlink target on Windows This fixes issue #271 --- t/symlinks.t | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/t/symlinks.t b/t/symlinks.t index 9e1a6f5..df907f4 100644 --- a/t/symlinks.t +++ b/t/symlinks.t @@ -19,12 +19,16 @@ subtest "relative symlinks with updir" => sub { my $foo = $td->child(qw/tmp foo/)->touch; my $bar = $td->child(qw/tmp tmp2 bar/); - symlink "../foo", $bar or die "Failed to symlink: $!\n"; + my $relpath = "../foo"; + # Account for a bug in Win32 API, see https://github.com/Perl/perl5/issues/20506 + # for more information + $relpath = "..\\foo" if $^O eq "MSWin32"; + symlink $relpath, $bar or die "Failed to symlink: $!\n"; ok -f $foo, "it's a file"; ok -l $bar, "it's a link"; - is readlink $bar, "../foo", "the link seems right"; + is readlink $bar, $relpath, "the link seems right"; is abs_path($bar), $foo, "abs_path gets's it right"; is $bar->realpath, $foo, "realpath get's it right";