]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
t/ipc: improve test reliability
authorEric Wong <e@80x24.org>
Tue, 26 Aug 2025 19:50:44 +0000 (19:50 +0000)
committerEric Wong <e@80x24.org>
Thu, 28 Aug 2025 18:48:16 +0000 (18:48 +0000)
->wq_close works asynchronously, nowadays, so processes may
not be completely done writing warnings when the parent process
reads the file.  We'll test some untested methods after test_die
to ensure the worker has had time to write the exception to the
warning log.  Finally, we'll explain warning contents on failure
in case it happens again.

t/ipc.t

diff --git a/t/ipc.t b/t/ipc.t
index d6a4b3414187fc7c782622da24b17945aa3116f4..fa1b040514f35d676c0f846d71d7b45dbad431bd 100644 (file)
--- a/t/ipc.t
+++ b/t/ipc.t
@@ -168,6 +168,10 @@ SKIP: {
        my $exp = bless ['blessed'], 'PublicInbox::WTF';
        my $ret = eval { $ipc->wq_do('test_die', $exp) };
        is_deeply($@, $exp, 'die with blessed ref');
+       $s = $ipc->wq_do('test_scalarref');
+       is_xdeeply $s, \'scalarref', 'scalar ref returned';
+       $s = $ipc->wq_do('test_undef');
+       is $s, undef, 'undef returned';
 }
 
 $ipc->wq_close;
@@ -175,7 +179,7 @@ SKIP: {
        require_mods '+SCM_RIGHTS', 1;
        seek $warn, 0, SEEK_SET;
        my @warn = <$warn>;
-       is(scalar(@warn), 2, 'warned 3 times');
+       is(scalar(@warn), 2, 'warned 3 times') or diag explain(\@warn);
        like($warn[0], qr/ wq_worker: /, '2nd warned from wq_worker');
        is($warn[0], $warn[1], 'worker did not die');