Skip to content

Commit 6e7e689

Browse files
bulk88Leont
authored andcommitted
dont do VMS TAP fixups on any platform but VMS
Also combine subs with identical bodies. On Win32, memory usage sampled with "perl -MTAP::Parser::Iterator -E"system 'pause'" caused memory usage to drop from 2,688KB to 2,672KB after this commit for me. next() dropped from 68us inclusive to 44us with nytprof, for comparison next_raw is 39us. next() is called once per test so it is hot. # Conflicts: # t/compat/test-harness-compat.t
1 parent 263d63d commit 6e7e689

File tree

3 files changed

+62
-53
lines changed

3 files changed

+62
-53
lines changed

lib/TAP/Parser/Iterator.pm

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ Iterate raw input without applying any fixes for quirky input syntax.
6161
6262
=cut
6363

64+
if ( $^O eq 'VMS' ) {
65+
eval <<'END' ;
6466
sub next {
6567
my $self = shift;
6668
my $line = $self->next_raw;
@@ -75,6 +77,11 @@ sub next {
7577
7678
return $line;
7779
}
80+
END
81+
}
82+
else {
83+
eval 'sub next { shift->next_raw(@_) }';
84+
}
7885

7986
sub next_raw {
8087
require Carp;
@@ -125,17 +132,8 @@ Return the C<exit> status for this iterator.
125132
126133
=cut
127134

128-
sub wait {
129-
require Carp;
130-
my $msg = Carp::longmess('abstract method called directly!');
131-
$_[0]->_croak($msg);
132-
}
133-
134-
sub exit {
135-
require Carp;
136-
my $msg = Carp::longmess('abstract method called directly!');
137-
$_[0]->_croak($msg);
138-
}
135+
#can not call abstract base method, next_raw is a fatal stub
136+
*exit = *wait = *next_raw;
139137

140138
1;
141139

t/compat/test-harness-compat.t

Lines changed: 42 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -150,14 +150,17 @@ if ($NoTaintSupport) {
150150
'name' => "$TEST_DIR/too_many",
151151
'wstat' => '1024'
152152
},
153-
"$TEST_DIR/vms_nit" => {
154-
'canon' => 1,
155-
'estat' => '',
156-
'failed' => 1,
157-
'max' => 2,
158-
'name' => "$TEST_DIR/vms_nit",
159-
'wstat' => ''
160-
}
153+
( $^O eq 'VMS' ?
154+
("$TEST_DIR/vms_nit" => {
155+
'canon' => 1,
156+
'estat' => '',
157+
'failed' => 1,
158+
'max' => 2,
159+
'name' => "$TEST_DIR/vms_nit",
160+
'wstat' => ''
161+
})
162+
: ()
163+
)
161164
},
162165
'todo' => {
163166
"$TEST_DIR/todo_inline" => {
@@ -170,12 +173,12 @@ if ($NoTaintSupport) {
170173
}
171174
},
172175
'totals' => {
173-
'bad' => ($NoTaintSupport ? 11 : 12),
176+
'bad' => ($NoTaintSupport ? 11 : 12)-($^O eq 'VMS' ? 0 : 1),
174177
'bonus' => 1,
175178
'files' => ($NoTaintSupport ? 24 : 27),
176-
'good' => ($NoTaintSupport ? 13 : 15),
179+
'good' => ($NoTaintSupport ? 13 : 15)+($^O eq 'VMS' ? 0 : 1),
177180
'max' => ($NoTaintSupport ? 72 : 76),
178-
'ok' => ($NoTaintSupport ? 75 : 78),
181+
'ok' => ($NoTaintSupport ? 75 : 78)+($^O eq 'VMS' ? 0 : 1),
179182
'skipped' => 2,
180183
'sub_skipped' => 2,
181184
'tests' => ($NoTaintSupport ? 24 : 27),
@@ -739,31 +742,35 @@ if ($NoTaintSupport) {
739742
'todo' => 0
740743
}
741744
},
742-
'vms_nit' => {
743-
'failed' => {
744-
"$TEST_DIR/vms_nit" => {
745-
'canon' => 1,
746-
'estat' => '',
747-
'failed' => 1,
748-
'max' => 2,
749-
'name' => "$TEST_DIR/vms_nit",
750-
'wstat' => ''
745+
( $^O eq 'VMS' ?
746+
('vms_nit' => {
747+
'failed' => {
748+
"$TEST_DIR/vms_nit" => {
749+
'canon' => 1,
750+
'estat' => '',
751+
'failed' => 1,
752+
'max' => 2,
753+
'name' => "$TEST_DIR/vms_nit",
754+
'wstat' => ''
755+
}
756+
},
757+
'skip_if' => sub { $^O ne 'VMS' },
758+
'todo' => {},
759+
'totals' => {
760+
'bad' => 1,
761+
'bonus' => 0,
762+
'files' => 1,
763+
'good' => 0,
764+
'max' => 2,
765+
'ok' => 1,
766+
'skipped' => 0,
767+
'sub_skipped' => 0,
768+
'tests' => 1,
769+
'todo' => 0
751770
}
752-
},
753-
'todo' => {},
754-
'totals' => {
755-
'bad' => 1,
756-
'bonus' => 0,
757-
'files' => 1,
758-
'good' => 0,
759-
'max' => 2,
760-
'ok' => 1,
761-
'skipped' => 0,
762-
'sub_skipped' => 0,
763-
'tests' => 1,
764-
'todo' => 0
765-
}
766-
}
771+
})
772+
: ()
773+
)
767774
};
768775

769776
my $num_tests = ( keys %$results ) * $PER_LOOP;

t/iterators.t

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -155,16 +155,20 @@ for my $test (@schedule) {
155155

156156
{
157157

158+
my $iterator;
158159
# coverage test for VMS case
159160

160-
my $iterator = make_iterator(
161-
[ 'not ',
162-
'ok 1 - I hate VMS',
163-
]
164-
);
161+
SKIP : {
162+
skip('Not VMS', 1) if $^O ne 'VMS';
163+
$iterator = make_iterator(
164+
[ 'not ',
165+
'ok 1 - I hate VMS',
166+
]
167+
);
165168

166-
is $iterator->next, 'not ok 1 - I hate VMS',
167-
'coverage of VMS line-splitting case';
169+
is $iterator->next, 'not ok 1 - I hate VMS',
170+
'coverage of VMS line-splitting case';
171+
}
168172

169173
# coverage test for VMS case - nothing after 'not'
170174

0 commit comments

Comments
 (0)