#!/usr/bin/perl
BEGIN {
$| = 1;
$^W = 1;
}
use
lib catdir(
't'
,
'lib'
);
BEGIN {
my
$testdir
= catdir(
't'
,
'lib'
);
ok( -d
$testdir
,
'Found test modules directory'
);
lib->
import
(
$testdir
);
}
my
$background
= catfile(
't'
,
'background_file.txt'
);
File::Remove::clear(
$background
);
open
( FILE,
'>'
,
$background
) or
die
"Failed to open test file to write"
;
print
FILE
"Test content\n"
;
close
FILE;
SCOPE: {
my
$remover
= MyBackgroundProcess->new(
file
=>
$background
);
isa_ok(
$remover
,
'MyBackgroundProcess'
);
isa_ok(
$remover
,
'Process'
);
isa_ok(
$remover
,
'Process::Backgroundable'
);
can_ok(
$remover
,
'background'
);
SCOPE: {
local
@Process::Backgroundable::PERLCMD
= (
@Process::Backgroundable::PERLCMD
,
'-I'
. catdir(
'blib'
,
'lib'
),
'-I'
. catdir(
't'
,
'lib'
),
);
ok(
$remover
->background,
'->background returns ok'
);
}
ok( -f
$background
,
'Test file still exists after ->background call'
);
sleep
3;
ok( ! -f
$background
,
'Test file is removed correctly'
);
}