# -*- Mode: cperl; cperl-indent-level: 4 -*-
-# $Id: Harness.pm,v 1.31 2002/05/18 20:19:06 schwern Exp $
+# $Id: Harness.pm,v 1.33 2002/05/29 23:02:48 schwern Exp $
package Test::Harness;
$Have_Devel_Corestack = 0;
-$VERSION = '2.23';
+$VERSION = '2.24';
$ENV{HARNESS_ACTIVE} = 1;
1..0 # Skipped: no leverage found
-If you don't have any comment on skipping, just print C<1..0> with
-nothing after it. Test::Harness will say something like this:
-
-op/64bitint..............skipped
- skipped: no reason given
-
-
=item B<Todo tests>
If the standard output line contains the substring C< # TODO> after
$tot{files}++;
$Strap->{_seen_header} = 0;
- my %results = $Strap->analyze_file($tfile);
+ my %results = $Strap->analyze_file($tfile) or
+ do { warn "$Strap->{error}\n"; next };
# state of the current test.
my @failed = grep { !$results{details}[$_-1]{ok} }
print "$test{ml}ok\n ".join(', ', @msg)."\n";
} elsif ($test{max}) {
print "$test{ml}ok\n";
- } elsif (defined $test{skip_all}) {
+ } elsif (length $test{skip_all}) {
print "skipped\n all skipped: $test{skip_all}\n";
$tot{skipped}++;
} else {
- print "\n skipped test on this platform\n";
+ print "skipped\n all skipped: no reason given\n";
$tot{skipped}++;
}
$tot{good}++;
Revision history for Perl extension Test::Harness
+2.24 Wed May 29 19:02:18 EDT 2002
+ * Nikola Knezevic found a bug when tests are completely skipped
+ but no reason is given it was considered a failure.
+ * Made Test::Harness::Straps->analyze_file & Test::Harness a bit
+ more graceful when the test doesn't exist.
+
2.23 Wed May 22 12:59:47 EDT 2002
- reason for all skip wasn't being displayed. Broken in 2.20.
- Changed the wait status tests to conform with POSIX standards.
# -*- Mode: cperl; cperl-indent-level: 4 -*-
-# $Id: Straps.pm,v 1.6 2002/05/17 23:04:11 schwern Exp $
+# $Id: Straps.pm,v 1.8 2002/05/29 23:02:48 schwern Exp $
package Test::Harness::Straps;
use strict;
use vars qw($VERSION);
use Config;
-$VERSION = '0.11';
+$VERSION = '0.12';
use Test::Harness::Assert;
use Test::Harness::Iterator;
$totals{skip_all} = $self->{skip_all} if defined $self->{skip_all};
- my $passed = $totals{skip_all} ||
+ my $passed = !$totals{max} ||
($totals{max} && $totals{seen} &&
$totals{max} == $totals{seen} &&
$totals{max} == $totals{ok});
sub analyze_file {
my($self, $file) = @_;
+ unless( -e $file ) {
+ $self->{error} = "$file does not exist";
+ return;
+ }
+
+ unless( -r $file ) {
+ $self->{error} = "$file is not readable";
+ return;
+ }
+
local $ENV{PERL5LIB} = $self->_INC2PERL5LIB;
# Is this necessary anymore?
my $s = '';
$s .= " $ENV{'HARNESS_PERL_SWITCHES'}"
if exists $ENV{'HARNESS_PERL_SWITCHES'};
- $s .= qq[ "-$1" ] if $first =~ /^#!.*\bperl.*\s-\w*([Tt]+)/;
- $s .= join " ", map {qq["-I$_"]} $self->_filtered_INC;
+
+ # When taint mode is on, PERL5LIB is ignored. So we need to put
+ # all that on the command line as -Is.
+ $s .= join " ", qq[ "-$1"], map {qq["-I$_"]} $self->_filtered_INC
+ if $first =~ /^#!.*\bperl.*\s-\w*([Tt]+)/;
close(TEST) or print "can't close $file. $!\n";
if( my($max, $extra) = $line =~ /^1\.\.(\d+)(.*)/ ) {
$self->{max} = $max;
assert( $self->{max} >= 0, 'Max # of tests looks right' );
- if( defined $extra ) {
+
+ if( defined $extra ) {
my($todo, $skip, $reason) = $extra =~ /$Extra_Header_Re/xo;
$self->{todo} = { map { $_ => 1 } split /\s+/, $todo } if $todo;
}
}
-use File::Spec::Functions;
-
-my $SAMPLE_TESTS = $ENV{PERL_CORE}
- ? catdir(curdir(), 'lib', 'sample-tests')
- : catdir(curdir(), 't', 'sample-tests');
+my $SAMPLE_TESTS = $ENV{PERL_CORE} ? 'lib/sample-tests' : 't/sample-tests';
use Test::More;
simple => [qw( header test test test test test )],
simple_fail => [qw( header test test test test test )],
'skip' => [qw( header test test test test test )],
- skip_all => [qw( header )],
- skip_no_msg => [qw( header test )],
+ skipall => [qw( header )],
+ skipall_nomsg => [qw( header )],
+ skip_nomsg => [qw( header test )],
taint => [qw( header test )],
'todo' => [qw( header test test test test test )],
todo_inline => [qw( header test test test )],
while( my($test, $expect) = each %samples ) {
local @out = ();
- $strap->analyze_file(catfile($SAMPLE_TESTS, $test));
+ $strap->analyze_file("$SAMPLE_TESTS/$test");
is_deeply(\@out, $expect, "$test callback");
}
}
}
-use File::Spec::Functions;
-
-my $SAMPLE_TESTS = $ENV{PERL_CORE}
- ? catdir(curdir(), 'lib', 'sample-tests')
- : catdir(curdir(), 't', 'sample-tests');
+my $SAMPLE_TESTS = $ENV{PERL_CORE} ? 'lib/sample-tests' : 't/sample-tests';
use strict;
use Test::More;
-if ($^O eq 'MacOS') {
- plan skip_all => "Exit status broken on Mac OS";
-}
-
my $IsVMS = $^O eq 'VMS';
# VMS uses native, not POSIX, exit codes.
]
},
- skip_all => {
+ 'skip_nomsg' => {
+ passing => 1,
+
+ 'exit' => 0,
+ 'wait' => 0,
+
+ max => 1,
+ seen => 1,
+
+ 'ok' => 1,
+ 'todo' => 0,
+ 'skip' => 1,
+ bonus => 0,
+
+ details => [ { 'ok' => 1, actual_ok => 1,
+ type => 'skip',
+ reason => '',
+ },
+ ]
+ },
+
+ skipall => {
passing => 1,
'exit' => 0,
details => [],
},
+ skipall_nomsg => {
+ passing => 1,
+
+ 'exit' => 0,
+ 'wait' => 0,
+
+ max => 0,
+ seen => 0,
+
+ 'ok' => 0,
+ 'todo' => 0,
+ 'skip' => 0,
+ bonus => 0,
+
+ details => [],
+ },
+
'todo' => {
passing => 1,
},
);
-plan tests => (keys(%samples) * 3) + 1;
+plan tests => (keys(%samples) * 3) + 3;
use_ok('Test::Harness::Straps');
}
my $strap = Test::Harness::Straps->new;
- my %results = $strap->analyze_file(catfile($SAMPLE_TESTS, $test));
+ my %results = $strap->analyze_file("$SAMPLE_TESTS/$test");
is_deeply($results{details}, $expect->{details}, "$test details" );
is_deeply(\%results, $expect, " the rest $test" );
}
+
+
+my $strap = Test::Harness::Straps->new;
+ok( !$strap->analyze_file('I_dont_exist') );
+is( $strap->{error}, "I_dont_exist does not exist" );
}
}
-use File::Spec::Functions;
-
-my $SAMPLE_TESTS = $ENV{PERL_CORE}
- ? catdir(curdir(), 'lib', 'sample-tests')
- : catdir(curdir(), 't', 'sample-tests');
+my $SAMPLE_TESTS = $ENV{PERL_CORE} ? "lib/sample-tests" : "t/sample-tests";
use strict;
use Test::More;
my $IsVMS = $^O eq 'VMS';
-my $IsMacOS = $^O eq 'MacOS';
# VMS uses native, not POSIX, exit codes.
-my $die_estat = $IsVMS ? 44 : $IsMacOS ? 0 : 1;
+my $die_estat = $IsVMS ? 44 : 1;
my %samples = (
simple => {
failed => { },
all_ok => 1,
},
+ 'skip_nomsg' => {
+ total => {
+ bonus => 0,
+ max => 1,
+ 'ok' => 1,
+ files => 1,
+ bad => 0,
+ good => 1,
+ tests => 1,
+ sub_skipped=> 1,
+ 'todo' => 0,
+ skipped => 0,
+ },
+ failed => { },
+ all_ok => 1,
+ },
bailout => 0,
combined => {
total => {
},
all_ok => 0,
},
- skip_all => {
+ skipall => {
+ total => {
+ bonus => 0,
+ max => 0,
+ 'ok' => 0,
+ files => 1,
+ bad => 0,
+ good => 1,
+ tests => 1,
+ sub_skipped=> 0,
+ 'todo' => 0,
+ skipped => 1,
+ },
+ failed => { },
+ all_ok => 1,
+ },
+ skipall_nomsg => {
total => {
bonus => 0,
max => 0,
select NULL; # _run_all_tests() isn't as quiet as it should be.
local $SIG{__WARN__} = sub { $warning .= join '', @_; };
($totals, $failed) =
- Test::Harness::_run_all_tests(catfile($SAMPLE_TESTS, $test));
+ Test::Harness::_run_all_tests("$SAMPLE_TESTS/$test");
};
select STDOUT;
is_deeply( {map { $_=>$totals->{$_} } keys %{$expect->{total}}},
$expect->{total},
"$test - totals" );
- is_deeply( {map { $_=>$failed->{catfile($SAMPLE_TESTS, $test)}{$_} }
+ is_deeply( {map { $_=>$failed->{"$SAMPLE_TESTS/$test"}{$_} }
keys %{$expect->{failed}}},
$expect->{failed},
"$test - failed" );
-use lib 'lib';
use if ($^O eq 'VMS'), vmsish => 'hushed';
exit 1; # exit because die() can be noisy
--- /dev/null
+print <<DUMMY;
+1..1
+ok 1 # Skip
+DUMMY
--- /dev/null
+print <<DUMMY_TEST;
+1..0 # skip: rope
+DUMMY_TEST
--- /dev/null
+print "1..0\n";
+exit 0;