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; |
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', |
30 |
documentation => 'run only this single test', |
documentation => 'run only this single test', |
31 |
); |
); |
32 |
|
|
33 |
has depends => ( |
has test_because => ( |
34 |
|
documentation => 'returns classes responsable for each test run', |
35 |
is => 'rw', |
is => 'rw', |
36 |
# isa => 'HashRef[Hashref[Int]', |
# isa => 'HashRef[Hashref[Int]', |
37 |
required => 1, |
required => 1, |
63 |
sub as_markup { |
sub as_markup { |
64 |
my ($self) = @_; |
my ($self) = @_; |
65 |
|
|
66 |
|
my $path = 'var/test/'; |
67 |
|
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, |
84 |
|
|
94 |
|
|
95 |
@tests = ( $self->test ) if $self->test; |
@tests = ( $self->test ) if $self->test; |
96 |
|
|
97 |
if ( my $depends = $self->depends ) { |
if ( my $depends = $self->test_because ) { |
98 |
@tests = grep { |
@tests = grep { |
99 |
$_ ne '' && |
$_ ne '' && |
100 |
! m{$0} # break recursion |
! m{$0} # break recursion |
101 |
} sort keys %{ $depends } unless @tests; |
} sort keys %{ $depends } unless @tests; |
102 |
} |
} |
103 |
|
|
104 |
$self->add_status( { test => { depends => $self->depends } } ); |
$self->add_status( { test => { depends => $self->test_because } } ); |
105 |
|
|
106 |
if ( ! @tests ) { |
if ( ! @tests ) { |
107 |
warn "can't find any tests ", dump( $self->tests ), " within depends ", dump( $self->depends ); |
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 ) ); |
114 |
|
|
115 |
warn "testing ",dump( @tests ); |
warn "testing ",dump( @tests ); |
116 |
$h->runtests( @tests ); |
$h->runtests( @tests ); |
117 |
|
|
143 |
|
|
144 |
$html = $self->editor_links( $html ); |
$html = $self->editor_links( $html ); |
145 |
|
|
146 |
if ( my $depends = $self->depends ) { |
if ( my $depends = $self->test_because ) { |
147 |
$html .= qq|Test dependencies:| |
$html .= qq|Test dependencies:| |
148 |
. qq|<ul><li>| |
. qq|<ul><li>| |
149 |
. join("</li>\n<li>", |
. join("</li>\n<li>", |
150 |
map { |
map { |
151 |
qq|<a href="#$_"><tt>$_</tt></a> ← | |
qq|<a href="?test=$_"><tt>$_</tt></a> ← | |
152 |
. |
. |
153 |
join(' ', |
join(' ', |
154 |
map { |
map { |
158 |
qq|<a target="introspect" href="/$_" title="introspect">$_</a>| |
qq|<a target="introspect" href="/$_" title="introspect">$_</a>| |
159 |
# qq|<a target="editor" href="/editor+$_+1" title="edit">$_</a>| |
# qq|<a target="editor" href="/editor+$_+1" title="edit">$_</a>| |
160 |
} |
} |
161 |
} keys %{ $self->depends->{$_} } |
} keys %{ $depends->{$_} } |
162 |
) |
) |
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)"}; |
171 |
|
|
172 |
|
unlink $running_pid or die "can't remove $running_pid: $!"; |
173 |
|
|
174 |
|
return $html; |
175 |
} |
} |
176 |
|
|
177 |
1; |
1; |