aboutsummaryrefslogtreecommitdiff
path: root/t/02auto.t
blob: 0a01d84d911bebd5b0f4265191b2e3be213e4da3 (plain)
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
36
37
38
39
40
41
42
43
44
# -*- perl -*-
use lib qw(t lib);
use strict;
use TestBackup;
use File::BackupCopy qw(backup_copy_numbered backup_copy_auto);
    
plan test => 16;

makefile('a');

my $name = backup_copy_auto('a');
ok($name, 'a~');
fileok('a', $name);

$name = backup_copy_numbered('a');
ok($name, 'a.~1~');
fileok('a', $name);
    
$name = backup_copy_auto('a');
ok($name, 'a.~2~');
fileok('a', $name);

mkdir "subdir";
$name = backup_copy_auto('a', dir => 'subdir');
ok($name, File::Spec->catfile('subdir','a~'));
fileok('a', $name);

$name = backup_copy_auto('a', dir => 'subdir');
ok($name, File::Spec->catfile('subdir','a~'));
fileok('a', $name);

ok(open(FH, '>', File::Spec->catfile('subdir','a.~1~')));
$name = backup_copy_auto('a', dir => 'subdir');
ok($name, File::Spec->catfile('subdir','a.~2~'));
fileok('a', $name);

eval {
    backup_copy_auto('a', dir => 'nonexisting');
};
ok(!!$@);

$name = backup_copy_auto('a', dir => 'nonexisting', error => \my $err);
ok(!defined($name));
ok(defined($err) && $err ne '');

Return to:

Send suggestions and report system problems to the System administrator.