/[Frey]/trunk/lib/Frey/Test/Runner.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/Frey/Test/Runner.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 528 by dpavlin, Wed Nov 26 03:22:21 2008 UTC revision 570 by dpavlin, Thu Nov 27 22:11:13 2008 UTC
# Line 8  with 'Frey::Storage'; Line 8  with 'Frey::Storage';
8  use TAP::Harness;  use TAP::Harness;
9  use TAP::Formatter::HTML;  use TAP::Formatter::HTML;
10  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
11    use File::Slurp;
12    
13  use Frey::SVK;  use Frey::SVK;
14  use Frey::PPI;  use Frey::PPI;
# Line 18  has tests => ( Line 19  has tests => (
19          required => 1,          required => 1,
20          lazy => 1, # FIXME ask users which tests to run          lazy => 1, # FIXME ask users which tests to run
21          default => sub {          default => sub {
 #               [ glob('t/*.t') ] # all tests  
22                  [ Frey::SVK->modified ]                  [ Frey::SVK->modified ]
23          },          },
24          documentation => 'run tests which are result of modifications or whole full tests',          documentation => 'run tests which are result of modifications or whole full tests',
# Line 60  has test_because => ( Line 60  has test_because => (
60          },          },
61  );  );
62    
 our $running;  
   
63  sub as_markup {  sub as_markup {
64          my ($self) = @_;          my ($self) = @_;
65    
66          return 'allready running' if $running;          my $path = 'var/test/';
67          $running = 1;          my $running_pid = "$path/running.pid";
68    
69            my $pid = read_file $running_pid if -e $running_pid;
70            if ( $pid ) {
71                    if ( kill 0, $pid ) {
72                            warn "ABORTING: $self started twice";
73                            return 'abort';
74                    } else {
75                            warn "got $pid from $running_pid but no process alive, ignoring...";
76                    }
77            }
78    
79            write_file( $running_pid, $$ );
80            warn "# started $self with pid $$ -> $running_pid";
81    
82          my $f = TAP::Formatter::HTML->new({          my $f = TAP::Formatter::HTML->new({
83  #               silent => 1,  #               silent => 1,
# Line 94  sub as_markup { Line 105  sub as_markup {
105    
106          if ( ! @tests ) {          if ( ! @tests ) {
107                  warn "can't find any tests ", dump( $self->tests ), " within depends ", dump( $self->test_because );                  warn "can't find any tests ", dump( $self->tests ), " within depends ", dump( $self->test_because );
108                  warn "running all tests instead";  #               warn "running all tests instead";
109                  @tests = glob('t/*.t');  #               @tests = glob('t/*.t');
110                    @tests = glob('t/01*.t'); # XXX default tests
111          }          }
112    
113          $self->title( join(' ', @tests ) );          $self->title( join(' ', @tests ) );
# Line 151  sub as_markup { Line 163  sub as_markup {
163                          } @tests )                          } @tests )
164                  . qq|</li></ul>|                  . qq|</li></ul>|
165                  ;                  ;
166            } else {
167                    warn "# test_because empty";
168          }          }
169    
170          $self->add_icon( $1 ) if $html =~ m{class="(passed|failed)"};          $self->add_icon( $1 ) if $html =~ m{class="(passed|failed)"};
171    
172          $running = 0;          unlink $running_pid or die "can't remove $running_pid: $!";
173    
174          return $html;          return $html;
175  }  }
176    

Legend:
Removed from v.528  
changed lines
  Added in v.570

  ViewVC Help
Powered by ViewVC 1.1.26