about summary refs log tree commit homepage
path: root/t
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2020-12-31 13:51:54 +0000
committerEric Wong <e@80x24.org>2021-01-01 05:00:40 +0000
commit0d6777e0389fe2db3edce41d675320746433f5b7 (patch)
treebd74fac722a93a2432e472e9b5c9797a41737f5f /t
parent3823705b72199c61e8ed96aabd34d21a63fe153c (diff)
downloadpublic-inbox-0d6777e0389fe2db3edce41d675320746433f5b7.tar.gz
Since we'll be forking for Xapian indexing and maybe
other places, having a simple guard in place to ensure
OnDestroy doesn't unexpectedly unlink files or similar
is a safer option.
Diffstat (limited to 't')
-rw-r--r--t/on_destroy.t9
1 files changed, 9 insertions, 0 deletions
diff --git a/t/on_destroy.t b/t/on_destroy.t
index 8b85b48e..0de67d0b 100644
--- a/t/on_destroy.t
+++ b/t/on_destroy.t
@@ -16,6 +16,15 @@ $od = PublicInbox::OnDestroy->new(sub { @x = @_ }, qw(x y));
 undef $od;
 is_deeply(\@x, [ 'x', 'y' ], '2 args passed');
 
+open my $tmp, '+>>', undef or BAIL_OUT $!;
+$tmp->autoflush(1);
+$od = PublicInbox::OnDestroy->new(1, sub { print $tmp "$$ DESTROY\n" });
+undef $od;
+is(-s $tmp, 0, '$tmp is empty on pid mismatch');
+$od = PublicInbox::OnDestroy->new($$, sub { $tmp = $$ });
+undef $od;
+is($tmp, $$, '$tmp set to $$ by callback');
+
 if (my $nr = $ENV{TEST_LEAK_NR}) {
         for (0..$nr) {
                 $od = PublicInbox::OnDestroy->new(sub { @x = @_ }, qw(x y));