--- trunk/lib/Frey/Test/Runner.pm 2008/11/26 21:30:01 548 +++ trunk/lib/Frey/Test/Runner.pm 2008/11/26 22:29:13 549 @@ -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; @@ -60,13 +61,24 @@ }, ); -our $running; - sub as_markup { my ($self) = @_; - return 'allready running' if $running; - $running = 1; + 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 started twice"; + 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"; my $f = TAP::Formatter::HTML->new({ # silent => 1, @@ -155,7 +167,8 @@ $self->add_icon( $1 ) if $html =~ m{class="(passed|failed)"}; - $running = 0; + unlink $running_pid or die "can't remove $running_pid: $!"; + return $html; }