21 |
# [ glob('t/*.t') ] # all tests |
# [ 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', |
25 |
); |
); |
26 |
|
|
27 |
|
has test => ( |
28 |
|
is => 'rw', |
29 |
|
isa => 'Str', |
30 |
|
documentation => 'run only this single test', |
31 |
|
); |
32 |
|
|
33 |
|
has test_because => ( |
34 |
|
documentation => 'returns classes responsable for each test run', |
35 |
|
is => 'rw', |
36 |
|
# isa => 'HashRef[Hashref[Int]', |
37 |
|
required => 1, |
38 |
|
lazy => 1, |
39 |
|
default => sub { |
40 |
|
my $self = shift; |
41 |
|
my $depends; |
42 |
|
|
43 |
|
# collect real tests |
44 |
|
map { |
45 |
|
$depends->{$_}->{'test modified'}++ if m{\.t$}; |
46 |
|
} @{ $self->tests }; |
47 |
|
|
48 |
|
# and tests which depend on modified classes supplied |
49 |
|
map { |
50 |
|
if ( m{(.+)\.pm$} ) { |
51 |
|
my $class = $1; |
52 |
|
$class =~ s{^lib/}{}; |
53 |
|
$class =~ s{/}{::}g; |
54 |
|
warn "extract tests from $_ class $class"; |
55 |
|
$depends->{$_}->{$class}++ foreach Frey::PPI->new( class => $class )->has_tests; |
56 |
|
} |
57 |
|
} @{ $self->tests }; |
58 |
|
|
59 |
|
return $depends; |
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 |
|
|
79 |
formatter => $f, |
formatter => $f, |
80 |
}); |
}); |
81 |
|
|
82 |
my $tests; |
my @tests; |
83 |
|
|
84 |
map { |
@tests = ( $self->test ) if $self->test; |
85 |
$tests->{$_}++ if m{\.t$}; |
|
86 |
} @{ $self->tests }; |
if ( my $depends = $self->test_because ) { |
87 |
|
@tests = grep { |
88 |
map { |
$_ ne '' && |
89 |
if ( m{(.+)\.pm$} ) { |
! m{$0} # break recursion |
90 |
my $class = $1; |
} sort keys %{ $depends } unless @tests; |
91 |
$class =~ s{^lib/}{}; |
} |
92 |
$class =~ s{/}{::}g; |
|
93 |
warn "extract tests from $_ class $class"; |
$self->add_status( { test => { depends => $self->test_because } } ); |
94 |
$tests->{$_}->{$class}++ foreach Frey::PPI->new( class => $class )->has_tests; |
|
95 |
} |
if ( ! @tests ) { |
96 |
} @{ $self->tests }; |
warn "can't find any tests ", dump( $self->tests ), " within depends ", dump( $self->test_because ); |
97 |
|
warn "running all tests instead"; |
98 |
my @tests = grep { |
@tests = glob('t/*.t'); |
99 |
! m{$0} # break recursion |
} |
100 |
} sort keys %$tests; |
|
101 |
die "no tests for files ", dump( $self->tests ),dump( $tests ) unless @tests; |
$self->title( join(' ', @tests ) ); |
102 |
|
|
103 |
warn "testing ",dump( @tests ); |
warn "testing ",dump( @tests ); |
104 |
$h->runtests( @tests ); |
$h->runtests( @tests ); |
105 |
|
|
106 |
$self->store( 'var/test/' . time() . '.yaml', $h ); |
$self->store( 'var/test/' . time() . '.yaml', $h ); |
107 |
|
|
|
push @{ $self->status }, { test => $tests }; |
|
|
|
|
108 |
my $html = ${ $f->html }; |
my $html = ${ $f->html }; |
109 |
# warn $html; |
# warn $html; |
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; |
129 |
|
|
130 |
$html =~ s{(<a class="file") href="#"(.+?)>t/(.+?)</a>}{<a target="editor" href="/editor+t/$3.t+1" name="t/$3.t" $2>$3</a>}sg; |
$html =~ s{(<a class="file") href="#"(.+?)>t/(.+?)</a>}{<a target="editor" href="/editor+t/$3.t+1" name="t/$3.t" $2>$3</a>}sg; |
131 |
|
|
132 |
return |
$html = $self->editor_links( $html ); |
133 |
$self->editor_links( $html ) |
|
134 |
|
if ( my $depends = $self->test_because ) { |
135 |
|
$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 { |
143 |
qq|<a target="editor" href="/editor+$_+1" title="edit">$_</a>| |
if ( m{\s} ) { |
144 |
} keys %{ $tests->{$_} } |
$_ # human comment with space |
145 |
|
} else { |
146 |
|
qq|<a target="introspect" href="/$_" title="introspect">$_</a>| |
147 |
|
# qq|<a target="editor" href="/editor+$_+1" title="edit">$_</a>| |
148 |
|
} |
149 |
|
} 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; |