Hi All.

I was impressed recently with py.test, a new-ish testing tool in the python world and wanted to snag one of their features for prove.

This patch adds a --session flag to prove that will make prove continually run and re-run any modified tests. Ideally, it would also re-run failed tests.

This is not designed as a replacement for a cron'd prove. The way i see it being used is in a terminal window adjacent to an editing session while trying to nail down a problem.

Thoughts?

-jason gessner
    [EMAIL PROTECTED]


23a24
> my $session = 0;
42a44
>     'session'       => \$session,
80,87c82,121
< my @tests;
< @ARGV = File::Spec->curdir unless @ARGV;
< push( @tests, -d $_ ? all_in( $_ ) : $_ ) for map { glob } @ARGV;
< 
< if ( @tests ) {
<     shuffle(@tests) if $shuffle;
<     if ( $dry ) {
<         print join( "\n", @tests, "" );
---
> my @session_tests;
> my %test_mods;
> 
> my $run_tests = 1;
> 
> while ( $run_tests ) {
>     my @tests;
> 
>     @ARGV = File::Spec->curdir unless @ARGV;
>     push( @tests, -d $_ ? all_in( $_ ) : $_ ) for map { glob } @ARGV;
> 
>     if ( @tests ) {
>         shuffle(@tests) if $shuffle;
>         if ( $dry ) {
>             print join( "\n", @tests, "" );
>         } else {
>             print "# ", scalar @tests, " tests to run\n" if 
> $Test::Harness::debug;
> 
>             if ( $session ) {
>                 # if we are running in "session" mode, let's build our 
>                 # list of tests out of the new files and modified files 
>                 # only.  The first run will have all of the files.
>                 my @sess_tests;
>                 foreach my $index ( 0 .. $#tests ) {
>                     if ( !exists $test_mods{$tests[$index]} || (stat 
> $tests[$index])[9] > $test_mods{$tests[$index]} ) {
>                         push @sess_tests, $tests[$index];
>                    }
>                 }
>                 @tests = @sess_tests;
>             }
>             
>             my $results = eval {runtests(@tests) } if @tests;
>         }
>     }
> 
>     if ( $session ) {
>         sleep(5);
>         foreach my $index ( 0 .. $#tests ) {
>             $test_mods{$tests[$index]} = (stat $tests[$index])[9]; 
>         }
89,90c123
<         print "# ", scalar @tests, " tests to run\n" if $Test::Harness::debug;
<         runtests(@tests);
---
>         $run_tests = 0;
91a125
> 

Reply via email to