]> Sergey Matveev's repositories - public-inbox.git/commitdiff
tests: make slow tests easier-to-find
authorEric Wong <e@80x24.org>
Mon, 30 Jan 2023 04:30:58 +0000 (04:30 +0000)
committerEric Wong <e@80x24.org>
Mon, 30 Jan 2023 06:42:43 +0000 (06:42 +0000)
t/run.perl now prints slowest 10 tests at startup, and I've
added ./devel/longest-tests to print all tests sorted by
elapsed time.

This should allow us to notice outliers more quickly in the
future.

MANIFEST
devel/longest-tests [new file with mode: 0755]
t/run.perl

index f22f60aa217fa6b95825830a81cf0bfc64e6b47c..aba32762a4073b2018684e1dfcd0e542266dacae 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -121,6 +121,7 @@ contrib/css/README
 contrib/selinux/el7/publicinbox.fc
 contrib/selinux/el7/publicinbox.te
 devel/README
+devel/longest-tests
 devel/syscall-list
 examples/README
 examples/README.unsubscribe
diff --git a/devel/longest-tests b/devel/longest-tests
new file mode 100755 (executable)
index 0000000..bf46e16
--- /dev/null
@@ -0,0 +1,7 @@
+eval 'exec perl -wS $0 ${1+"$@"}' # this script is too short to copyright
+if 0; # running under some shell
+use v5.12; use autodie; use YAML::XS qw(Load);
+open(my $fh, '<', shift // '.prove');
+my $t = Load(do { local $/; <$fh> })->{tests};
+my @t = sort { $t->{$b}->{elapsed} <=> $t->{$a}->{elapsed} } keys %$t;
+printf "%0.6f %s\n", $t->{$_}->{elapsed}, $_ for @t;
index b90715a6ffe09ce86d04e84ad7d7b1f5b71c604d..f68dab607f2693c53edb9d517b9ff93150fbae5a 100755 (executable)
@@ -85,6 +85,10 @@ if ($shuffle) {
        @tests = sort {
                ($t->{$b}->{elapsed} // 0) <=> ($t->{$a}->{elapsed} // 0)
        } @tests;
+       say "# top 10 longest tests (`make check' regenerates)";
+       for (@tests[0..9]) {
+               printf "# %0.6f %s\n", $t->{$_}->{elapsed}, $_;
+       }
 }
 
 our $tb = Test::More->builder;