--- trunk/lib/Frey/Test/Runner.pm 2008/11/26 03:22:21 528 +++ trunk/lib/Frey/Test/Runner.pm 2008/12/09 20:31:37 776 @@ -8,6 +8,7 @@ use TAP::Harness; use TAP::Formatter::HTML; use Data::Dump qw/dump/; +use File::Slurp; use Frey::SVK; use Frey::PPI; @@ -18,7 +19,6 @@ required => 1, lazy => 1, # FIXME ask users which tests to run default => sub { -# [ glob('t/*.t') ] # all tests [ Frey::SVK->modified ] }, documentation => 'run tests which are result of modifications or whole full tests', @@ -60,13 +60,28 @@ }, ); -our $running; - sub as_markup { my ($self) = @_; - return 'allready running' if $running; - $running = 1; +=for later + + my $path = 'var/test/'; + my $running_pid = "$path/running.pid"; + + my $pid = read_file $running_pid if -e $running_pid; + if ( $pid ) { + if ( kill 0, $pid ) { + warn "ABORTING: $self allready running as pid $pid"; + return 'abort'; + } else { + warn "got $pid from $running_pid but no process alive, ignoring..."; + } + } + + write_file( $running_pid, $$ ); + warn "# started $self with pid $$ -> $running_pid"; + +=cut my $f = TAP::Formatter::HTML->new({ # silent => 1, @@ -86,6 +101,7 @@ if ( my $depends = $self->test_because ) { @tests = grep { $_ ne '' && + -e $_ && ! m{$0} # break recursion } sort keys %{ $depends } unless @tests; } @@ -94,8 +110,9 @@ if ( ! @tests ) { warn "can't find any tests ", dump( $self->tests ), " within depends ", dump( $self->test_because ); - warn "running all tests instead"; - @tests = glob('t/*.t'); +# warn "running all tests instead"; +# @tests = glob('t/*.t'); + @tests = ( qw{t/00-load.t t/pod.t} ); # XXX default tests } $self->title( join(' ', @tests ) ); @@ -129,15 +146,15 @@ $html =~ s{(t/(.+?)}{$3}sg; - $html = $self->editor_links( $html ); + $html = $self->html_links( $html ); if ( my $depends = $self->test_because ) { $html .= qq|Test dependencies:| . qq|| ; + } else { + warn "# test_because empty"; } $self->add_icon( $1 ) if $html =~ m{class="(passed|failed)"}; - $running = 0; +=for later + + unlink $running_pid or die "can't remove $running_pid: $!"; + +=cut + return $html; }