File: link.t

package info (click to toggle)
libio-all-perl 0.87-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 712 kB
  • sloc: perl: 2,017; makefile: 5
file content (35 lines) | stat: -rw-r--r-- 1,263 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
use strict; use warnings;
use lib -e 't' ? 't' : 'test';
use Test::More;
use IO::All;
use IO_All_Test;
use Cwd qw(abs_path);

my $cwd = abs_path('.');
eval { symlink(defined($ENV{AUTOPKGTEST_TMP}) ? '/usr/share/perl5/IO/All.pm' : "$cwd/lib/IO/All.pm", o_dir() . '/IO-All-file-link') or die $! };

if ($@ or not (-e o_dir() . '/IO-All-file-link' and -l o_dir() . '/IO-All-file-link')) {
    plan skip_all => 'Cannot call symlink on this platform';
}
else {
    plan tests => 7;
}

my $file_link = io(o_dir() . '/IO-All-file-link');
ok($file_link->is_link, 'Link to file is a link (not a file)');
my $file_target = $file_link->readlink;
ok(! $file_target->is_link, 'readlink returns file object, not link' );
is($file_target->filename, 'All.pm', 'link target is expected file' );

symlink( defined($ENV{AUTOPKGTEST_TMP}) ? '/usr/share/perl5/IO' : "$cwd/lib/IO", o_dir() . '/IO-All-dir-link');

my $dir_link = io(o_dir() . '/IO-All-dir-link');
ok($dir_link->is_link, 'Link to dir is a link (not a dir)');
my $dir_target = $dir_link->readlink;
ok(! $dir_target->is_link, 'readlink returns dir object, not link' );
ok($dir_target->is_dir, 'readlink returns dir object, not link' );
is($dir_target->filename, 'IO', 'link target is expected dir' );



del_output_dir();