$SIG
{__DIE__} =
sub
{ confess
@_
; };
BEGIN { plan
tests
=> 2 +
$CACHE_TESTS
+ 3 + 1 }
use_ok(
'Cache::File'
);
{
my
$tempdir
= tempdir(
CLEANUP
=> 1);
my
$cache
= Cache::File->new(
cache_root
=>
$tempdir
,
lock_level
=> Cache::File::LOCK_NFS());
ok(
$cache
,
'Cache created'
);
run_cache_tests(
$cache
);
}
{
my
$tempdir
= tempdir(
CLEANUP
=> 1);
my
$cache
= Cache::File->new(
cache_root
=>
$tempdir
,);
{
my
$warning
;
{
local
$SIG
{__WARN__} =
sub
{
$warning
=
shift
; };
$cache
->set (
'test'
, {
x
=> 23},
'10 s'
);
}
like (
$warning
,
qr/\AReference passed to set/
,
"Got the right warning on passing a reference to set."
)
}
}
{
umask
077;
my
$tempdir
= tempdir(
CLEANUP
=> 1);
my
$cache
= Cache::File->new(
cache_root
=>
$tempdir
,
cache_umask
=> 070);
ok(
$cache
,
'Cache created'
);
my
$entry
=
$cache
->set(
'key1'
,
'data1'
);
is(
$cache
->count(), 1,
'Added entry'
);
my
$valid
= 0;
sub
wanted {
return
if
$_
eq
$tempdir
;
my
(
undef
,
undef
,
$mode
) =
lstat
(
$_
) or
die
"lstat failed"
;
$mode
&= 0777;
(-d and
$mode
== 0707) or (not -d and
$mode
== 0606)
or
die
'bad permissions ('
.
sprintf
(
'%04o'
,
$mode
).
") on $_"
;
}
eval
{ File::Find::find({
wanted
=> \
&wanted
,
no_chdir
=> 1 },
$tempdir
) };
die
if
($@ and $@ !~ /^bad permissions/);
warn
$@
if
$@;
ok((not $@),
"Permissions are good"
);
}