Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test::MockFile symlinks does not play nice with Cwd... #139

Open
atoomic opened this issue Feb 11, 2022 · 1 comment
Open

Test::MockFile symlinks does not play nice with Cwd... #139

atoomic opened this issue Feb 11, 2022 · 1 comment

Comments

@atoomic
Copy link
Contributor

atoomic commented Feb 11, 2022

When monitoring a symlink under T::MF
the perl internals readlink works fine but Cwd::abs_path is a failure...

unfortunately not having this working would either push to avoid Cwd in production code
or avoid T::MF in tests...

here is an example:

#!perl

use Test::MockFile qw{nostrict};

use Cwd;

use Test::More;

my ( $SRC, $DST ) = ( '/src', '/dest' );

# cleanup
unlink $SRC if -e $SRC;
unlink $DST if -l $DST;

symlink( $SRC, $DST );

ok -l $DST;
ok readlink( $DST ), $SRC;

my $mock = Test::MockFile->symlink( '/different', $DST );
is readlink( $DST ), '/different', 'readlink';
is Cwd::abs_path( $DST ), '/different', 'Cwd';

output

╰─> perl -Ilib test.pl
ok 1
ok 2 - /src
ok 3 - readlink
not ok 4 - Cwd
#   Failed test 'Cwd'
#   at test.pl line 22.
#          got: '/src'
#     expected: '/different'
# Tests were run but no plan was declared and done_testing() was not seen.
@xsawyerx
Copy link
Contributor

I don't see how we can make Cwd::abs_path() without being... "creative." It's implemented in XS: https://metacpan.org/release/XSAWYERX/PathTools-3.75/source/Cwd.xs#L583

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants