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, |
60 |
}, |
}, |
61 |
); |
); |
62 |
|
|
63 |
|
our $running; |
64 |
|
|
65 |
sub as_markup { |
sub as_markup { |
66 |
my ($self) = @_; |
my ($self) = @_; |
67 |
|
|
68 |
|
return 'allready running' if $running; |
69 |
|
$running = 1; |
70 |
|
|
71 |
my $f = TAP::Formatter::HTML->new({ |
my $f = TAP::Formatter::HTML->new({ |
72 |
# silent => 1, |
# silent => 1, |
73 |
|
|
83 |
|
|
84 |
@tests = ( $self->test ) if $self->test; |
@tests = ( $self->test ) if $self->test; |
85 |
|
|
86 |
if ( my $depends = $self->depends ) { |
if ( my $depends = $self->test_because ) { |
87 |
@tests = grep { |
@tests = grep { |
88 |
|
$_ ne '' && |
89 |
! m{$0} # break recursion |
! m{$0} # break recursion |
90 |
} sort keys %{ $depends } unless @tests; |
} sort keys %{ $depends } unless @tests; |
91 |
} |
} |
92 |
|
|
93 |
$self->add_status( { test => { depends => $self->depends } } ); |
$self->add_status( { test => { depends => $self->test_because } } ); |
94 |
|
|
95 |
if ( ! @tests ) { |
if ( ! @tests ) { |
96 |
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 ); |
97 |
warn "running all tests instead"; |
warn "running all tests instead"; |
98 |
@tests = glob('t/*.t'); |
@tests = glob('t/*.t'); |
99 |
} |
} |
100 |
|
|
101 |
|
$self->title( join(' ', @tests ) ); |
102 |
|
|
103 |
warn "testing ",dump( @tests ); |
warn "testing ",dump( @tests ); |
104 |
$h->runtests( @tests ); |
$h->runtests( @tests ); |
105 |
|
|
110 |
warn "got ",length($html), " bytes"; |
warn "got ",length($html), " bytes"; |
111 |
|
|
112 |
while ( $html =~ s{(<style.+?/style>)}{}gs ) { |
while ( $html =~ s{(<style.+?/style>)}{}gs ) { |
113 |
$self->add_head( $1 ); |
my $style = $1; |
114 |
|
$style =~ s[((?:body|html)\s+{[^}]+})][/\* $1 \*/]sg; # remove some styles |
115 |
|
$self->add_head( $style ); |
116 |
} |
} |
117 |
|
|
118 |
$self->add_head(qq| |
$self->add_head(qq| |
122 |
td.results:hover ul.test-out { display: block; } |
td.results:hover ul.test-out { display: block; } |
123 |
</style> |
</style> |
124 |
|); |
|); |
125 |
|
$html =~ s{<div id="menu">.+?</div>}{}sg; # remove menu which doesn't work without JavaScript |
126 |
|
|
127 |
$html =~ s{^.*<body>}{}s; |
$html =~ s{^.*<body>}{}s; |
128 |
$html =~ s{</body>.*$}{}s; |
$html =~ s{</body>.*$}{}s; |
131 |
|
|
132 |
$html = $self->editor_links( $html ); |
$html = $self->editor_links( $html ); |
133 |
|
|
134 |
if ( my $depends = $self->depends ) { |
if ( my $depends = $self->test_because ) { |
135 |
$html .= qq|Test dependencies:| |
$html .= qq|Test dependencies:| |
136 |
. qq|<ul><li>| |
. qq|<ul><li>| |
137 |
. join("</li>\n<li>", |
. join("</li>\n<li>", |
138 |
map { |
map { |
139 |
qq|<a href="#$_"><tt>$_</tt></a> ← | |
qq|<a href="?test=$_"><tt>$_</tt></a> ← | |
140 |
. |
. |
141 |
join(' ', |
join(' ', |
142 |
map { |
map { |
146 |
qq|<a target="introspect" href="/$_" title="introspect">$_</a>| |
qq|<a target="introspect" href="/$_" title="introspect">$_</a>| |
147 |
# qq|<a target="editor" href="/editor+$_+1" title="edit">$_</a>| |
# qq|<a target="editor" href="/editor+$_+1" title="edit">$_</a>| |
148 |
} |
} |
149 |
} keys %{ $self->depends->{$_} } |
} keys %{ $depends->{$_} } |
150 |
) |
) |
151 |
} @tests ) |
} @tests ) |
152 |
. qq|</li></ul>| |
. qq|</li></ul>| |
153 |
; |
; |
154 |
} |
} |
155 |
|
|
156 |
|
$self->add_icon( $1 ) if $html =~ m{class="(passed|failed)"}; |
157 |
|
|
158 |
|
$running = 0; |
159 |
|
return $html; |
160 |
} |
} |
161 |
|
|
162 |
1; |
1; |