You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When creating a symlink file controlled by Test::MockFile calling symlink later would not update its location as show in the example below. readlink is returning an accurate value
use Test::More;
use Test::MockFile;
{
# unmocked version# cleanup on startupunlink('/bin/foo');
unlink('/not/there');
# create a symlink
ok symlink( '/not-there', '/bin/foo' );
ok -l'/bin/foo';
is readlink('/bin/foo'), '/not-there';
ok !-e'/bin/foo';
ok unlink('/bin/foo');
ok !-l'/bin/foo';
ok symlink( '/abcd', '/bin/foo' );
is readlink('/bin/foo'), '/abcd', 'symlink now points to /abcd';
}
{
# now testing with MockFile# cleanupunlink('/bin/foo');
unlink('/not/there');
# we want to take control of that file and set it as a symlinkmy$mock_bin_foo = Test::MockFile->symlink( "/not-there", "/bin/foo" );
ok -l'/bin/foo';
is readlink('/bin/foo'), '/not-there';
ok !-e'/bin/foo';
ok unlink('/bin/foo');
ok !-l'/bin/foo';
ok symlink( '/abcd', '/bin/foo' );
is readlink('/bin/foo'), '/abcd', 'symlink now points to /abcd';
# ^^ symlink on a Test::MockFile symlinked file is not updating its location
}
done_testing;
output
ok 1
ok 2
ok 3
ok 4
ok 5
ok 6
ok 7
ok 8 - symlink now points to /abcd
ok 9
ok 10
ok 11
ok 12
ok 13
ok 14
not ok 15 - symlink now points to /abcd
# Failed test 'symlink now points to /abcd'
# at test.t line X.
# got: undef
# expected: '/abcd'
1..15
The text was updated successfully, but these errors were encountered:
hacked (and I do mean hack, lol, because this test will never need a real symlink) around it for now:
use Test::MockFile;
BEGIN {
*CORE::GLOBAL::symlink = sub {
my ( $target, $symlink ) = @_;
$Test::MockFile::files_being_mocked{$symlink}->{readlink} = $target;
};
}
may need to do same w/ readlink() ➜ it was correct but it may have been reading from the file system symlink that symlink() created.
When creating a symlink file controlled by Test::MockFile calling
symlink
later would not update its location as show in the example below.readlink
is returning an accurate valueoutput
The text was updated successfully, but these errors were encountered: