about summary refs log tree commit homepage
path: root/xt
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2023-09-16 03:21:21 +0000
committerEric Wong <e@80x24.org>2023-09-16 12:12:51 +0000
commit217b26d007a7d9be3f0ae768e32a8a3e4807f27c (patch)
treed3b006f4a51bb99ea68a4fdc02e379f20e772756 /xt
parent584d2d5fc4fb458792aef93c9802126d0722dfb1 (diff)
downloadpublic-inbox-217b26d007a7d9be3f0ae768e32a8a3e4807f27c.tar.gz
This non-parallelized target is useful for noticing core dumps
and preventing them from being clobbered as we run the test
suite.  It will also notice leftover temporary files and
directories.

This make target was used on OpenBSD 7.3 to develop at least two
recent fixes:

e281363ba937 (lei: ensure we run DESTROY|END at daemon exit w/ kqueue)
759885e60e59 (lei: ensure --stdin sets %ENV and $current_lei)

I considered using a per-test TMPDIR for this to enable
parallelization, but on-filesystem UNIX sockets won't work
with excessively long path names.
Diffstat (limited to 'xt')
-rw-r--r--xt/check-debris.t30
1 files changed, 30 insertions, 0 deletions
diff --git a/xt/check-debris.t b/xt/check-debris.t
new file mode 100644
index 00000000..0bb5091d
--- /dev/null
+++ b/xt/check-debris.t
@@ -0,0 +1,30 @@
+#!perl -w
+use v5.12;
+use autodie qw(open);
+use PublicInbox::TestCommon;
+use File::Spec;
+my $tmpdir = File::Spec->tmpdir;
+
+diag "note: writes to `$tmpdir' by others results in false-positives";
+
+my %cur = map { $_ => 1 } glob("$tmpdir/*");
+for my $t (@ARGV ? @ARGV : glob('t/*.t')) {
+        open my $fh, '-|', $^X, '-w', $t;
+        my @out;
+        while (<$fh>) {
+                chomp;
+                push @out, $_;
+                next if /^ok / || /\A[0-9]+\.\.[0-9]+\z/;
+                diag $_;
+        }
+        ok(close($fh), $t) or diag(explain(\@out));
+
+        no_coredump($tmpdir);
+
+        my @remain = grep { !$cur{$_}++ } glob("$tmpdir/*");
+        next if !@remain;
+        is_deeply(\@remain, [], "$t has no leftovers") or
+                diag "$t added: ",explain(\@remain);
+}
+
+done_testing;