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 depends => ( |
34 |
|
is => 'rw', |
35 |
|
# isa => 'HashRef[Hashref[Int]', |
36 |
|
required => 1, |
37 |
|
lazy => 1, |
38 |
|
default => sub { |
39 |
|
my $self = shift; |
40 |
|
my $depends; |
41 |
|
|
42 |
|
# collect real tests |
43 |
|
map { |
44 |
|
$depends->{$_}->{'test modified'}++ if m{\.t$}; |
45 |
|
} @{ $self->tests }; |
46 |
|
|
47 |
|
# and tests which depend on modified classes supplied |
48 |
|
map { |
49 |
|
if ( m{(.+)\.pm$} ) { |
50 |
|
my $class = $1; |
51 |
|
$class =~ s{^lib/}{}; |
52 |
|
$class =~ s{/}{::}g; |
53 |
|
warn "extract tests from $_ class $class"; |
54 |
|
$depends->{$_}->{$class}++ foreach Frey::PPI->new( class => $class )->has_tests; |
55 |
|
} |
56 |
|
} @{ $self->tests }; |
57 |
|
|
58 |
|
return $depends; |
59 |
|
}, |
60 |
); |
); |
61 |
|
|
62 |
sub as_markup { |
sub as_markup { |
73 |
formatter => $f, |
formatter => $f, |
74 |
}); |
}); |
75 |
|
|
76 |
my $tests; |
my @tests; |
77 |
|
|
78 |
|
@tests = ( $self->test ) if $self->test; |
79 |
|
|
80 |
map { |
if ( my $depends = $self->depends ) { |
81 |
$tests->{$_}->{'test modified'}++ if m{\.t$}; |
@tests = grep { |
82 |
} @{ $self->tests }; |
$_ ne '' && |
83 |
|
! m{$0} # break recursion |
84 |
map { |
} sort keys %{ $depends } unless @tests; |
85 |
if ( m{(.+)\.pm$} ) { |
} |
86 |
my $class = $1; |
|
87 |
$class =~ s{^lib/}{}; |
$self->add_status( { test => { depends => $self->depends } } ); |
88 |
$class =~ s{/}{::}g; |
|
89 |
warn "extract tests from $_ class $class"; |
if ( ! @tests ) { |
90 |
$tests->{$_}->{$class}++ foreach Frey::PPI->new( class => $class )->has_tests; |
warn "can't find any tests ", dump( $self->tests ), " within depends ", dump( $self->depends ); |
91 |
} |
warn "running all tests instead"; |
92 |
} @{ $self->tests }; |
@tests = glob('t/*.t'); |
93 |
|
} |
|
my @tests = grep { |
|
|
! m{$0} # break recursion |
|
|
} sort keys %$tests; |
|
|
die "no tests for files ", dump( $self->tests ),dump( $tests ) unless @tests; |
|
94 |
|
|
95 |
warn "testing ",dump( @tests ); |
warn "testing ",dump( @tests ); |
96 |
$h->runtests( @tests ); |
$h->runtests( @tests ); |
97 |
|
|
98 |
$self->store( 'var/test/' . time() . '.yaml', $h ); |
$self->store( 'var/test/' . time() . '.yaml', $h ); |
99 |
|
|
|
push @{ $self->status }, { test => $tests }; |
|
|
|
|
100 |
my $html = ${ $f->html }; |
my $html = ${ $f->html }; |
101 |
# warn $html; |
# warn $html; |
102 |
warn "got ",length($html), " bytes"; |
warn "got ",length($html), " bytes"; |
103 |
|
|
104 |
while ( $html =~ s{(<style.+?/style>)}{}gs ) { |
while ( $html =~ s{(<style.+?/style>)}{}gs ) { |
105 |
$self->add_head( $1 ); |
my $style = $1; |
106 |
|
$style =~ s[((?:body|html)\s+{[^}]+})][/\* $1 \*/]sg; # remove some styles |
107 |
|
$self->add_head( $style ); |
108 |
} |
} |
109 |
|
|
110 |
$self->add_head(qq| |
$self->add_head(qq| |
114 |
td.results:hover ul.test-out { display: block; } |
td.results:hover ul.test-out { display: block; } |
115 |
</style> |
</style> |
116 |
|); |
|); |
117 |
|
$html =~ s{<div id="menu">.+?</div>}{}sg; # remove menu which doesn't work without JavaScript |
118 |
|
|
119 |
$html =~ s{^.*<body>}{}s; |
$html =~ s{^.*<body>}{}s; |
120 |
$html =~ s{</body>.*$}{}s; |
$html =~ s{</body>.*$}{}s; |
121 |
|
|
122 |
$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; |
123 |
|
|
124 |
return |
$html = $self->editor_links( $html ); |
125 |
$self->editor_links( $html ) |
|
126 |
|
if ( my $depends = $self->depends ) { |
127 |
|
$html .= qq|Test dependencies:| |
128 |
. qq|<ul><li>| |
. qq|<ul><li>| |
129 |
. join("</li>\n<li>", |
. join("</li>\n<li>", |
130 |
map { |
map { |
138 |
qq|<a target="introspect" href="/$_" title="introspect">$_</a>| |
qq|<a target="introspect" href="/$_" title="introspect">$_</a>| |
139 |
# qq|<a target="editor" href="/editor+$_+1" title="edit">$_</a>| |
# qq|<a target="editor" href="/editor+$_+1" title="edit">$_</a>| |
140 |
} |
} |
141 |
} keys %{ $tests->{$_} } |
} keys %{ $self->depends->{$_} } |
142 |
) |
) |
143 |
} @tests ) |
} @tests ) |
144 |
. qq|</li></ul>| |
. qq|</li></ul>| |
145 |
; |
; |
146 |
|
} |
147 |
|
|
148 |
} |
} |
149 |
|
|