use Test::More; use File::Find; use DBI; my $dbh = DBI->connect( ... ); my ($file_count) = $dbh->selectrow_array( 'SELECT count(*) FROM t' ); plan 'tests' => $tests_per_file * $file_count; find({ wanted => \&verify, follow_fast => 1 }, $storage_dir ); diag( "It's normal to run more tests than planned because files have been created since the records were counted" ); #### # before testing. my $results_db = 'test_results.db'; if ( ! unlink $results_db && -e $results_db ) { die "Can't unlink existing results db '$results_db': $!"; } my $db = tie my @test_results, 'DBM::Deep', 'test_results.db'; Test::More->builder->{Test_Results} = \@test_results; #### package Tie::StdArray::TestResults; use Tie::Array; @Tie::StdArray::TestResults::ISA = ( 'Tie::StdArray' ); use List::Util qw( first ); sub default_STORE { $_[0]->[$_[1]] = $_[2] } sub STORE { my ( $self, $index, $val ) = @_; return &default_STORE if ref $val ne ref {}; return &default_STORE if ! $val->{ok}; my $first_ok = first { ref $_ eq ref {} and $_->{ok} } @{ $self }; return &default_STORE if ! $first_ok; return $self->default_STORE( $index, $first_ok ); } package main; use Test::More; tie my @test_results, 'Tie::StdArray::TestResults'; Test::More->builder->{Test_Results} = \@test_results;