From: Nicholas Clark Date: Sat, 9 Aug 2008 20:11:55 +0000 (+0000) Subject: Use App::Prove::State to store the timings for the tests, and if X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0279961e65f24cb3d5407ae9771030dcc5eb6882;p=p5sagit%2Fp5-mst-13.2.git Use App::Prove::State to store the timings for the tests, and if timings are available, reorder the parallelisable tests to run the slowest first. Timings for a second run are 18 seconds less for me: Files=1553, Tests=209393, 459 wallclock secs (94.89 usr 13.16 sys + 638.19 cusr 58.59 csys = 804.83 CPU) Files=1553, Tests=209393, 441 wallclock secs (82.83 usr 13.90 sys + 622.13 cusr 59.20 csys = 778.06 CPU) p4raw-id: //depot/perl@34192 --- diff --git a/Makefile.SH b/Makefile.SH index 04bdabd..fa109a8 100644 --- a/Makefile.SH +++ b/Makefile.SH @@ -1098,6 +1098,7 @@ realclean: cleanup_unpacked_files _realcleaner _mopup _clobber: -@rm -f Cross/run-* Cross/to-* Cross/from-* + rm -f t/test_state rm -f config.sh cppstdin Policy.sh extras.lst clobber: cleanup_unpacked_files _realcleaner _mopup _clobber diff --git a/t/harness b/t/harness index a701fc7..8a4e9b4 100644 --- a/t/harness +++ b/t/harness @@ -46,7 +46,7 @@ foreach (keys %datahandle) { unlink "$_.t"; } -my (@tests, $rules, $re); +my (@tests, $re); # [.VMS]TEST.COM calls harness with empty arguments, so clean-up @ARGV @ARGV = grep $_ && length( $_ ) => @ARGV; @@ -100,7 +100,11 @@ if ($ARGV[0] && $ARGV[0]=~/^-re/) { } } +my $jobs = $ENV{TEST_JOBS}; +my ($rules, $state); + if (@ARGV) { + # If you want these run in speed order, just use prove if ($^O eq 'MSWin32') { @tests = map(glob($_),@ARGV); } @@ -123,15 +127,35 @@ if (@ARGV) { # nice to get the tests in t/op/*.t able to run in parallel. unless (@tests) { - my @seq; - push @seq, ; + my @seq = ; my @next = qw(comp cmd run io op uni mro lib); push @next, 'japh' if $torture; push @next, 'win32' if $^O eq 'MSWin32'; - push @seq, { par => [ + # Hopefully TAP::Parser::Scheduler will support this syntax soon. + # my $next = { par => '{' . join (',', @next) . '}/*.t' }; + my $next = { par => [ map { "$_/*.t" } @next ] }; + @tests = _extract_tests ($next); + + # This is a bit of a game, because we only want to sort these tests in + # speed order. base/*.t wants to run first, and ext,lib etc last and in + # MANIFEST order + if ($jobs) { + require App::Prove::State; + $state = App::Prove::State->new({ store => 'test_state' }); + $state->apply_switch('slow', 'save'); + # For some reason get_tests returns *all* the tests previously run, + # (in the right order), not simply the selection in @tests + # (in the right order). Not sure if this is a bug or a feature. + # Whatever, *we* are only interested in the ones that are in @tests + my %seen; + @seen{@tests} = (); + @tests = grep {exists $seen{$_} } $state->get_tests(0, @tests); + } + @tests = (@seq, @tests); + push @seq, $next; my @last; use Config; @@ -171,12 +195,11 @@ if (@ARGV) { push @last, ; push @last, ; - @tests = (_extract_tests (@seq), @last); + push @tests, @last; push @seq, _seq_dir_rules @last; $rules = { seq => \@seq }; - } } if ($^O eq 'MSWin32') { @@ -185,10 +208,16 @@ if ($^O eq 'MSWin32') { @tests=grep /$re/, @tests if $re; -my $jobs = $ENV{TEST_JOBS}; if ($jobs) { eval 'use TAP::Harness 3.13; 1' or die $@; my $h = TAP::Harness->new({ jobs => $jobs, rules => $rules}); + if ($state) { + $h->callback( + after_test => sub { + $state->observe_test(@_); + } + ); + } $h->runtests(@tests); } else { Test::Harness::runtests @tests; diff --git a/vms/descrip_mms.template b/vms/descrip_mms.template index dfc876e..5b371c3 100644 --- a/vms/descrip_mms.template +++ b/vms/descrip_mms.template @@ -1865,6 +1865,7 @@ realclean : clean - If F$Search("[...]*$(E)").nes."" Then Delete/NoConfirm/Log [...]*$(E);* - If F$Search("[.vms]Perl_Setup.Com").nes."" Then Delete/NoConfirm/Log [.vms]Perl_Setup.Com;* - If F$Search("[.t]rantests.").nes."" Then Delete/NoConfirm/Log [.t]rantests.;* + - If F$Search("[.t]test_state.").nes."" Then Delete/NoConfirm/Log [.t]test_state.;* - If F$Search("[.t.lib]vmsfspec.t").nes."" Then Delete/NoConfirm/Log [.t.lib]vmsfspec.t;* - If F$Search("[.t.lib]vmsish.t").nes."" Then Delete/NoConfirm/Log [.t.lib]vmsish.t;* - If F$Search("[.t.lib]vms_dclsym.t").nes."" Then Delete/NoConfirm/Log [.t.lib]vms_dclsym.t;* diff --git a/win32/Makefile b/win32/Makefile index 35aa452..adf57dc 100644 --- a/win32/Makefile +++ b/win32/Makefile @@ -1225,6 +1225,7 @@ distclean: realclean -if exist pod2htmd.tmp del pod2htmd.tmp -if exist pod2htmi.tmp del pod2htmi.tmp -if exist $(HTMLDIR) rmdir /s /q $(HTMLDIR) + -del /f ..\t\test_state install : all installbare installhtml diff --git a/win32/Makefile.ce b/win32/Makefile.ce index fbca695..4065c9c 100644 --- a/win32/Makefile.ce +++ b/win32/Makefile.ce @@ -779,6 +779,7 @@ clean: -rm -f $(MACHINE)/*.lib -rm -f ../config.sh ../lib/Config.pm -rm -f config.h xconfig.h perl.res + -rm -f ../t/test_state XDLLOBJS = \ $(DLLDIR)\av.obj \ diff --git a/win32/makefile.mk b/win32/makefile.mk index 3ef3d0b..6ff01a6 100644 --- a/win32/makefile.mk +++ b/win32/makefile.mk @@ -1549,6 +1549,7 @@ distclean: realclean -if exist pod2htmd.tmp del pod2htmd.tmp -if exist pod2htmi.tmp del pod2htmi.tmp -if exist $(HTMLDIR) rmdir /s /q $(HTMLDIR) + -del /f ..\t\test_state install : all installbare installhtml