File: 11-cleanup.t

package info (click to toggle)
libdirectory-scratch-perl 0.18-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, stretch
  • size: 404 kB
  • ctags: 25
  • sloc: perl: 1,173; makefile: 2
file content (35 lines) | stat: -rw-r--r-- 787 bytes parent folder | download | duplicates (4)
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
#!/usr/bin/perl
# 11-cleanup.t 
# Copyright (c) 2006 Jonathan Rockway <jrockway@cpan.org>


use strict;
use warnings;
use Test::More tests=>8;
use Directory::Scratch;
use File::Path;

my $tmp = Directory::Scratch->new;
isa_ok($tmp, 'Directory::Scratch');
my $base_1 = $tmp->base;
$tmp->touch('foo');
ok(-e $base_1);
undef $tmp;
diag("Manually verify that $base_1 got cleaned up.");

$tmp = Directory::Scratch->new;
isa_ok($tmp, 'Directory::Scratch');
my $base = $tmp->base;
ok(-e $base);
$tmp->cleanup;
ok(!-e $base, 'explicitly cleaned up OK'); 

$tmp = Directory::Scratch->new(CLEANUP => 0);
isa_ok($tmp, 'Directory::Scratch');
$base = $tmp->base;
$SIG{__WARN__} = sub {};
ok(-e $base);
undef $tmp;
File::Path::rmtree($base->stringify, 0, 1);
ok(!-e $base, 'cleaned up manually OK');