| 1 | package Test::Run::Straps; | ||||||||||||||
| 2 | |||||||||||||||
| 3 | 15 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 4 | 15 | ▶ | use warnings; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 5 | |||||||||||||||
| 6 | 15 | ▶ | use vars qw($VERSION); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 7 | 15 | $VERSION = '0.0306'; | |||||||||||||
| 8 | |||||||||||||||
| 9 | =head1 NAME | ||||||||||||||
| 10 | |||||||||||||||
| 11 | Test::Run::Straps - analyse the test results by using TAP::Parser. | ||||||||||||||
| 12 | |||||||||||||||
| 13 | =head1 METHODS | ||||||||||||||
| 14 | |||||||||||||||
| 15 | =cut | ||||||||||||||
| 16 | |||||||||||||||
| 17 | 15 | ▶ | use Moose; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 18 | |||||||||||||||
| 19 | 15 | ▶ | use MRO::Compat; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 20 | |||||||||||||||
| 21 | 15 | extends('Test::Run::Straps::Base'); | |||||||||||||
| 22 | |||||||||||||||
| 23 | 15 | ▶ | use Config; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 24 | |||||||||||||||
| 25 | 15 | ▶ | use IPC::System::Simple qw( capturex ); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 26 | |||||||||||||||
| 27 | 15 | ▶ | use TAP::Parser; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 28 | |||||||||||||||
| 29 | 15 | ▶ | use Test::Run::Straps::EventWrapper; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 30 | 15 | ▶ | use Test::Run::Straps::StrapsTotalsObj; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 31 | |||||||||||||||
| 32 | 15 | ▶ | use Test::Run::Obj::Error; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 33 | |||||||||||||||
| 34 | 15 | has 'bailout_reason' => (is => "rw", isa => "Str"); | |||||||||||||
| 35 | 15 | has 'callback' => (is => "rw", isa => "Maybe[CodeRef]"); | |||||||||||||
| 36 | 15 | has 'Debug' => (is => "rw", isa => "Bool"); | |||||||||||||
| 37 | 15 | has 'error' => (is => "rw", isa => "Any"); | |||||||||||||
| 38 | 15 | has 'exception' => (is => "rw", isa => "Any"); | |||||||||||||
| 39 | 15 | has 'file' => (is => "rw", isa => "Str"); | |||||||||||||
| 40 | 15 | has '_file_totals' => | |||||||||||||
| 41 | (is => "rw", isa => "Test::Run::Straps::StrapsTotalsObj"); | ||||||||||||||
| 42 | has '_is_macos' => (is => "rw", isa => "Bool", | ||||||||||||||
| 43 | 52 | ▶ | default => sub { return ($^O eq "MacOS"); }, | ||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||
| 44 | 15 | ); | |||||||||||||
| 45 | has '_is_win32' => (is => "rw", isa => "Bool", | ||||||||||||||
| 46 | 52 | ▶ | default => sub { return ($^O =~ m{\A(?:MS)?Win32\z}); }, | ||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||
| 47 | 15 | ); | |||||||||||||
| 48 | has '_is_vms' => (is => "rw", isa => "Bool", | ||||||||||||||
| 49 | 52 | ▶ | default => sub { return ($^O eq "VMS"); }, | ||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||
| 50 | 15 | ); | |||||||||||||
| 51 | 15 | has 'last_test_print' => (is => "rw", isa => "Bool"); | |||||||||||||
| 52 | 15 | has 'next_test_num' => (is => "rw", isa => "Num"); | |||||||||||||
| 53 | 15 | has '_old5lib' => (is => "rw", isa => "Maybe[Str]"); | |||||||||||||
| 54 | 15 | has '_parser' => (is => "rw", isa => "Maybe[TAP::Parser]"); | |||||||||||||
| 55 | 15 | has 'results' => | |||||||||||||
| 56 | (is => "rw", isa => "Test::Run::Straps::StrapsTotalsObj"); | ||||||||||||||
| 57 | 15 | has 'saw_bailout' => (is => "rw", isa => "Bool"); | |||||||||||||
| 58 | 15 | has 'saw_header' => (is => "rw", isa => "Bool"); | |||||||||||||
| 59 | 15 | has '_seen_header' => (is => "rw", isa => "Num"); | |||||||||||||
| 60 | 15 | has 'Switches' => (is => "rw", isa => "Maybe[Str]"); | |||||||||||||
| 61 | 15 | has 'Switches_Env' => (is => "rw", isa => "Maybe[Str]"); | |||||||||||||
| 62 | 15 | has 'Test_Interpreter' => (is => "rw", isa => "Maybe[Str]"); | |||||||||||||
| 63 | 52 | ▶ | has 'todo' => (is => "rw", isa => "HashRef", default => sub { +{} },); | ||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||
| 64 | 15 | has 'too_many_tests' => (is => "rw", isa => "Bool"); | |||||||||||||
| 65 | has 'totals' => | ||||||||||||||
| 66 | 52 | ▶ | (is => "rw", isa => "HashRef", default => sub { +{} },); | ||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||
| 67 | |||||||||||||||
| 68 | |||||||||||||||
| 69 | =head2 my $strap = Test::Run::Straps->new(); | ||||||||||||||
| 70 | |||||||||||||||
| 71 | Initialize a new strap. | ||||||||||||||
| 72 | |||||||||||||||
| 73 | =cut | ||||||||||||||
| 74 | |||||||||||||||
| 75 | sub _start_new_file | ||||||||||||||
| 76 | 57 | ▶ | { | ||||||||||||
|
Subroutine
_start_new_file: called CC=1 SCAR=0.0
| |||||||||||||||
| 77 | 57 | my $self = shift; | |||||||||||||
| 78 | |||||||||||||||
| 79 | 57 | $self->_reset_file_state; | |||||||||||||
| 80 | 57 | my $totals = | |||||||||||||
| 81 | $self->_init_totals_obj_instance( | ||||||||||||||
| 82 | $self->_get_initial_totals_obj_params(), | ||||||||||||||
| 83 | ); | ||||||||||||||
| 84 | |||||||||||||||
| 85 | 57 | $self->_file_totals($totals); | |||||||||||||
| 86 | |||||||||||||||
| 87 | # Set them up here so callbacks can have them. | ||||||||||||||
| 88 | 57 | $self->totals()->{$self->file()} = $totals; | |||||||||||||
| 89 | |||||||||||||||
| 90 | 57 | return; | |||||||||||||
| 91 | } | ||||||||||||||
| 92 | |||||||||||||||
| 93 | sub _calc_next_event | ||||||||||||||
| 94 | 344 | ▶ | { | ||||||||||||
|
Subroutine
_calc_next_event: called CC=2 SCAR=6.9
| |||||||||||||||
| 95 | 344 | my $self = shift; | |||||||||||||
| 96 | |||||||||||||||
| 97 | 344 | my $event = scalar($self->_parser->next()); | |||||||||||||
| 98 | |||||||||||||||
| 99 | 344 | ▶ | if (defined($event)) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 100 | { | ||||||||||||||
| 101 | return | ||||||||||||||
| 102 | 289 | Test::Run::Straps::EventWrapper->new( | |||||||||||||
| 103 | { | ||||||||||||||
| 104 | event => $event, | ||||||||||||||
| 105 | }, | ||||||||||||||
| 106 | ); | ||||||||||||||
| 107 | } | ||||||||||||||
| 108 | else | ||||||||||||||
| 109 | { | ||||||||||||||
| 110 | 55 | return undef; | |||||||||||||
| 111 | } | ||||||||||||||
| 112 | } | ||||||||||||||
| 113 | |||||||||||||||
| 114 | sub _get_next_event | ||||||||||||||
| 115 | 344 | ▶ | { | ||||||||||||
|
Subroutine
_get_next_event: called CC=1 SCAR=0.0
| |||||||||||||||
| 116 | 344 | my ($self) = @_; | |||||||||||||
| 117 | |||||||||||||||
| 118 | 344 | return $self->_event($self->_calc_next_event()); | |||||||||||||
| 119 | } | ||||||||||||||
| 120 | |||||||||||||||
| 121 | sub _get_event_types_cascade | ||||||||||||||
| 122 | 289 | ▶ | { | ||||||||||||
|
Subroutine
_get_event_types_cascade: called CC=1 SCAR=0.0
| |||||||||||||||
| 123 | 289 | return [qw(test plan bailout comment)]; | |||||||||||||
| 124 | } | ||||||||||||||
| 125 | |||||||||||||||
| 126 | =head2 $strap->_inc_seen_header() | ||||||||||||||
| 127 | |||||||||||||||
| 128 | Increment the _seen_header field. Used by L<Test::Run::Core>. | ||||||||||||||
| 129 | |||||||||||||||
| 130 | =cut | ||||||||||||||
| 131 | |||||||||||||||
| 132 | sub _inc_seen_header | ||||||||||||||
| 133 | 52 | ▶ | { | ||||||||||||
|
Subroutine
_inc_seen_header: called CC=1 SCAR=0.0
| |||||||||||||||
| 134 | 52 | my $self = shift; | |||||||||||||
| 135 | |||||||||||||||
| 136 | 52 | $self->inc_field('_seen_header'); | |||||||||||||
| 137 | |||||||||||||||
| 138 | 52 | return; | |||||||||||||
| 139 | } | ||||||||||||||
| 140 | |||||||||||||||
| 141 | sub _inc_saw_header | ||||||||||||||
| 142 | 52 | ▶ | { | ||||||||||||
|
Subroutine
_inc_saw_header: called CC=1 SCAR=0.0
| |||||||||||||||
| 143 | 52 | my $self = shift; | |||||||||||||
| 144 | |||||||||||||||
| 145 | 52 | $self->inc_field('saw_header'); | |||||||||||||
| 146 | |||||||||||||||
| 147 | 52 | return; | |||||||||||||
| 148 | } | ||||||||||||||
| 149 | |||||||||||||||
| 150 | sub _plan_set_max | ||||||||||||||
| 151 | 52 | ▶ | { | ||||||||||||
|
Subroutine
_plan_set_max: called CC=1 SCAR=0.0
| |||||||||||||||
| 152 | 52 | my $self = shift; | |||||||||||||
| 153 | |||||||||||||||
| 154 | 52 | $self->_file_totals->max($self->_event->tests_planned()); | |||||||||||||
| 155 | |||||||||||||||
| 156 | 52 | return; | |||||||||||||
| 157 | } | ||||||||||||||
| 158 | |||||||||||||||
| 159 | sub _handle_plan_skip_all | ||||||||||||||
| 160 | 52 | ▶ | { | ||||||||||||
|
Subroutine
_handle_plan_skip_all: called CC=2 SCAR=6.9
| |||||||||||||||
| 161 | 52 | my $self = shift; | |||||||||||||
| 162 | |||||||||||||||
| 163 | # If it's a skip-all line. | ||||||||||||||
| 164 | 52 | ▶ | if ($self->_event->tests_planned() == 0) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 165 | { | ||||||||||||||
| 166 | 3 | $self->_file_totals->skip_all($self->_event->explanation()); | |||||||||||||
| 167 | } | ||||||||||||||
| 168 | |||||||||||||||
| 169 | 52 | return; | |||||||||||||
| 170 | } | ||||||||||||||
| 171 | |||||||||||||||
| 172 | sub _calc__handle_plan_event__callbacks | ||||||||||||||
| 173 | 52 | ▶ | { | ||||||||||||
|
Subroutine
_calc__handle_plan_event__callbacks: called CC=1 SCAR=0.0
| |||||||||||||||
| 174 | 52 | my $self = shift; | |||||||||||||
| 175 | |||||||||||||||
| 176 | 52 | return [qw( | |||||||||||||
| 177 | _inc_saw_header | ||||||||||||||
| 178 | _plan_set_max | ||||||||||||||
| 179 | _handle_plan_skip_all | ||||||||||||||
| 180 | )]; | ||||||||||||||
| 181 | } | ||||||||||||||
| 182 | |||||||||||||||
| 183 | sub _handle_plan_event | ||||||||||||||
| 184 | 52 | ▶ | { | ||||||||||||
|
Subroutine
_handle_plan_event: called CC=1 SCAR=0.0
| |||||||||||||||
| 185 | 52 | shift->_run_sequence(); | |||||||||||||
| 186 | |||||||||||||||
| 187 | 52 | return; | |||||||||||||
| 188 | } | ||||||||||||||
| 189 | |||||||||||||||
| 190 | sub _handle_bailout_event | ||||||||||||||
| 191 | 2 | ▶ | { | ||||||||||||
|
Subroutine
_handle_bailout_event: called CC=1 SCAR=0.0
| |||||||||||||||
| 192 | 2 | my $self = shift; | |||||||||||||
| 193 | |||||||||||||||
| 194 | 2 | $self->bailout_reason($self->_event->explanation()); | |||||||||||||
| 195 | 2 | $self->saw_bailout(1); | |||||||||||||
| 196 | |||||||||||||||
| 197 | 2 | return; | |||||||||||||
| 198 | } | ||||||||||||||
| 199 | |||||||||||||||
| 200 | sub _handle_comment_event | ||||||||||||||
| 201 | 26 | ▶ | { | ||||||||||||
|
Subroutine
_handle_comment_event: called CC=2 SCAR=6.9
| |||||||||||||||
| 202 | 26 | my $self = shift; | |||||||||||||
| 203 | |||||||||||||||
| 204 | 26 | my $test = $self->_file_totals->last_detail(); | |||||||||||||
| 205 | 26 | ▶ | if (defined($test)) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 206 | { | ||||||||||||||
| 207 | 19 | $test->append_to_diag($self->_event->comment()); | |||||||||||||
| 208 | } | ||||||||||||||
| 209 | |||||||||||||||
| 210 | 26 | return; | |||||||||||||
| 211 | } | ||||||||||||||
| 212 | |||||||||||||||
| 213 | sub _handle_labeled_test_event | ||||||||||||||
| 214 | 0 | ▶ | { | ||||||||||||
|
Subroutine
_handle_labeled_test_event: not called CC=1 SCAR=6.9
| |||||||||||||||
| 215 | 0 | my $self = shift; | |||||||||||||
| 216 | |||||||||||||||
| 217 | 0 | return; | |||||||||||||
| 218 | } | ||||||||||||||
| 219 | |||||||||||||||
| 220 | sub _on_first_too_many_tests | ||||||||||||||
| 221 | 2 | ▶ | { | ||||||||||||
|
Subroutine
_on_first_too_many_tests: called CC=1 SCAR=0.0
| |||||||||||||||
| 222 | 2 | my $self = shift; | |||||||||||||
| 223 | |||||||||||||||
| 224 | 2 | warn "Enormous test number seen [test ", $self->_event->number(), "]\n"; | |||||||||||||
| 225 | 2 | warn "Can't detailize, too big.\n"; | |||||||||||||
| 226 | |||||||||||||||
| 227 | 2 | return; | |||||||||||||
| 228 | } | ||||||||||||||
| 229 | |||||||||||||||
| 230 | sub _handle_enormous_event_num | ||||||||||||||
| 231 | 7 | ▶ | { | ||||||||||||
|
Subroutine
_handle_enormous_event_num: called CC=2 SCAR=6.9
| |||||||||||||||
| 232 | 7 | my $self = shift; | |||||||||||||
| 233 | |||||||||||||||
| 234 | 7 | ▶ | if (! $self->too_many_tests()) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 235 | { | ||||||||||||||
| 236 | 2 | $self->_on_first_too_many_tests(); | |||||||||||||
| 237 | 2 | $self->too_many_tests(1); | |||||||||||||
| 238 | } | ||||||||||||||
| 239 | |||||||||||||||
| 240 | 7 | return; | |||||||||||||
| 241 | } | ||||||||||||||
| 242 | |||||||||||||||
| 243 | sub _handle_test_event | ||||||||||||||
| 244 | 208 | ▶ | { | ||||||||||||
|
Subroutine
_handle_test_event: called CC=1 SCAR=0.2
| |||||||||||||||
| 245 | 208 | my $self = shift; | |||||||||||||
| 246 | return $self->_file_totals->handle_event( | ||||||||||||||
| 247 | { | ||||||||||||||
| 248 | event => $self->_event, | ||||||||||||||
| 249 | enormous_num_cb => | ||||||||||||||
| 250 | 7 | ▶ | sub { return $self->_handle_enormous_event_num(); }, | ||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||
| 251 | } | ||||||||||||||
| 252 | 208 | ); | |||||||||||||
| 253 | |||||||||||||||
| 254 | 0 | return; | |||||||||||||
| 255 | } | ||||||||||||||
| 256 | |||||||||||||||
| 257 | =head2 $self->_handle_event() | ||||||||||||||
| 258 | |||||||||||||||
| 259 | Handles the current event according to the list of types in the cascade. It | ||||||||||||||
| 260 | checks each type and if matches calls the appropriate | ||||||||||||||
| 261 | C<_handle_${type}_event> callback. Returns the type of the event that matched. | ||||||||||||||
| 262 | |||||||||||||||
| 263 | =cut | ||||||||||||||
| 264 | |||||||||||||||
| 265 | sub _handle_event | ||||||||||||||
| 266 | 289 | ▶ | { | ||||||||||||
|
Subroutine
_handle_event: called CC=3 SCAR=11.0
| |||||||||||||||
| 267 | 289 | my $self = shift; | |||||||||||||
| 268 | |||||||||||||||
| 269 | 289 | my $event = $self->_event; | |||||||||||||
| 270 | |||||||||||||||
| 271 | 289 | foreach my $type (@{$self->_get_event_types_cascade()}) | |||||||||||||
| 272 | { | ||||||||||||||
| 273 | 426 | my $is_type = "is_" . $type; | |||||||||||||
| 274 | 426 | ▶ | if ($event->$is_type()) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 275 | { | ||||||||||||||
| 276 | 288 | my $handle_type = "_handle_${type}_event"; | |||||||||||||
| 277 | 288 | $self->$handle_type(); | |||||||||||||
| 278 | |||||||||||||||
| 279 | 288 | return $type; | |||||||||||||
| 280 | } | ||||||||||||||
| 281 | } | ||||||||||||||
| 282 | |||||||||||||||
| 283 | 1 | return; | |||||||||||||
| 284 | } | ||||||||||||||
| 285 | |||||||||||||||
| 286 | sub _invoke_cb | ||||||||||||||
| 287 | 347 | ▶ | { | ||||||||||||
|
Subroutine
_invoke_cb: called CC=2 SCAR=6.9
| |||||||||||||||
| 288 | 347 | my $self = shift; | |||||||||||||
| 289 | 347 | my $args = shift; | |||||||||||||
| 290 | |||||||||||||||
| 291 | 347 | ▶ | if ($self->callback()) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 292 | { | ||||||||||||||
| 293 | 346 | $self->callback()->( | |||||||||||||
| 294 | $args | ||||||||||||||
| 295 | ); | ||||||||||||||
| 296 | } | ||||||||||||||
| 297 | } | ||||||||||||||
| 298 | |||||||||||||||
| 299 | sub _call_callback | ||||||||||||||
| 300 | 289 | ▶ | { | ||||||||||||
|
Subroutine
_call_callback: called CC=1 SCAR=0.0
| |||||||||||||||
| 301 | 289 | my $self = shift; | |||||||||||||
| 302 | 289 | return $self->_invoke_cb( | |||||||||||||
| 303 | { | ||||||||||||||
| 304 | type => "tap_event", | ||||||||||||||
| 305 | event => $self->_event(), | ||||||||||||||
| 306 | totals => $self->_file_totals(), | ||||||||||||||
| 307 | } | ||||||||||||||
| 308 | ); | ||||||||||||||
| 309 | } | ||||||||||||||
| 310 | |||||||||||||||
| 311 | sub _bump_next | ||||||||||||||
| 312 | 287 | ▶ | { | ||||||||||||
|
Subroutine
_bump_next: called CC=2 SCAR=6.9
| |||||||||||||||
| 313 | 287 | my $self = shift; | |||||||||||||
| 314 | |||||||||||||||
| 315 | 287 | ▶ | if (defined(my $n = $self->_event->get_next_test_number())) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 316 | { | ||||||||||||||
| 317 | 208 | $self->next_test_num($n); | |||||||||||||
| 318 | } | ||||||||||||||
| 319 | |||||||||||||||
| 320 | 287 | return; | |||||||||||||
| 321 | } | ||||||||||||||
| 322 | |||||||||||||||
| 323 | |||||||||||||||
| 324 | sub _calc__analyze_event__callbacks | ||||||||||||||
| 325 | 289 | ▶ | { | ||||||||||||
|
Subroutine
_calc__analyze_event__callbacks: called CC=1 SCAR=0.0
| |||||||||||||||
| 326 | 289 | my $self = shift; | |||||||||||||
| 327 | |||||||||||||||
| 328 | 289 | return [qw( | |||||||||||||
| 329 | _handle_event | ||||||||||||||
| 330 | _call_callback | ||||||||||||||
| 331 | _bump_next | ||||||||||||||
| 332 | )]; | ||||||||||||||
| 333 | } | ||||||||||||||
| 334 | |||||||||||||||
| 335 | sub _analyze_event | ||||||||||||||
| 336 | 289 | ▶ | { | ||||||||||||
|
Subroutine
_analyze_event: called CC=1 SCAR=0.0
| |||||||||||||||
| 337 | 289 | shift->_run_sequence(); | |||||||||||||
| 338 | |||||||||||||||
| 339 | 287 | return; | |||||||||||||
| 340 | } | ||||||||||||||
| 341 | |||||||||||||||
| 342 | sub _events_loop | ||||||||||||||
| 343 | 57 | ▶ | { | ||||||||||||
|
Subroutine
_events_loop: called CC=3 SCAR=11.0
| |||||||||||||||
| 344 | 57 | my $self = shift; | |||||||||||||
| 345 | |||||||||||||||
| 346 | 57 | ▶ | while ($self->_get_next_event()) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 347 | { | ||||||||||||||
| 348 | 289 | $self->_analyze_event(); | |||||||||||||
| 349 | 287 | ▶ | last if $self->saw_bailout(); | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 350 | } | ||||||||||||||
| 351 | |||||||||||||||
| 352 | 55 | return; | |||||||||||||
| 353 | } | ||||||||||||||
| 354 | |||||||||||||||
| 355 | sub _end_file | ||||||||||||||
| 356 | 55 | ▶ | { | ||||||||||||
|
Subroutine
_end_file: called CC=1 SCAR=0.0
| |||||||||||||||
| 357 | 55 | my $self = shift; | |||||||||||||
| 358 | |||||||||||||||
| 359 | 55 | $self->_file_totals->determine_passing(); | |||||||||||||
| 360 | |||||||||||||||
| 361 | 55 | $self->_parser(undef); | |||||||||||||
| 362 | 55 | $self->_event(undef); | |||||||||||||
| 363 | |||||||||||||||
| 364 | 55 | return; | |||||||||||||
| 365 | } | ||||||||||||||
| 366 | |||||||||||||||
| 367 | sub _calc__analyze_with_parser__callbacks | ||||||||||||||
| 368 | 57 | ▶ | { | ||||||||||||
|
Subroutine
_calc__analyze_with_parser__callbacks: called CC=1 SCAR=0.0
| |||||||||||||||
| 369 | 57 | my $self = shift; | |||||||||||||
| 370 | |||||||||||||||
| 371 | 57 | return [qw( | |||||||||||||
| 372 | _start_new_file | ||||||||||||||
| 373 | _events_loop | ||||||||||||||
| 374 | _end_file | ||||||||||||||
| 375 | )]; | ||||||||||||||
| 376 | } | ||||||||||||||
| 377 | |||||||||||||||
| 378 | sub _analyze_with_parser | ||||||||||||||
| 379 | 57 | ▶ | { | ||||||||||||
|
Subroutine
_analyze_with_parser: called CC=1 SCAR=0.0
| |||||||||||||||
| 380 | 57 | my $self = shift; | |||||||||||||
| 381 | |||||||||||||||
| 382 | 57 | $self->_run_sequence(); | |||||||||||||
| 383 | |||||||||||||||
| 384 | 55 | return $self->_file_totals(); | |||||||||||||
| 385 | } | ||||||||||||||
| 386 | |||||||||||||||
| 387 | sub _get_command_and_switches | ||||||||||||||
| 388 | 60 | ▶ | { | ||||||||||||
|
Subroutine
_get_command_and_switches: called CC=1 SCAR=0.0
| |||||||||||||||
| 389 | 60 | my $self = shift; | |||||||||||||
| 390 | |||||||||||||||
| 391 | 60 | return [$self->_command(), @{$self->_switches()}]; | |||||||||||||
| 392 | } | ||||||||||||||
| 393 | |||||||||||||||
| 394 | sub _get_full_exec_command | ||||||||||||||
| 395 | 60 | ▶ | { | ||||||||||||
|
Subroutine
_get_full_exec_command: called CC=1 SCAR=0.0
| |||||||||||||||
| 396 | 60 | my $self = shift; | |||||||||||||
| 397 | |||||||||||||||
| 398 | 60 | return [ @{$self->_get_command_and_switches()}, $self->file()]; | |||||||||||||
| 399 | } | ||||||||||||||
| 400 | |||||||||||||||
| 401 | sub _command_line | ||||||||||||||
| 402 | 3 | ▶ | { | ||||||||||||
|
Subroutine
_command_line: called CC=1 SCAR=0.0
| |||||||||||||||
| 403 | 3 | my $self = shift; | |||||||||||||
| 404 | |||||||||||||||
| 405 | 3 | return join(" ", @{$self->_get_full_exec_command()}); | |||||||||||||
| 406 | } | ||||||||||||||
| 407 | |||||||||||||||
| 408 | sub _create_parser | ||||||||||||||
| 409 | 57 | ▶ | { | ||||||||||||
|
Subroutine
_create_parser: called CC=1 SCAR=0.0
| |||||||||||||||
| 410 | 57 | my $self = shift; | |||||||||||||
| 411 | |||||||||||||||
| 412 | 57 | local $ENV{PERL5LIB} = $self->_INC2PERL5LIB; | |||||||||||||
| 413 | 57 | $self->_invoke_cb({type => "report_start_env"}); | |||||||||||||
| 414 | |||||||||||||||
| 415 | 57 | my $ret = TAP::Parser->new( | |||||||||||||
| 416 | { | ||||||||||||||
| 417 | exec => $self->_get_full_exec_command(), | ||||||||||||||
| 418 | } | ||||||||||||||
| 419 | ); | ||||||||||||||
| 420 | |||||||||||||||
| 421 | 57 | $self->_restore_PERL5LIB(); | |||||||||||||
| 422 | |||||||||||||||
| 423 | 57 | return $ret; | |||||||||||||
| 424 | } | ||||||||||||||
| 425 | |||||||||||||||
| 426 | =head2 my $results = $self->analyze( $name, \@output_lines) | ||||||||||||||
| 427 | |||||||||||||||
| 428 | Analyzes the output @output_lines of a given test, to which the name | ||||||||||||||
| 429 | $name is assigned. Returns the results $results of the test - an object of | ||||||||||||||
| 430 | type L<Test::Run::Straps::StrapsTotalsObj> . | ||||||||||||||
| 431 | |||||||||||||||
| 432 | @output_lines should be the output of the test including newlines. | ||||||||||||||
| 433 | |||||||||||||||
| 434 | =cut | ||||||||||||||
| 435 | |||||||||||||||
| 436 | sub analyze | ||||||||||||||
| 437 | 0 | ▶ | { | ||||||||||||
|
Subroutine
analyze: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||
| 438 | 0 | my($self, $name, $test_output_orig) = @_; | |||||||||||||
| 439 | |||||||||||||||
| 440 | # Assign it here so it won't be passed around. | ||||||||||||||
| 441 | 0 | $self->file($name); | |||||||||||||
| 442 | |||||||||||||||
| 443 | 0 | $self->_parser($self->_create_parser($test_output_orig)); | |||||||||||||
| 444 | |||||||||||||||
| 445 | 0 | return $self->_analyze_with_parser(); | |||||||||||||
| 446 | } | ||||||||||||||
| 447 | |||||||||||||||
| 448 | sub _init_totals_obj_instance | ||||||||||||||
| 449 | 57 | ▶ | { | ||||||||||||
|
Subroutine
_init_totals_obj_instance: called CC=1 SCAR=0.0
| |||||||||||||||
| 450 | 57 | my ($self, $args) = @_; | |||||||||||||
| 451 | 57 | return Test::Run::Straps::StrapsTotalsObj->new($args); | |||||||||||||
| 452 | } | ||||||||||||||
| 453 | |||||||||||||||
| 454 | sub _get_initial_totals_obj_params | ||||||||||||||
| 455 | 57 | ▶ | { | ||||||||||||
|
Subroutine
_get_initial_totals_obj_params: called CC=1 SCAR=0.0
| |||||||||||||||
| 456 | 57 | my $self = shift; | |||||||||||||
| 457 | |||||||||||||||
| 458 | return | ||||||||||||||
| 459 | { | ||||||||||||||
| 460 | 57 | (map { $_ => 0 } qw(max seen ok todo skip bonus)), | |||||||||||||
| 461 | filename => $self->file(), | ||||||||||||||
| 462 | details => [], | ||||||||||||||
| 463 | _is_vms => $self->_is_vms(), | ||||||||||||||
| 464 | }; | ||||||||||||||
| 465 | } | ||||||||||||||
| 466 | |||||||||||||||
| 467 | sub _is_event_todo | ||||||||||||||
| 468 | 0 | ▶ | { | ||||||||||||
|
Subroutine
_is_event_todo: not called CC=1 SCAR=6.9
| |||||||||||||||
| 469 | 0 | my $self = shift; | |||||||||||||
| 470 | |||||||||||||||
| 471 | 0 | return $self->_event->has_todo(); | |||||||||||||
| 472 | } | ||||||||||||||
| 473 | |||||||||||||||
| 474 | =head2 $strap->analyze_fh() | ||||||||||||||
| 475 | |||||||||||||||
| 476 | Analyzes a TAP stream based on the TAP::Parser from $self->_create_parser(). | ||||||||||||||
| 477 | |||||||||||||||
| 478 | =cut | ||||||||||||||
| 479 | |||||||||||||||
| 480 | sub analyze_fh | ||||||||||||||
| 481 | 57 | ▶ | { | ||||||||||||
|
Subroutine
analyze_fh: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 482 | 57 | my $self = shift; | |||||||||||||
| 483 | |||||||||||||||
| 484 | 57 | $self->_parser($self->_create_parser()); | |||||||||||||
| 485 | |||||||||||||||
| 486 | 57 | return $self->_analyze_with_parser(); | |||||||||||||
| 487 | } | ||||||||||||||
| 488 | |||||||||||||||
| 489 | sub _analyze_fh_wrapper | ||||||||||||||
| 490 | 57 | ▶ | { | ||||||||||||
|
Subroutine
_analyze_fh_wrapper: called CC=1 SCAR=0.0
| |||||||||||||||
| 491 | 57 | my $self = shift; | |||||||||||||
| 492 | |||||||||||||||
| 493 | eval | ||||||||||||||
| 494 | 57 | { | |||||||||||||
| 495 | 57 | $self->results($self->analyze_fh()); | |||||||||||||
| 496 | }; | ||||||||||||||
| 497 | 57 | $self->exception($@); | |||||||||||||
| 498 | |||||||||||||||
| 499 | 57 | return; | |||||||||||||
| 500 | } | ||||||||||||||
| 501 | |||||||||||||||
| 502 | sub _throw_trapped_exception | ||||||||||||||
| 503 | 57 | ▶ | { | ||||||||||||
|
Subroutine
_throw_trapped_exception: called CC=2 SCAR=6.9
| |||||||||||||||
| 504 | 57 | my $self = shift; | |||||||||||||
| 505 | |||||||||||||||
| 506 | 57 | ▶ | if ($self->exception() ne "") | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 507 | { | ||||||||||||||
| 508 | 2 | die $self->exception(); | |||||||||||||
| 509 | } | ||||||||||||||
| 510 | |||||||||||||||
| 511 | 55 | return; | |||||||||||||
| 512 | } | ||||||||||||||
| 513 | |||||||||||||||
| 514 | sub _cleanup_analysis | ||||||||||||||
| 515 | 57 | ▶ | { | ||||||||||||
|
Subroutine
_cleanup_analysis: called CC=1 SCAR=0.0
| |||||||||||||||
| 516 | 57 | my ($self) = @_; | |||||||||||||
| 517 | |||||||||||||||
| 518 | 57 | $self->_throw_trapped_exception(); | |||||||||||||
| 519 | |||||||||||||||
| 520 | 55 | $self->results()->_calc_all_process_status(); | |||||||||||||
| 521 | |||||||||||||||
| 522 | 55 | return; | |||||||||||||
| 523 | } | ||||||||||||||
| 524 | |||||||||||||||
| 525 | =head2 $strap->analyze_file($filename) | ||||||||||||||
| 526 | |||||||||||||||
| 527 | Runs and analyzes the program file C<$filename>. It will also use it | ||||||||||||||
| 528 | as the name in the final report. | ||||||||||||||
| 529 | |||||||||||||||
| 530 | =cut | ||||||||||||||
| 531 | |||||||||||||||
| 532 | sub analyze_file | ||||||||||||||
| 533 | 57 | ▶ | { | ||||||||||||
|
Subroutine
analyze_file: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 534 | 57 | my ($self, $file) = @_; | |||||||||||||
| 535 | |||||||||||||||
| 536 | # Assign it here so it won't be passed around. | ||||||||||||||
| 537 | 57 | $self->file($file); | |||||||||||||
| 538 | |||||||||||||||
| 539 | 57 | $self->_analyze_fh_wrapper(); | |||||||||||||
| 540 | |||||||||||||||
| 541 | 57 | $self->_cleanup_analysis(); | |||||||||||||
| 542 | |||||||||||||||
| 543 | 55 | return $self->results(); | |||||||||||||
| 544 | } | ||||||||||||||
| 545 | |||||||||||||||
| 546 | sub _default_inc | ||||||||||||||
| 547 | 60 | ▶ | { | ||||||||||||
|
Subroutine
_default_inc: called CC=1 SCAR=0.0
| |||||||||||||||
| 548 | 60 | my $self = shift; | |||||||||||||
| 549 | |||||||||||||||
| 550 | # Temporarily nullify PERL5LIB so Perl will not report the paths | ||||||||||||||
| 551 | # that it contains. | ||||||||||||||
| 552 | 60 | local $ENV{PERL5LIB}; | |||||||||||||
| 553 | |||||||||||||||
| 554 | 60 | my $perl_includes; | |||||||||||||
| 555 | |||||||||||||||
| 556 | 60 | my @includes = capturex( $^X, "-e", qq{print join("\\n", \@INC);} ); | |||||||||||||
| 557 | 60 | chomp(@includes); | |||||||||||||
| 558 | |||||||||||||||
| 559 | 60 | return \@includes; | |||||||||||||
| 560 | } | ||||||||||||||
| 561 | |||||||||||||||
| 562 | =head2 $strap->_filtered_INC(\@inc) | ||||||||||||||
| 563 | |||||||||||||||
| 564 | Filters @inc so it will fit into the environment of some operating systems | ||||||||||||||
| 565 | which limit it (such as VMS). | ||||||||||||||
| 566 | |||||||||||||||
| 567 | =cut | ||||||||||||||
| 568 | |||||||||||||||
| 569 | sub _filtered_INC | ||||||||||||||
| 570 | 60 | ▶ | { | ||||||||||||
|
Subroutine
_filtered_INC: called CC=5 SCAR=18.0
| |||||||||||||||
| 571 | 60 | my ($self, $inc_param) = @_; | |||||||||||||
| 572 | |||||||||||||||
| 573 | 60 | ▶ | my @inc = $inc_param ? @$inc_param : @INC; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 574 | |||||||||||||||
| 575 | 60 | ▶ | if ($self->_is_vms()) | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 576 | { | ||||||||||||||
| 577 | 0 | @inc = grep { !m{perl_root}i } @inc; | |||||||||||||
| 578 | } | ||||||||||||||
| 579 | elsif ($self->_is_win32()) | ||||||||||||||
| 580 | { | ||||||||||||||
| 581 | 0 | foreach my $path (@inc) | |||||||||||||
| 582 | { | ||||||||||||||
| 583 | 0 | $path =~ s{[\\/]+\z}{}ms; | |||||||||||||
| 584 | } | ||||||||||||||
| 585 | } | ||||||||||||||
| 586 | |||||||||||||||
| 587 | 60 | my %seen; | |||||||||||||
| 588 | |||||||||||||||
| 589 | 60 | %seen = (map { $_ => 1} @{$self->_default_inc()}); | |||||||||||||
| 590 | 60 | @inc = (grep { ! $seen{$_}++ } @inc); | |||||||||||||
| 591 | |||||||||||||||
| 592 | 60 | return \@inc; | |||||||||||||
| 593 | } | ||||||||||||||
| 594 | |||||||||||||||
| 595 | =head2 [@filtered] = $strap->_clean_switches(\@switches) | ||||||||||||||
| 596 | |||||||||||||||
| 597 | Returns trimmed and blank-filtered switches from the user. | ||||||||||||||
| 598 | |||||||||||||||
| 599 | =cut | ||||||||||||||
| 600 | |||||||||||||||
| 601 | sub _trim | ||||||||||||||
| 602 | 346 | ▶ | { | ||||||||||||
|
Subroutine
_trim: called CC=2 SCAR=7.2
| |||||||||||||||
| 603 | 346 | my $s = shift; | |||||||||||||
| 604 | |||||||||||||||
| 605 | 346 | ▶ | if (!defined($s)) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 606 | { | ||||||||||||||
| 607 | 0 | return (); | |||||||||||||
| 608 | } | ||||||||||||||
| 609 | 346 | $s =~ s{\A\s+}{}ms; | |||||||||||||
| 610 | 346 | $s =~ s{\s+\z}{}ms; | |||||||||||||
| 611 | |||||||||||||||
| 612 | 346 | return ($s); | |||||||||||||
| 613 | } | ||||||||||||||
| 614 | |||||||||||||||
| 615 | sub _split_switches | ||||||||||||||
| 616 | 60 | ▶ | { | ||||||||||||
|
Subroutine
_split_switches: called CC=1 SCAR=0.0
| |||||||||||||||
| 617 | 60 | my $self = shift; | |||||||||||||
| 618 | 60 | my $switches = shift; | |||||||||||||
| 619 | |||||||||||||||
| 620 | return | ||||||||||||||
| 621 | [ | ||||||||||||||
| 622 | map | ||||||||||||||
| 623 | 346 | { my $s = $_; $s =~ s{\A"(.*)"\z}{$1}; $s } | |||||||||||||
| 624 | map | ||||||||||||||
| 625 | 62 | { split(/\s+/, $_) } | |||||||||||||
| 626 | grep | ||||||||||||||
| 627 | 60 | { defined($_) } | |||||||||||||
| 628 | @$switches | ||||||||||||||
| 629 | ]; | ||||||||||||||
| 630 | } | ||||||||||||||
| 631 | |||||||||||||||
| 632 | sub _clean_switches | ||||||||||||||
| 633 | 60 | ▶ | { | ||||||||||||
|
Subroutine
_clean_switches: called CC=1 SCAR=0.0
| |||||||||||||||
| 634 | 60 | my ($self, $switches) = @_; | |||||||||||||
| 635 | |||||||||||||||
| 636 | 60 | return [grep { length($_) } map { _trim($_) } @$switches]; | |||||||||||||
| 637 | } | ||||||||||||||
| 638 | |||||||||||||||
| 639 | sub _get_shebang | ||||||||||||||
| 640 | 60 | ▶ | { | ||||||||||||
|
Subroutine
_get_shebang: called CC=3 SCAR=11.1
| |||||||||||||||
| 641 | 60 | my($self) = @_; | |||||||||||||
| 642 | |||||||||||||||
| 643 | 60 | my $file = $self->file(); | |||||||||||||
| 644 | |||||||||||||||
| 645 | 60 | my $test_fh; | |||||||||||||
| 646 | 60 | ▶ | if (!open($test_fh, $file)) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 647 | { | ||||||||||||||
| 648 | 1 | $self->_handle_test_file_opening_error( | |||||||||||||
| 649 | { | ||||||||||||||
| 650 | file => $file, | ||||||||||||||
| 651 | error => $!, | ||||||||||||||
| 652 | } | ||||||||||||||
| 653 | ); | ||||||||||||||
| 654 | 1 | return ""; | |||||||||||||
| 655 | } | ||||||||||||||
| 656 | 59 | my $shebang = <$test_fh>; | |||||||||||||
| 657 | 59 | ▶ | if (!close($test_fh)) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 658 | { | ||||||||||||||
| 659 | 0 | $self->_handle_test_file_closing_error( | |||||||||||||
| 660 | { | ||||||||||||||
| 661 | file => $file, | ||||||||||||||
| 662 | error => $!, | ||||||||||||||
| 663 | } | ||||||||||||||
| 664 | ); | ||||||||||||||
| 665 | } | ||||||||||||||
| 666 | 59 | return $shebang; | |||||||||||||
| 667 | } | ||||||||||||||
| 668 | |||||||||||||||
| 669 | =head2 $self->_command() | ||||||||||||||
| 670 | |||||||||||||||
| 671 | Returns the command (the command-line executable) that will run the test | ||||||||||||||
| 672 | along with L<_switches()>. | ||||||||||||||
| 673 | |||||||||||||||
| 674 | Normally returns $^X, but can be over-rided using the C<Test_Interpreter> | ||||||||||||||
| 675 | accessor. | ||||||||||||||
| 676 | |||||||||||||||
| 677 | This method can be over-rided in custom test harnesses in order to run | ||||||||||||||
| 678 | using different TAP producers than Perl. | ||||||||||||||
| 679 | |||||||||||||||
| 680 | =cut | ||||||||||||||
| 681 | |||||||||||||||
| 682 | sub _command | ||||||||||||||
| 683 | 60 | ▶ | { | ||||||||||||
|
Subroutine
_command: called CC=3 SCAR=11.0
| |||||||||||||||
| 684 | 60 | my $self = shift; | |||||||||||||
| 685 | |||||||||||||||
| 686 | 60 | ▶ | if (defined(my $interp = $self->Test_Interpreter())) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 687 | { | ||||||||||||||
| 688 | return | ||||||||||||||
| 689 | 1 | ▶ | +(ref($interp) eq "ARRAY") | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 690 | ? (@$interp) | ||||||||||||||
| 691 | : (split(/\s+/, $interp)) | ||||||||||||||
| 692 | ; | ||||||||||||||
| 693 | } | ||||||||||||||
| 694 | else | ||||||||||||||
| 695 | { | ||||||||||||||
| 696 | 59 | return $self->_default_command($^X); | |||||||||||||
| 697 | } | ||||||||||||||
| 698 | } | ||||||||||||||
| 699 | |||||||||||||||
| 700 | sub _default_command | ||||||||||||||
| 701 | 59 | ▶ | { | ||||||||||||
|
Subroutine
_default_command: called CC=2 SCAR=7.4
| |||||||||||||||
| 702 | 59 | my $self = shift; | |||||||||||||
| 703 | 59 | my $path = shift; | |||||||||||||
| 704 | |||||||||||||||
| 705 | 59 | ▶ | if ($self->_is_win32()) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 706 | { | ||||||||||||||
| 707 | 0 | return Win32::GetShortPathName($path); | |||||||||||||
| 708 | } | ||||||||||||||
| 709 | else | ||||||||||||||
| 710 | { | ||||||||||||||
| 711 | 59 | return $path; | |||||||||||||
| 712 | } | ||||||||||||||
| 713 | } | ||||||||||||||
| 714 | |||||||||||||||
| 715 | sub _handle_test_file_opening_error | ||||||||||||||
| 716 | 1 | ▶ | { | ||||||||||||
|
Subroutine
_handle_test_file_opening_error: called CC=1 SCAR=0.0
| |||||||||||||||
| 717 | 1 | my ($self, $args) = @_; | |||||||||||||
| 718 | |||||||||||||||
| 719 | 1 | $self->_invoke_cb({type => "test_file_opening_error", %$args}); | |||||||||||||
| 720 | } | ||||||||||||||
| 721 | |||||||||||||||
| 722 | sub _handle_test_file_closing_error | ||||||||||||||
| 723 | 0 | ▶ | { | ||||||||||||
|
Subroutine
_handle_test_file_closing_error: not called CC=1 SCAR=6.9
| |||||||||||||||
| 724 | 0 | my ($self, $args) = @_; | |||||||||||||
| 725 | |||||||||||||||
| 726 | 0 | $self->_invoke_cb({type => "test_file_closing_error", %$args}); | |||||||||||||
| 727 | } | ||||||||||||||
| 728 | |||||||||||||||
| 729 | =head2 $strap->_restore_PERL5LIB() | ||||||||||||||
| 730 | |||||||||||||||
| 731 | Restores the old value of PERL5LIB. This is necessary on VMS. Does not | ||||||||||||||
| 732 | do anything on other platforms. | ||||||||||||||
| 733 | |||||||||||||||
| 734 | =cut | ||||||||||||||
| 735 | |||||||||||||||
| 736 | sub _restore_PERL5LIB | ||||||||||||||
| 737 | 106 | ▶ | { | ||||||||||||
|
Subroutine
_restore_PERL5LIB: called CC=2 SCAR=7.6
| |||||||||||||||
| 738 | 106 | my $self = shift; | |||||||||||||
| 739 | |||||||||||||||
| 740 | 106 | ▶ | if ($self->_is_vms()) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 741 | { | ||||||||||||||
| 742 | 0 | $ENV{PERL5LIB} = $self->_old5lib(); | |||||||||||||
| 743 | } | ||||||||||||||
| 744 | |||||||||||||||
| 745 | 106 | return; | |||||||||||||
| 746 | } | ||||||||||||||
| 747 | |||||||||||||||
| 748 | =head2 $self->_reset_file_state() | ||||||||||||||
| 749 | |||||||||||||||
| 750 | Reset some fields so it will be ready to process the next file. | ||||||||||||||
| 751 | |||||||||||||||
| 752 | =cut | ||||||||||||||
| 753 | |||||||||||||||
| 754 | sub _calc_reset_file_state | ||||||||||||||
| 755 | 57 | ▶ | { | ||||||||||||
|
Subroutine
_calc_reset_file_state: called CC=1 SCAR=0.0
| |||||||||||||||
| 756 | 57 | my $self = shift; | |||||||||||||
| 757 | |||||||||||||||
| 758 | return | ||||||||||||||
| 759 | { | ||||||||||||||
| 760 | 57 | too_many_tests => undef(), | |||||||||||||
| 761 | todo => +{}, | ||||||||||||||
| 762 | saw_header => 0, | ||||||||||||||
| 763 | saw_bailout => 0, | ||||||||||||||
| 764 | bailout_reason => "", | ||||||||||||||
| 765 | next_test_num => 1, | ||||||||||||||
| 766 | }; | ||||||||||||||
| 767 | } | ||||||||||||||
| 768 | |||||||||||||||
| 769 | sub _reset_file_state | ||||||||||||||
| 770 | 57 | ▶ | { | ||||||||||||
|
Subroutine
_reset_file_state: called CC=2 SCAR=6.9
| |||||||||||||||
| 771 | 57 | my $self = shift; | |||||||||||||
| 772 | |||||||||||||||
| 773 | 57 | my $to = $self->_calc_reset_file_state(); | |||||||||||||
| 774 | |||||||||||||||
| 775 | 57 | ▶ | while (my ($field, $value) = each(%$to)) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 776 | { | ||||||||||||||
| 777 | 342 | $self->$field($value); | |||||||||||||
| 778 | } | ||||||||||||||
| 779 | |||||||||||||||
| 780 | 57 | return; | |||||||||||||
| 781 | } | ||||||||||||||
| 782 | |||||||||||||||
| 783 | sub _calc_existing_switches | ||||||||||||||
| 784 | 60 | ▶ | { | ||||||||||||
|
Subroutine
_calc_existing_switches: called CC=1 SCAR=0.0
| |||||||||||||||
| 785 | 60 | my $self = shift; | |||||||||||||
| 786 | |||||||||||||||
| 787 | 60 | return $self->_clean_switches( | |||||||||||||
| 788 | $self->_split_switches( | ||||||||||||||
| 789 | [$self->Switches(), $self->Switches_Env()] | ||||||||||||||
| 790 | ) | ||||||||||||||
| 791 | ); | ||||||||||||||
| 792 | } | ||||||||||||||
| 793 | |||||||||||||||
| 794 | sub _calc_taint_flag | ||||||||||||||
| 795 | 60 | ▶ | { | ||||||||||||
|
Subroutine
_calc_taint_flag: called CC=2 SCAR=6.9
| |||||||||||||||
| 796 | 60 | my $self = shift; | |||||||||||||
| 797 | |||||||||||||||
| 798 | 60 | my $shebang = $self->_get_shebang(); | |||||||||||||
| 799 | |||||||||||||||
| 800 | 60 | ▶ | if ($shebang =~ m{^#!.*\bperl.*\s-\w*([Tt]+)}) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 801 | { | ||||||||||||||
| 802 | 3 | return ($1); | |||||||||||||
| 803 | } | ||||||||||||||
| 804 | else | ||||||||||||||
| 805 | { | ||||||||||||||
| 806 | 57 | return; | |||||||||||||
| 807 | } | ||||||||||||||
| 808 | } | ||||||||||||||
| 809 | |||||||||||||||
| 810 | sub _calc_derived_switches | ||||||||||||||
| 811 | 60 | ▶ | { | ||||||||||||
|
Subroutine
_calc_derived_switches: called CC=2 SCAR=6.9
| |||||||||||||||
| 812 | 60 | my $self = shift; | |||||||||||||
| 813 | |||||||||||||||
| 814 | 60 | ▶ | if (my ($t) = $self->_calc_taint_flag()) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 815 | { | ||||||||||||||
| 816 | 3 | return ["-$t", map { "-I$_" } @{$self->_filtered_INC()}]; | |||||||||||||
| 817 | } | ||||||||||||||
| 818 | else | ||||||||||||||
| 819 | { | ||||||||||||||
| 820 | 57 | return []; | |||||||||||||
| 821 | } | ||||||||||||||
| 822 | } | ||||||||||||||
| 823 | |||||||||||||||
| 824 | =head2 $self->_switches() | ||||||||||||||
| 825 | |||||||||||||||
| 826 | Calculates and returns the switches necessary to run the test. | ||||||||||||||
| 827 | |||||||||||||||
| 828 | =cut | ||||||||||||||
| 829 | |||||||||||||||
| 830 | sub _switches | ||||||||||||||
| 831 | 60 | ▶ | { | ||||||||||||
|
Subroutine
_switches: called CC=1 SCAR=0.0
| |||||||||||||||
| 832 | 60 | my $self = shift; | |||||||||||||
| 833 | |||||||||||||||
| 834 | return | ||||||||||||||
| 835 | [ | ||||||||||||||
| 836 | 60 | @{$self->_calc_existing_switches()}, | |||||||||||||
| 837 | 60 | @{$self->_calc_derived_switches()}, | |||||||||||||
| 838 | ]; | ||||||||||||||
| 839 | } | ||||||||||||||
| 840 | |||||||||||||||
| 841 | =head2 local $ENV{PERL5LIB} = $self->_INC2PERL5LIB() | ||||||||||||||
| 842 | |||||||||||||||
| 843 | Takes the calculated library paths for running the test scripts and returns | ||||||||||||||
| 844 | it as something that one can assign to the PERL5LIB environment variable. | ||||||||||||||
| 845 | |||||||||||||||
| 846 | =cut | ||||||||||||||
| 847 | |||||||||||||||
| 848 | sub _INC2PERL5LIB | ||||||||||||||
| 849 | 57 | ▶ | { | ||||||||||||
|
Subroutine
_INC2PERL5LIB: called CC=1 SCAR=0.0
| |||||||||||||||
| 850 | 57 | my $self = shift; | |||||||||||||
| 851 | |||||||||||||||
| 852 | 57 | $self->_old5lib($ENV{PERL5LIB}); | |||||||||||||
| 853 | |||||||||||||||
| 854 | 57 | return join($Config{path_sep}, @{$self->_filtered_INC()}); | |||||||||||||
| 855 | } | ||||||||||||||
| 856 | |||||||||||||||
| 857 | |||||||||||||||
| 858 | 15 | 1; | |||||||||||||
| 859 | |||||||||||||||
| 860 | =head1 LICENSE | ||||||||||||||
| 861 | |||||||||||||||
| 862 | This file is licensed under the MIT X11 License: | ||||||||||||||
| 863 | |||||||||||||||
| 864 | http://www.opensource.org/licenses/mit-license.php | ||||||||||||||
| 865 | |||||||||||||||
| 866 | =head1 AUTHOR | ||||||||||||||
| 867 | |||||||||||||||
| 868 | Shlomi Fish, L<http://www.shlomifish.org/> . | ||||||||||||||