Skip to content

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

@atoomic

Description

@atoomic

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions