Debian Codegraph @

t/5persist/symlink.t

raw
1 #
2 # make sure persist really writes where its supposed to.
3 #
4 use strict;
5 use warnings;
6 use File::Spec ();
7
8 BEGIN {
9 my $eummh = File::Spec->catfile(qw(ulib EUMM.h));
10 open my $fh, '<', $eummh or die "open: $eummh: $!";
11 my $conf = join '', <$fh>;
12 return 1 if $conf =~ /define HAVE_SYMLINK/;
13 print "1..0 # SKIP no symlinks\n";
14 exit 0;
15 }
16
17 use MyTest;
18 use File::Temp ();
19 use vars qw(@OPTS $TMPDIR $TARG $FULL);
20
21 BEGIN {
22 $TMPDIR = File::Temp::tempdir('UUID-test-XXXXXXXX', TMPDIR => 1, CLEANUP => 1);
23 ok -d $TMPDIR, 'tmpdir exists';
24
25 $TARG = 'foo.txt';
26 $FULL = File::Spec->catdir($TMPDIR, $TARG);
27
28 my $newfile = File::Spec->catfile($TMPDIR, 'state.txt');
29
30 symlink $TARG, $newfile;
31 ok -l $newfile, 'symlink exists';
32
33 @OPTS = ":persist=$newfile";
34 }
35
36 use UUID @OPTS;
37
38 ok 1, 'loaded';
39
40 my $uu = UUID::uuid1();
41 # is it a uuid?
42 is length($uu), 36, 'uuid length';
43 like $uu, qr/^[-0-9a-f]{36}$/, 'uuid looks ok';
44
45 # is the target in the tmpdir?
46 ok !-e $FULL, 'target exists';
47
48 done_testing;