diff options
author | Nicholas Clark <nick@ccl4.org> | 2008-08-26 10:51:53 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2008-08-26 10:51:53 +0000 |
commit | fbd6575c915bb6c2521a5086fde2a0e1607c6f01 (patch) | |
tree | 378fa1a62da2f50670e4b0942bc23b1a3103cc4a /ext | |
parent | 2a21c44486d05ca8bdd9ae5994c23a5fdc81d55f (diff) | |
download | perl-fbd6575c915bb6c2521a5086fde2a0e1607c6f01.tar.gz |
Move t/lib/{data,sample-tests,source_tests,subclass_tests} into
ext/Test/Harness/t/{data,sample-tests,source_tests,subclass_tests}
(The same path as in the Test-Harness distribution.)
p4raw-id: //depot/perl@34227
Diffstat (limited to 'ext')
80 files changed, 641 insertions, 39 deletions
diff --git a/ext/Test/Harness/t/compat/failure.t b/ext/Test/Harness/t/compat/failure.t index c1b902bab0..b164f9b908 100644 --- a/ext/Test/Harness/t/compat/failure.t +++ b/ext/Test/Harness/t/compat/failure.t @@ -19,11 +19,14 @@ use Test::Harness; return sub { $died = 1 } } - my $curdir = File::Spec->curdir; - my $sample_tests - = $ENV{PERL_CORE} - ? File::Spec->catdir( $curdir, 'lib', 'sample-tests' ) - : File::Spec->catdir( $curdir, 't', 'sample-tests' ); + my $sample_tests; + if ($ENV{PERL_CORE}) { + my $updir = File::Spec->updir; + $sample_tests = File::Spec->catdir( $updir, 'ext', 'Test', 'Harness', 't', 'sample-tests' ); + } else { + my $curdir = File::Spec->curdir; + $sample_tests = File::Spec->catdir( $curdir, 't', 'sample-tests' ); + } { local $SIG{__DIE__} = prepare_for_death(); diff --git a/ext/Test/Harness/t/compat/inc_taint.t b/ext/Test/Harness/t/compat/inc_taint.t index 06a8e237bd..bdb0d73e19 100644 --- a/ext/Test/Harness/t/compat/inc_taint.t +++ b/ext/Test/Harness/t/compat/inc_taint.t @@ -35,7 +35,7 @@ sub _all_ok { my ( $tot, $failed ) = Test::Harness::execute_tests( tests => [ $ENV{PERL_CORE} - ? 'lib/sample-tests/inc_taint' + ? '../ext/Test/Harness/t/sample-tests/inc_taint' : 't/sample-tests/inc_taint' ] ); diff --git a/ext/Test/Harness/t/data/catme.1 b/ext/Test/Harness/t/data/catme.1 new file mode 100644 index 0000000000..7ecdd9a102 --- /dev/null +++ b/ext/Test/Harness/t/data/catme.1 @@ -0,0 +1,2 @@ +1..1 +ok 1 diff --git a/ext/Test/Harness/t/data/proverc b/ext/Test/Harness/t/data/proverc new file mode 100644 index 0000000000..9d2924145d --- /dev/null +++ b/ext/Test/Harness/t/data/proverc @@ -0,0 +1,7 @@ +--should be --split correctly # No comment! +Can "quote things" 'using single or' "double quotes" + +# More stuff +--this +is +'OK?' diff --git a/ext/Test/Harness/t/data/sample.yml b/ext/Test/Harness/t/data/sample.yml new file mode 100644 index 0000000000..6c4b7fbf4a --- /dev/null +++ b/ext/Test/Harness/t/data/sample.yml @@ -0,0 +1,29 @@ +--- +invoice: 34843 +date : 2001-01-23 +bill-to: + given : Chris + family : Dumars + address: + lines: | + 458 Walkman Dr. + Suite #292 + city : Royal Oak + state : MI + postal : 48046 +product: + - sku : BL394D + quantity : 4 + description : Basketball + price : 450.00 + - sku : BL4438H + quantity : 1 + description : Super Hoop + price : 2392.00 +tax : 251.42 +total: 4443.52 +comments: > + Late afternoon is best. + Backup contact is Nancy + Billsmer @ 338-4338 + diff --git a/ext/Test/Harness/t/harness.t b/ext/Test/Harness/t/harness.t index 70ff42e452..716ea59f02 100644 --- a/ext/Test/Harness/t/harness.t +++ b/ext/Test/Harness/t/harness.t @@ -19,8 +19,8 @@ use TAP::Harness; my $HARNESS = 'TAP::Harness'; -my $source_tests = $ENV{PERL_CORE} ? 'lib/source_tests' : 't/source_tests'; -my $sample_tests = $ENV{PERL_CORE} ? 'lib/sample-tests' : 't/sample-tests'; +my $source_tests = $ENV{PERL_CORE} ? '../ext/Test/Harness/t/source_tests' : 't/source_tests'; +my $sample_tests = $ENV{PERL_CORE} ? '../ext/Test/Harness/t/sample-tests' : 't/sample-tests'; plan tests => 113; @@ -523,7 +523,7 @@ SKIP: { eval { _runtests( $harness, - $ENV{PERL_CORE} ? 'lib/data/catme.1' : 't/data/catme.1' + $ENV{PERL_CORE} ? '../ext/Test/Harness/t/data/catme.1' : 't/data/catme.1' ); }; @@ -810,7 +810,7 @@ sub _runtests { # coverage tests for the basically untested T::H::_open_spool - my @spool = ( $ENV{PERL_CORE} ? ('spool') : ( 't', 'spool' ) ); + my @spool = ( ( $ENV{PERL_CORE} ? (File::Spec->updir(), 'ext', 'Test', 'Harness' ) : () ), ( 't', 'spool' ) ); $ENV{PERL_TEST_HARNESS_DUMP_TAP} = File::Spec->catfile(@spool); # now given that we're going to be writing stuff to the file system, make sure we have diff --git a/ext/Test/Harness/t/iterators.t b/ext/Test/Harness/t/iterators.t index 11b2899b12..e4df5108cd 100644 --- a/ext/Test/Harness/t/iterators.t +++ b/ext/Test/Harness/t/iterators.t @@ -42,8 +42,8 @@ my @schedule = ( command => [ $^X, File::Spec->catfile( - ( $ENV{PERL_CORE} ? 'lib' : 't' ), - 'sample-tests', 'out_err_mix' + ( $ENV{PERL_CORE} ? ( File::Spec->updir(), 'ext', 'Test', 'Harness' ) : () ), + 't', 'sample-tests', 'out_err_mix' ) ], merge => 1, diff --git a/ext/Test/Harness/t/multiplexer.t b/ext/Test/Harness/t/multiplexer.t index dd988dcee1..eccbb0ee16 100644 --- a/ext/Test/Harness/t/multiplexer.t +++ b/ext/Test/Harness/t/multiplexer.t @@ -56,8 +56,8 @@ my @schedule = ( return [ TAP::Parser->new( { source => File::Spec->catfile( - ( $ENV{PERL_CORE} ? 'lib' : 't' ), 'sample-tests', - 'simple' + ( $ENV{PERL_CORE} ? ( File::Spec->updir(), 'ext', 'Test', 'Harness' ) : () ), + 't', 'sample-tests', 'simple' ), } ), @@ -76,8 +76,8 @@ my @schedule = ( return map { [ TAP::Parser->new( { source => File::Spec->catfile( - ( $ENV{PERL_CORE} ? 'lib' : 't' ), - 'sample-tests', 'simple' + ( $ENV{PERL_CORE} ? ( File::Spec->updir(), 'ext', 'Test', 'Harness' ) : () ), + 't', 'sample-tests', 'simple' ), } ), @@ -116,8 +116,8 @@ my @schedule = ( ( map { [ TAP::Parser->new( { source => File::Spec->catfile( - ( $ENV{PERL_CORE} ? 'lib' : 't' ), - 'sample-tests', 'simple' + ( $ENV{PERL_CORE} ? ( File::Spec->updir(), 'ext', 'Test', 'Harness' ) : () ), + 't', 'sample-tests', 'simple' ), } ), diff --git a/ext/Test/Harness/t/nofork.t b/ext/Test/Harness/t/nofork.t index 6a45e503c8..7f2782059d 100755 --- a/ext/Test/Harness/t/nofork.t +++ b/ext/Test/Harness/t/nofork.t @@ -58,7 +58,7 @@ my $mod = 'TAP::Parser::Iterator::Process'; } ); $harness->runtests( - ( $ENV{PERL_CORE} ? 'lib' : 't' ) . '/sample-tests/simple' ); + ( $ENV{PERL_CORE} ? '../ext/Test/Harness/' : '' ) . 't/sample-tests/simple' ); my @output = tied($$capture)->dump; is pop @output, "Result: PASS\n", 'status OK'; pop @output; # get rid of summary line diff --git a/ext/Test/Harness/t/parse.t b/ext/Test/Harness/t/parse.t index 7118199a51..39f2c380c9 100755 --- a/ext/Test/Harness/t/parse.t +++ b/ext/Test/Harness/t/parse.t @@ -605,8 +605,8 @@ END_TAP my $parser = TAP::Parser->new( { source => File::Spec->catfile( - ( $ENV{PERL_CORE} ? 'lib' : 't' ), - 'sample-tests', 'simple' + ( $ENV{PERL_CORE} ? ( File::Spec->updir(), 'ext', 'Test', 'Harness' ) : () ), + 't', 'sample-tests', 'simple' ), } ); diff --git a/ext/Test/Harness/t/parser-config.t b/ext/Test/Harness/t/parser-config.t index cf0a246a03..0c74427fa6 100644 --- a/ext/Test/Harness/t/parser-config.t +++ b/ext/Test/Harness/t/parser-config.t @@ -14,7 +14,7 @@ use strict; use vars qw(%INIT %CUSTOM); use Test::More tests => 11; -use File::Spec::Functions qw( catfile ); +use File::Spec::Functions qw( catfile updir ); use TAP::Parser; use_ok('MySource'); @@ -23,8 +23,8 @@ use_ok('MyGrammar'); use_ok('MyIteratorFactory'); use_ok('MyResultFactory'); -my $t_dir = $ENV{PERL_CORE} ? 'lib' : 't'; -my $source = catfile( $t_dir, 'source_tests', 'source' ); +my @t_path = $ENV{PERL_CORE} ? ( updir(), 'ext', 'Test', 'Harness' ) : (); +my $source = catfile( @t_path, 't', 'source_tests', 'source' ); my %customize = ( source_class => 'MySource', perl_source_class => 'MyPerlSource', diff --git a/ext/Test/Harness/t/parser-subclass.t b/ext/Test/Harness/t/parser-subclass.t index f522f89aff..2817751714 100644 --- a/ext/Test/Harness/t/parser-subclass.t +++ b/ext/Test/Harness/t/parser-subclass.t @@ -14,16 +14,16 @@ use strict; use vars qw(%INIT %CUSTOM); use Test::More tests => 24; -use File::Spec::Functions qw( catfile ); +use File::Spec::Functions qw( catfile updir ); use_ok('TAP::Parser::SubclassTest'); # TODO: foreach my $source ( ... ) -my $t_dir = $ENV{PERL_CORE} ? 'lib' : 't'; +my @t_path = $ENV{PERL_CORE} ? ( updir(), 'ext', 'Test', 'Harness' ) : (); { # perl source %INIT = %CUSTOM = (); - my $source = catfile( $t_dir, 'subclass_tests', 'perl_source' ); + my $source = catfile( @t_path, 't', 'subclass_tests', 'perl_source' ); my $p = TAP::Parser::SubclassTest->new( { source => $source } ); # The grammar is lazily constructed so we need to ask for it to @@ -78,7 +78,7 @@ SKIP: { # non-perl source unless ( -e $cat ) { skip "no '$cat'", 4; } - my $file = catfile( $t_dir, 'data', 'catme.1' ); + my $file = catfile( @t_path, 't', 'data', 'catme.1' ); my $p = TAP::Parser::SubclassTest->new( { exec => [ $cat => $file ] } ); is( $INIT{MySource}, 1, 'initialized MySource subclass' ); diff --git a/ext/Test/Harness/t/process.t b/ext/Test/Harness/t/process.t index 5adddc9017..abebf69489 100644 --- a/ext/Test/Harness/t/process.t +++ b/ext/Test/Harness/t/process.t @@ -28,8 +28,8 @@ my @expect = ( ); my $source = File::Spec->catfile( - ( $ENV{PERL_CORE} ? 'lib' : 't' ), - 'sample-tests', 'delayed' + ( $ENV{PERL_CORE} ? ( File::Spec->updir(), 'ext', 'Test', 'Harness' ) : () ), + 't', 'sample-tests', 'delayed' ); for my $chunk_size ( 1, 4, 65536 ) { diff --git a/ext/Test/Harness/t/proverc.t b/ext/Test/Harness/t/proverc.t index 2577250532..df4cbbb1d4 100644 --- a/ext/Test/Harness/t/proverc.t +++ b/ext/Test/Harness/t/proverc.t @@ -20,7 +20,7 @@ my $prove = App::Prove->new; $prove->add_rc_file( File::Spec->catfile( - ( $ENV{PERL_CORE} ? 'lib' : 't' ), 'data', 'proverc' + ( $ENV{PERL_CORE} ? ( File::Spec->updir(), 'ext', 'Test', 'Harness' ) : () ), 't', 'data', 'proverc' ) ); diff --git a/ext/Test/Harness/t/proverun.t b/ext/Test/Harness/t/proverun.t index b40d56362d..7db019732c 100644 --- a/ext/Test/Harness/t/proverun.t +++ b/ext/Test/Harness/t/proverun.t @@ -20,8 +20,8 @@ my @SCHEDULE; BEGIN { my $sample_test = File::Spec->catfile( - split /\//, - ( $ENV{PERL_CORE} ? 'lib' : 't' ) . '/sample-tests/simple' + ( $ENV{PERL_CORE} ? ( File::Spec->updir(), 'ext', 'Test', 'Harness' ) : () ), + 't', 'sample-tests', 'simple' ); @SCHEDULE = ( diff --git a/ext/Test/Harness/t/regression.t b/ext/Test/Harness/t/regression.t index c029a050a9..8f93e4e1dc 100644 --- a/ext/Test/Harness/t/regression.t +++ b/ext/Test/Harness/t/regression.t @@ -30,8 +30,8 @@ my $IsWin32 = $^O eq 'MSWin32'; my $SAMPLE_TESTS = File::Spec->catdir( File::Spec->curdir, - ( $ENV{PERL_CORE} ? 'lib' : 't' ), - 'sample-tests' + ( $ENV{PERL_CORE} ? ( File::Spec->updir(), 'ext', 'Test', 'Harness' ) : () ), + 't', 'sample-tests' ); my %deprecated = map { $_ => 1 } qw( diff --git a/ext/Test/Harness/t/sample-tests/bailout b/ext/Test/Harness/t/sample-tests/bailout new file mode 100644 index 0000000000..b25f417b52 --- /dev/null +++ b/ext/Test/Harness/t/sample-tests/bailout @@ -0,0 +1,11 @@ +# Sleep makes Mac OS open3 race problem more repeatable +sleep 1; +print <<DUMMY_TEST; +1..5 +ok 1 +ok 2 +ok 3 +Bail out! GERONIMMMOOOOOO!!! +ok 4 +ok 5 +DUMMY_TEST diff --git a/ext/Test/Harness/t/sample-tests/bignum b/ext/Test/Harness/t/sample-tests/bignum new file mode 100644 index 0000000000..b5824a12a1 --- /dev/null +++ b/ext/Test/Harness/t/sample-tests/bignum @@ -0,0 +1,7 @@ +print <<DUMMY; +1..2 +ok 1 +ok 2 +ok 136211425 +ok 136211426 +DUMMY diff --git a/ext/Test/Harness/t/sample-tests/bignum_many b/ext/Test/Harness/t/sample-tests/bignum_many new file mode 100644 index 0000000000..1e30b2f1dd --- /dev/null +++ b/ext/Test/Harness/t/sample-tests/bignum_many @@ -0,0 +1,14 @@ +print <<DUMMY; +1..2 +ok 1 +ok 2 +ok 99997 +ok 99998 +ok 99999 +ok 100000 +ok 100001 +ok 100002 +ok 100003 +ok 100004 +ok 100005 +DUMMY diff --git a/ext/Test/Harness/t/sample-tests/combined b/ext/Test/Harness/t/sample-tests/combined new file mode 100644 index 0000000000..7e157092b3 --- /dev/null +++ b/ext/Test/Harness/t/sample-tests/combined @@ -0,0 +1,13 @@ +print <<DUMMY_TEST; +1..10 +ok 1 +ok 2 basset hounds got long ears +not ok 3 all hell broke loose +not ok 4 # TODO if I heard a voice from heaven ... +ok say "live without loving", +ok 6 I'd beg off. +ok 7 # Skip contract negotiations +ok 8 Girls are such exquisite hell +ok 9 Elegy 9B # TOdO +not ok 10 +DUMMY_TEST diff --git a/ext/Test/Harness/t/sample-tests/combined_compat b/ext/Test/Harness/t/sample-tests/combined_compat new file mode 100644 index 0000000000..8dfaa28e92 --- /dev/null +++ b/ext/Test/Harness/t/sample-tests/combined_compat @@ -0,0 +1,13 @@ +print <<DUMMY_TEST; +1..10 todo 4 10 +ok 1 +ok 2 basset hounds got long ears +not ok 3 all hell broke lose +ok 4 +ok +ok 6 +ok 7 # Skip contract negociations +ok 8 +not ok 9 +not ok 10 +DUMMY_TEST diff --git a/ext/Test/Harness/t/sample-tests/delayed b/ext/Test/Harness/t/sample-tests/delayed new file mode 100644 index 0000000000..94f667fa2f --- /dev/null +++ b/ext/Test/Harness/t/sample-tests/delayed @@ -0,0 +1,33 @@ +# Used to test Process.pm + +BEGIN { + if ( $ENV{PERL_CORE} ) { + unshift @INC, '../lib'; + } +} + +use Time::HiRes qw(sleep); + +my $delay = 0.01; + +$| = 1; + +my @parts = ( + "1.", + ".5\n", + "ok 1 00000\n", + "ok 2\nnot", + " ok 3", + "\nok 4\nok ", + "5 00000", + "" +); + +my $delay_at = shift || 0; + +while (@parts) { + sleep $delay if ( $delay_at & 1 ); + $delay_at >>= 1; + print shift @parts; +} +sleep $delay if ( $delay_at & 1 ); diff --git a/ext/Test/Harness/t/sample-tests/descriptive b/ext/Test/Harness/t/sample-tests/descriptive new file mode 100644 index 0000000000..e165ac1bf5 --- /dev/null +++ b/ext/Test/Harness/t/sample-tests/descriptive @@ -0,0 +1,8 @@ +print <<DUMMY_TEST; +1..5 +ok 1 Interlock activated +ok 2 Megathrusters are go +ok 3 Head formed +ok 4 Blazing sword formed +ok 5 Robeast destroyed +DUMMY_TEST diff --git a/ext/Test/Harness/t/sample-tests/descriptive_trailing b/ext/Test/Harness/t/sample-tests/descriptive_trailing new file mode 100644 index 0000000000..f92d7ca694 --- /dev/null +++ b/ext/Test/Harness/t/sample-tests/descriptive_trailing @@ -0,0 +1,8 @@ +print <<DUMMY_TEST; +ok 1 Interlock activated +ok 2 Megathrusters are go +ok 3 Head formed +ok 4 Blazing sword formed +ok 5 Robeast destroyed +1..5 +DUMMY_TEST diff --git a/ext/Test/Harness/t/sample-tests/die b/ext/Test/Harness/t/sample-tests/die new file mode 100644 index 0000000000..ca8b0a9b0b --- /dev/null +++ b/ext/Test/Harness/t/sample-tests/die @@ -0,0 +1,2 @@ +eval "use vmsish 'hushed'" if ($^O eq 'VMS'); +exit 1; # exit because die() can be noisy diff --git a/ext/Test/Harness/t/sample-tests/die_head_end b/ext/Test/Harness/t/sample-tests/die_head_end new file mode 100644 index 0000000000..494e4d3c82 --- /dev/null +++ b/ext/Test/Harness/t/sample-tests/die_head_end @@ -0,0 +1,9 @@ +print <<DUMMY_TEST; +ok 1 +ok 2 +ok 3 +ok 4 +DUMMY_TEST + +eval "use vmsish 'hushed'" if ($^O eq 'VMS'); +exit 1; diff --git a/ext/Test/Harness/t/sample-tests/die_last_minute b/ext/Test/Harness/t/sample-tests/die_last_minute new file mode 100644 index 0000000000..ea533d628e --- /dev/null +++ b/ext/Test/Harness/t/sample-tests/die_last_minute @@ -0,0 +1,10 @@ +print <<DUMMY_TEST; +ok 1 +ok 2 +ok 3 +ok 4 +1..4 +DUMMY_TEST + +eval "use vmsish 'hushed'" if ($^O eq 'VMS'); +exit 1; diff --git a/ext/Test/Harness/t/sample-tests/die_unfinished b/ext/Test/Harness/t/sample-tests/die_unfinished new file mode 100644 index 0000000000..3efd08ff09 --- /dev/null +++ b/ext/Test/Harness/t/sample-tests/die_unfinished @@ -0,0 +1,9 @@ +print <<DUMMY_TEST; +1..4 +ok 1 +ok 2 +ok 3 +DUMMY_TEST + +eval "use vmsish 'hushed'" if ($^O eq 'VMS'); +exit 1; diff --git a/ext/Test/Harness/t/sample-tests/duplicates b/ext/Test/Harness/t/sample-tests/duplicates new file mode 100644 index 0000000000..63f6a706b6 --- /dev/null +++ b/ext/Test/Harness/t/sample-tests/duplicates @@ -0,0 +1,14 @@ +print <<DUMMY_TEST +1..10 +ok 1 +ok 2 +ok 3 +ok 4 +ok 4 +ok 5 +ok 6 +ok 7 +ok 8 +ok 9 +ok 10 +DUMMY_TEST diff --git a/ext/Test/Harness/t/sample-tests/echo b/ext/Test/Harness/t/sample-tests/echo new file mode 100644 index 0000000000..6696e71f17 --- /dev/null +++ b/ext/Test/Harness/t/sample-tests/echo @@ -0,0 +1,2 @@ +print '1..', scalar(@ARGV), "\n"; +print "ok $_ ", $ARGV[ $_ - 1 ], "\n" for 1 .. @ARGV; diff --git a/ext/Test/Harness/t/sample-tests/empty b/ext/Test/Harness/t/sample-tests/empty new file mode 100644 index 0000000000..66d42ad402 --- /dev/null +++ b/ext/Test/Harness/t/sample-tests/empty @@ -0,0 +1,2 @@ +__END__ +Used to exercise the "empty test" case. diff --git a/ext/Test/Harness/t/sample-tests/escape_eol b/ext/Test/Harness/t/sample-tests/escape_eol new file mode 100644 index 0000000000..1b8ba27f1e --- /dev/null +++ b/ext/Test/Harness/t/sample-tests/escape_eol @@ -0,0 +1,5 @@ +print <<DUMMY_TEST; +1..2 +ok 1 Should parse as literal backslash --> \\ +ok 2 Not a continuation line +DUMMY_TEST diff --git a/ext/Test/Harness/t/sample-tests/escape_hash b/ext/Test/Harness/t/sample-tests/escape_hash new file mode 100644 index 0000000000..c404372c0c --- /dev/null +++ b/ext/Test/Harness/t/sample-tests/escape_hash @@ -0,0 +1,6 @@ +print <<DUMMY_TEST; +1..3 +ok 1 Not a \\# TODO +ok 2 Not a \\# SKIP +ok 3 Escaped \\\\\\# +DUMMY_TEST diff --git a/ext/Test/Harness/t/sample-tests/head_end b/ext/Test/Harness/t/sample-tests/head_end new file mode 100644 index 0000000000..14a32f2fe6 --- /dev/null +++ b/ext/Test/Harness/t/sample-tests/head_end @@ -0,0 +1,11 @@ +print <<DUMMY_TEST; +# comments +ok 1 +ok 2 +ok 3 +ok 4 +# comment +1..4 +# more ignored stuff +# and yet more +DUMMY_TEST diff --git a/ext/Test/Harness/t/sample-tests/head_fail b/ext/Test/Harness/t/sample-tests/head_fail new file mode 100644 index 0000000000..9d1667ab19 --- /dev/null +++ b/ext/Test/Harness/t/sample-tests/head_fail @@ -0,0 +1,11 @@ +print <<DUMMY_TEST; +# comments +ok 1 +not ok 2 +ok 3 +ok 4 +# comment +1..4 +# more ignored stuff +# and yet more +DUMMY_TEST diff --git a/ext/Test/Harness/t/sample-tests/inc_taint b/ext/Test/Harness/t/sample-tests/inc_taint new file mode 100644 index 0000000000..223b53570f --- /dev/null +++ b/ext/Test/Harness/t/sample-tests/inc_taint @@ -0,0 +1,15 @@ +#!/usr/bin/perl -Tw + +BEGIN { + if ( $ENV{PERL_CORE} ) { + unshift @INC, '../lib'; + } + else { + unshift @INC, 't/lib'; + } +} + +use Test::More tests => 1; + +ok( grep( /examples/, @INC ) ); + diff --git a/ext/Test/Harness/t/sample-tests/junk_before_plan b/ext/Test/Harness/t/sample-tests/junk_before_plan new file mode 100644 index 0000000000..b2ad018301 --- /dev/null +++ b/ext/Test/Harness/t/sample-tests/junk_before_plan @@ -0,0 +1,6 @@ +print <<DUMMY_TEST; +this is junk +# this is a comment +1..1 +ok 1 +DUMMY_TEST diff --git a/ext/Test/Harness/t/sample-tests/lone_not_bug b/ext/Test/Harness/t/sample-tests/lone_not_bug new file mode 100644 index 0000000000..10eaa2a3b0 --- /dev/null +++ b/ext/Test/Harness/t/sample-tests/lone_not_bug @@ -0,0 +1,9 @@ +# There was a bug where the first test would be considered a +# 'lone not' failure. +print <<DUMMY; +ok 1 +ok 2 +ok 3 +ok 4 +1..4 +DUMMY diff --git a/ext/Test/Harness/t/sample-tests/no_nums b/ext/Test/Harness/t/sample-tests/no_nums new file mode 100644 index 0000000000..c32d3f22ba --- /dev/null +++ b/ext/Test/Harness/t/sample-tests/no_nums @@ -0,0 +1,8 @@ +print <<DUMMY_TEST; +1..5 +ok +ok +not ok +ok +ok +DUMMY_TEST diff --git a/ext/Test/Harness/t/sample-tests/no_output b/ext/Test/Harness/t/sample-tests/no_output new file mode 100644 index 0000000000..505acda7e6 --- /dev/null +++ b/ext/Test/Harness/t/sample-tests/no_output @@ -0,0 +1,3 @@ +#!/usr/bin/perl -w + +exit; diff --git a/ext/Test/Harness/t/sample-tests/out_err_mix b/ext/Test/Harness/t/sample-tests/out_err_mix new file mode 100644 index 0000000000..c802eb4a11 --- /dev/null +++ b/ext/Test/Harness/t/sample-tests/out_err_mix @@ -0,0 +1,13 @@ +sub _autoflush { + my $flushed = shift; + my $old_fh = select $flushed; + $| = 1; + select $old_fh; +} + +_autoflush( \*STDOUT ); +_autoflush( \*STDERR ); + +print STDOUT "one\n"; +print STDERR "two\n\n"; +print STDOUT "three\n"; diff --git a/ext/Test/Harness/t/sample-tests/out_of_order b/ext/Test/Harness/t/sample-tests/out_of_order new file mode 100644 index 0000000000..77641aa362 --- /dev/null +++ b/ext/Test/Harness/t/sample-tests/out_of_order @@ -0,0 +1,22 @@ +# From a bungled core thread test. +# +# The important thing here is that the last test is the right test. +# Test::Harness would misparse this as being a valid test. +print <<DUMMY; +ok 2 - Test that argument passing works +ok 3 - Test that passing arguments as references work +ok 4 - Test a normal sub +ok 6 - Detach test +ok 8 - Nested thread test +ok 9 - Nested thread test +ok 10 - Wanted 7, got 7 +ok 11 - Wanted 7, got 7 +ok 12 - Wanted 8, got 8 +ok 13 - Wanted 8, got 8 +1..15 +ok 1 +ok 5 - Check that Config::threads is true +ok 7 - Detach test +ok 14 - Check so that tid for threads work for main thread +ok 15 - Check so that tid for threads work for main thread +DUMMY diff --git a/ext/Test/Harness/t/sample-tests/schwern b/ext/Test/Harness/t/sample-tests/schwern new file mode 100644 index 0000000000..d45726bc7a --- /dev/null +++ b/ext/Test/Harness/t/sample-tests/schwern @@ -0,0 +1,3 @@ +use Test::More; +plan tests => 1; +ok 23, 42; diff --git a/ext/Test/Harness/t/sample-tests/schwern-todo-quiet b/ext/Test/Harness/t/sample-tests/schwern-todo-quiet new file mode 100644 index 0000000000..4d482d43fa --- /dev/null +++ b/ext/Test/Harness/t/sample-tests/schwern-todo-quiet @@ -0,0 +1,13 @@ +print <<DUMMY_TEST; +1..3 +ok 1 +not ok 2 +# Failed test at ../../andy/schwern.pl line 17. +# got: '23' +# expected: '42' +not ok 3 # TODO Roman numerials still not a built in type +# Failed (TODO) test at ../../andy/schwern.pl line 20. +# got: 'XXIII' +# expected: '23' +# Looks like you failed 1 test of 3. +DUMMY_TEST diff --git a/ext/Test/Harness/t/sample-tests/segfault b/ext/Test/Harness/t/sample-tests/segfault new file mode 100644 index 0000000000..c5670a42b5 --- /dev/null +++ b/ext/Test/Harness/t/sample-tests/segfault @@ -0,0 +1,5 @@ +#!/usr/bin/perl + +print "1..1\n"; +print "ok 1\n"; +kill 11, $$; diff --git a/ext/Test/Harness/t/sample-tests/sequence_misparse b/ext/Test/Harness/t/sample-tests/sequence_misparse new file mode 100644 index 0000000000..c66d127bb0 --- /dev/null +++ b/ext/Test/Harness/t/sample-tests/sequence_misparse @@ -0,0 +1,14 @@ +# +# This was causing parse failures due to an error in the TAP specification. +# Hash marks *are* allowed in the description. +# +print <<DUMMY; +1..5 +ok 1 +ok 2 +ok 3 # skipped on foobar system +# 1234567890123456789012345678901234567890 +ok 4 +# 1234567890123456789012345678901234567890 +ok 5 +DUMMY diff --git a/ext/Test/Harness/t/sample-tests/shbang_misparse b/ext/Test/Harness/t/sample-tests/shbang_misparse new file mode 100644 index 0000000000..ab93b468ae --- /dev/null +++ b/ext/Test/Harness/t/sample-tests/shbang_misparse @@ -0,0 +1,12 @@ +#!/usr/bin/perl-latest + +# The above #! line was misparsed as having a -t. +# Pre-5.8 this will simply cause perl to choke, since there was no -t. +# Post-5.8 taint warnings will mistakenly be on. + +print "1..2\n"; +print "ok 1\n"; +my $warning = ''; +$SIG{__WARN__} = sub { $warning .= $_[0] }; +eval( "#" . substr( $0, 0, 0 ) ); +print $warning ? "not ok 2\n" : "ok 2\n"; diff --git a/ext/Test/Harness/t/sample-tests/simple b/ext/Test/Harness/t/sample-tests/simple new file mode 100644 index 0000000000..d6b85846b2 --- /dev/null +++ b/ext/Test/Harness/t/sample-tests/simple @@ -0,0 +1,8 @@ +print <<DUMMY_TEST; +1..5 +ok 1 +ok 2 +ok 3 +ok 4 +ok 5 +DUMMY_TEST diff --git a/ext/Test/Harness/t/sample-tests/simple_fail b/ext/Test/Harness/t/sample-tests/simple_fail new file mode 100644 index 0000000000..aa65f5f66d --- /dev/null +++ b/ext/Test/Harness/t/sample-tests/simple_fail @@ -0,0 +1,8 @@ +print <<DUMMY_TEST; +1..5 +ok 1 +not ok 2 +ok 3 +ok 4 +not ok 5 +DUMMY_TEST diff --git a/ext/Test/Harness/t/sample-tests/simple_yaml b/ext/Test/Harness/t/sample-tests/simple_yaml new file mode 100644 index 0000000000..9f52c5c8a8 --- /dev/null +++ b/ext/Test/Harness/t/sample-tests/simple_yaml @@ -0,0 +1,27 @@ +print <<DUMMY_TEST; +TAP version 13 +1..5 +ok 1 +ok 2 + --- + - + fnurk: skib + ponk: gleeb + - + bar: krup + foo: plink + ... +ok 3 +ok 4 + --- + expected: + - 1 + - 2 + - 4 + got: + - 1 + - pong + - 4 + ... +ok 5 +DUMMY_TEST diff --git a/ext/Test/Harness/t/sample-tests/skip b/ext/Test/Harness/t/sample-tests/skip new file mode 100644 index 0000000000..6a9cd662bc --- /dev/null +++ b/ext/Test/Harness/t/sample-tests/skip @@ -0,0 +1,8 @@ +print <<DUMMY_TEST; +1..5 +ok 1 +ok 2 # skip rain delay +ok 3 +ok 4 +ok 5 +DUMMY_TEST diff --git a/ext/Test/Harness/t/sample-tests/skip_nomsg b/ext/Test/Harness/t/sample-tests/skip_nomsg new file mode 100644 index 0000000000..51d1ed6b43 --- /dev/null +++ b/ext/Test/Harness/t/sample-tests/skip_nomsg @@ -0,0 +1,4 @@ +print <<DUMMY; +1..1 +ok 1 # Skip +DUMMY diff --git a/ext/Test/Harness/t/sample-tests/skipall b/ext/Test/Harness/t/sample-tests/skipall new file mode 100644 index 0000000000..ceb2c19b3a --- /dev/null +++ b/ext/Test/Harness/t/sample-tests/skipall @@ -0,0 +1,3 @@ +print <<DUMMY_TEST; +1..0 # skipping: rope +DUMMY_TEST diff --git a/ext/Test/Harness/t/sample-tests/skipall_nomsg b/ext/Test/Harness/t/sample-tests/skipall_nomsg new file mode 100644 index 0000000000..9b0dc11a69 --- /dev/null +++ b/ext/Test/Harness/t/sample-tests/skipall_nomsg @@ -0,0 +1,2 @@ +print "1..0\n"; +exit 0; diff --git a/ext/Test/Harness/t/sample-tests/skipall_v13 b/ext/Test/Harness/t/sample-tests/skipall_v13 new file mode 100644 index 0000000000..d16bd4f652 --- /dev/null +++ b/ext/Test/Harness/t/sample-tests/skipall_v13 @@ -0,0 +1,4 @@ +print <<DUMMY_TEST; +TAP version 13 +1..0 # skipping: rope +DUMMY_TEST diff --git a/ext/Test/Harness/t/sample-tests/space_after_plan b/ext/Test/Harness/t/sample-tests/space_after_plan new file mode 100644 index 0000000000..d454c20d4d --- /dev/null +++ b/ext/Test/Harness/t/sample-tests/space_after_plan @@ -0,0 +1,3 @@ +# gforth TAP generates a space after the plan. Should probably be allowed. +print "1..5 \n"; +print "ok $_ \n" for 1..5; diff --git a/ext/Test/Harness/t/sample-tests/stdout_stderr b/ext/Test/Harness/t/sample-tests/stdout_stderr new file mode 100644 index 0000000000..2f8ca38b23 --- /dev/null +++ b/ext/Test/Harness/t/sample-tests/stdout_stderr @@ -0,0 +1,14 @@ +BEGIN { + if ( $ENV{PERL_CORE} ) { + unshift @INC, '../lib'; + } +} +use Test::More 'no_plan'; +diag 'comments'; +ok 1; +ok 1; +ok 1; +diag 'comment'; +ok 1; +diag 'more ignored stuff'; +diag 'and yet more'; diff --git a/ext/Test/Harness/t/sample-tests/strict b/ext/Test/Harness/t/sample-tests/strict new file mode 100644 index 0000000000..b89138de40 --- /dev/null +++ b/ext/Test/Harness/t/sample-tests/strict @@ -0,0 +1,9 @@ +print <<DUMMY_TEST; +TAP version 13 +1..1 +pragma +strict +Nonsense! +pragma -strict +Doesn't matter. +ok 1 All OK +DUMMY_TEST diff --git a/ext/Test/Harness/t/sample-tests/switches b/ext/Test/Harness/t/sample-tests/switches new file mode 100644 index 0000000000..8ce9c9a589 --- /dev/null +++ b/ext/Test/Harness/t/sample-tests/switches @@ -0,0 +1,2 @@ +print "1..1\n"; +print $INC{'strict.pm'} ? "ok 1\n" : "not ok 1\n"; diff --git a/ext/Test/Harness/t/sample-tests/taint b/ext/Test/Harness/t/sample-tests/taint new file mode 100644 index 0000000000..b67d719fc7 --- /dev/null +++ b/ext/Test/Harness/t/sample-tests/taint @@ -0,0 +1,7 @@ +#!/usr/bin/perl -Tw + +use lib qw(t/lib); +use Test::More tests => 1; + +eval { kill 0, $^X }; +like( $@, '/^Insecure dependency/', '-T honored' ); diff --git a/ext/Test/Harness/t/sample-tests/taint_warn b/ext/Test/Harness/t/sample-tests/taint_warn new file mode 100644 index 0000000000..768f527326 --- /dev/null +++ b/ext/Test/Harness/t/sample-tests/taint_warn @@ -0,0 +1,11 @@ +#!/usr/bin/perl -tw + +use lib qw(t/lib); +use Test::More tests => 1; + +my $warnings = ''; +{ + local $SIG{__WARN__} = sub { $warnings .= join '', @_ }; + kill 0, $^X; +} +like( $warnings, '/^Insecure dependency/', '-t honored' ); diff --git a/ext/Test/Harness/t/sample-tests/todo b/ext/Test/Harness/t/sample-tests/todo new file mode 100644 index 0000000000..77f00b4dc9 --- /dev/null +++ b/ext/Test/Harness/t/sample-tests/todo @@ -0,0 +1,8 @@ +print <<DUMMY_TEST; +1..5 todo 3 2; +ok 1 +ok 2 +not ok 3 +ok 4 +ok 5 +DUMMY_TEST diff --git a/ext/Test/Harness/t/sample-tests/todo_inline b/ext/Test/Harness/t/sample-tests/todo_inline new file mode 100644 index 0000000000..5b96d68caf --- /dev/null +++ b/ext/Test/Harness/t/sample-tests/todo_inline @@ -0,0 +1,6 @@ +print <<DUMMY_TEST; +1..3 +not ok 1 - Foo # TODO Just testing the todo interface. +ok 2 - Unexpected success # TODO Just testing the todo interface. +ok 3 - This is not todo +DUMMY_TEST diff --git a/ext/Test/Harness/t/sample-tests/todo_misparse b/ext/Test/Harness/t/sample-tests/todo_misparse new file mode 100644 index 0000000000..138f3fbaaa --- /dev/null +++ b/ext/Test/Harness/t/sample-tests/todo_misparse @@ -0,0 +1,5 @@ +print <<'END'; +1..1 +not ok 1 Hamlette # TODOORNOTTODO +END + diff --git a/ext/Test/Harness/t/sample-tests/too_many b/ext/Test/Harness/t/sample-tests/too_many new file mode 100644 index 0000000000..46acaded4d --- /dev/null +++ b/ext/Test/Harness/t/sample-tests/too_many @@ -0,0 +1,14 @@ +print <<DUMMY; +1..3 +ok 1 +ok 2 +ok 3 +ok 4 +ok 5 +ok 6 +ok 7 +DUMMY + +exit 4; # simulate Test::More's exit status + + diff --git a/ext/Test/Harness/t/sample-tests/version_good b/ext/Test/Harness/t/sample-tests/version_good new file mode 100644 index 0000000000..9e4ab908a2 --- /dev/null +++ b/ext/Test/Harness/t/sample-tests/version_good @@ -0,0 +1,9 @@ +print <<DUMMY_TEST; +TAP version 13 +1..5 +ok 1 +ok 2 +ok 3 +ok 4 +ok 5 +DUMMY_TEST diff --git a/ext/Test/Harness/t/sample-tests/version_late b/ext/Test/Harness/t/sample-tests/version_late new file mode 100644 index 0000000000..4537a322e3 --- /dev/null +++ b/ext/Test/Harness/t/sample-tests/version_late @@ -0,0 +1,9 @@ +print <<DUMMY_TEST; +1..5 +TAP version 13 +ok 1 +ok 2 +ok 3 +ok 4 +ok 5 +DUMMY_TEST diff --git a/ext/Test/Harness/t/sample-tests/version_old b/ext/Test/Harness/t/sample-tests/version_old new file mode 100644 index 0000000000..3c0c44ffb1 --- /dev/null +++ b/ext/Test/Harness/t/sample-tests/version_old @@ -0,0 +1,9 @@ +print <<DUMMY_TEST; +TAP version 12 +1..5 +ok 1 +ok 2 +ok 3 +ok 4 +ok 5 +DUMMY_TEST diff --git a/ext/Test/Harness/t/sample-tests/vms_nit b/ext/Test/Harness/t/sample-tests/vms_nit new file mode 100644 index 0000000000..1df7804309 --- /dev/null +++ b/ext/Test/Harness/t/sample-tests/vms_nit @@ -0,0 +1,6 @@ +print <<DUMMY; +1..2 +not +ok 1 +ok 2 +DUMMY diff --git a/ext/Test/Harness/t/sample-tests/with_comments b/ext/Test/Harness/t/sample-tests/with_comments new file mode 100644 index 0000000000..7aa913985b --- /dev/null +++ b/ext/Test/Harness/t/sample-tests/with_comments @@ -0,0 +1,14 @@ +print <<DUMMY_TEST; +# and stuff +1..5 todo 1 2 4 5; +# yeah, that +not ok 1 +# Failed test 1 in t/todo.t at line 9 *TODO* +ok 2 # (t/todo.t at line 10 TODO?!) +ok 3 +not ok 4 +# Test 4 got: '0' (t/todo.t at line 12 *TODO*) +# Expected: '1' (need more tuits) +ok 5 # (t/todo.t at line 13 TODO?!) +# woo +DUMMY_TEST diff --git a/ext/Test/Harness/t/source.t b/ext/Test/Harness/t/source.t index 8f7e60f2e3..a6441a5242 100644 --- a/ext/Test/Harness/t/source.t +++ b/ext/Test/Harness/t/source.t @@ -22,8 +22,8 @@ use TAP::Parser::Source::Perl; my $parser = EmptyParser->new; my $test = File::Spec->catfile( - ( $ENV{PERL_CORE} ? 'lib' : 't' ), 'source_tests', - 'source' + ( $ENV{PERL_CORE} ? ( File::Spec->updir(), 'ext', 'Test', 'Harness' ) : () ), + 't', 'source_tests', 'source' ); my $perl = $^X; diff --git a/ext/Test/Harness/t/source_tests/harness b/ext/Test/Harness/t/source_tests/harness new file mode 100644 index 0000000000..7fef7d5459 --- /dev/null +++ b/ext/Test/Harness/t/source_tests/harness @@ -0,0 +1,6 @@ +#!/usr/bin/perl + +print <<'END_TESTS'; +1..1 +ok 1 - this is a test +END_TESTS diff --git a/ext/Test/Harness/t/source_tests/harness_badtap b/ext/Test/Harness/t/source_tests/harness_badtap new file mode 100644 index 0000000000..bf8233a5ca --- /dev/null +++ b/ext/Test/Harness/t/source_tests/harness_badtap @@ -0,0 +1,8 @@ +#!/usr/bin/perl + +print <<'END_TESTS'; +1..2 +ok 1 - this is a test +not ok 2 - this is another test +1..2 +END_TESTS diff --git a/ext/Test/Harness/t/source_tests/harness_complain b/ext/Test/Harness/t/source_tests/harness_complain new file mode 100644 index 0000000000..1ef4cf0534 --- /dev/null +++ b/ext/Test/Harness/t/source_tests/harness_complain @@ -0,0 +1,7 @@ +#!/usr/bin/perl + +print "1..1\n"; + +die "I should have no args -- @ARGV" if (@ARGV); +print "ok 1 - this is a test\n"; + diff --git a/ext/Test/Harness/t/source_tests/harness_directives b/ext/Test/Harness/t/source_tests/harness_directives new file mode 100644 index 0000000000..91ada58bf3 --- /dev/null +++ b/ext/Test/Harness/t/source_tests/harness_directives @@ -0,0 +1,8 @@ +#!/usr/bin/perl + +print <<'END_TESTS'; +1..3 +ok 1 - this is a test +not ok 2 - we have a something # TODO some output +ok 3 houston, we don't have liftoff # SKIP no funding +END_TESTS diff --git a/ext/Test/Harness/t/source_tests/harness_failure b/ext/Test/Harness/t/source_tests/harness_failure new file mode 100644 index 0000000000..d8b0add0fc --- /dev/null +++ b/ext/Test/Harness/t/source_tests/harness_failure @@ -0,0 +1,7 @@ +#!/usr/bin/perl + +print <<'END_TESTS'; +1..2 +ok 1 - this is a test +not ok 2 - this is another test +END_TESTS diff --git a/ext/Test/Harness/t/source_tests/source b/ext/Test/Harness/t/source_tests/source new file mode 100644 index 0000000000..6d469f4581 --- /dev/null +++ b/ext/Test/Harness/t/source_tests/source @@ -0,0 +1,15 @@ +#!/usr/bin/perl -wT + +BEGIN { + if ( $ENV{PERL_CORE} ) { + chdir 't'; + @INC = ( '../lib', 'lib' ); + } + else { + unshift @INC, 't/lib'; + } +} + +use Test::More tests => 1; + +ok 1; diff --git a/ext/Test/Harness/t/subclass_tests/non_perl_source b/ext/Test/Harness/t/subclass_tests/non_perl_source new file mode 100644 index 0000000000..12f0f74012 --- /dev/null +++ b/ext/Test/Harness/t/subclass_tests/non_perl_source @@ -0,0 +1,3 @@ +#!/bin/sh +echo "1..1" +echo "ok 1 - this is a test" diff --git a/ext/Test/Harness/t/subclass_tests/perl_source b/ext/Test/Harness/t/subclass_tests/perl_source new file mode 100644 index 0000000000..7fef7d5459 --- /dev/null +++ b/ext/Test/Harness/t/subclass_tests/perl_source @@ -0,0 +1,6 @@ +#!/usr/bin/perl + +print <<'END_TESTS'; +1..1 +ok 1 - this is a test +END_TESTS diff --git a/ext/Test/Harness/t/testargs.t b/ext/Test/Harness/t/testargs.t index 9160c5909b..0c69f8adfe 100644 --- a/ext/Test/Harness/t/testargs.t +++ b/ext/Test/Harness/t/testargs.t @@ -14,8 +14,8 @@ use TAP::Harness; use App::Prove; my $test = File::Spec->catfile( - ( $ENV{PERL_CORE} ? 'lib' : 't' ), - 'sample-tests', 'echo' + ( $ENV{PERL_CORE} ? ( File::Spec->updir(), 'ext', 'Test', 'Harness' ) : () ), + 't', 'sample-tests', 'echo' ); diag( "\n\n", bigness( join ' ', @ARGV ), "\n\n" ) if @ARGV; |