#!/usr/bin/perl -w
BEGIN {
- if( $ENV{PERL_CORE} ) {
+ if ( $ENV{PERL_CORE} ) {
chdir 't';
- @INC = ('../lib', 'lib');
+ @INC = ( '../lib', 'lib' );
}
else {
- use lib 't/lib';
- }
-}
-
-BEGIN {
- if ($ENV{PERL_CORE}) {
- # FIXME
- print "1..0 # Skip pending resolution of a clean way to record the change in location of the sample tests\n";
- exit 0;
+ unshift @INC, 't/lib';
}
}
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';
+
plan tests => 106;
# note that this test will always pass when run through 'prove'
# normal tests in verbose mode
- ok my $aggregate = _runtests( $harness, 't/source_tests/harness' ),
+ ok my $aggregate = _runtests( $harness, "$source_tests/harness" ),
'... runtests returns the aggregate';
isa_ok $aggregate, 'TAP::Parser::Aggregator';
chomp(@output);
my @expected = (
- 't/source_tests/harness....',
+ "$source_tests/harness....",
'1..1',
'[[reset]]',
'ok 1 - this is a test',
@output = ();
ok $aggregate
- = _runtests( $harness, [ 't/source_tests/harness', 'My Nice Test' ] ),
+ = _runtests( $harness, [ "$source_tests/harness", 'My Nice Test' ] ),
'... runtests returns the aggregate';
isa_ok $aggregate, 'TAP::Parser::Aggregator';
# run same test twice
@output = ();
- ok $aggregate
- = _runtests( $harness, [ 't/source_tests/harness', 'My Nice Test' ],
- [ 't/source_tests/harness', 'My Nice Test Again' ] ),
+ ok $aggregate = _runtests(
+ $harness, [ "$source_tests/harness", 'My Nice Test' ],
+ [ "$source_tests/harness", 'My Nice Test Again' ]
+ ),
'... runtests returns the aggregate';
isa_ok $aggregate, 'TAP::Parser::Aggregator';
# normal tests in quiet mode
@output = ();
- _runtests( $harness_whisper, 't/source_tests/harness' );
+ _runtests( $harness_whisper, "$source_tests/harness" );
chomp(@output);
@expected = (
- 't/source_tests/harness....',
+ "$source_tests/harness....",
'ok',
'All tests successful.',
);
# normal tests in really_quiet mode
@output = ();
- _runtests( $harness_mute, 't/source_tests/harness' );
+ _runtests( $harness_mute, "$source_tests/harness" );
chomp(@output);
@expected = (
# normal tests with failures
@output = ();
- _runtests( $harness, 't/source_tests/harness_failure' );
+ _runtests( $harness, "$source_tests/harness_failure" );
$status = pop @output;
$summary = pop @output;
@output = @output[ 0 .. 9 ];
@expected = (
- 't/source_tests/harness_failure....',
+ "$source_tests/harness_failure....",
'1..2',
'[[reset]]',
'ok 1 - this is a test',
'Test Summary Report',
'-------------------',
'[[red]]',
- 't/source_tests/harness_failure (Wstat: 0 Tests: 2 Failed: 1)',
+ "$source_tests/harness_failure (Wstat: 0 Tests: 2 Failed: 1)",
'[[reset]]',
'[[red]]',
'Failed test:',
# quiet tests with failures
@output = ();
- _runtests( $harness_whisper, 't/source_tests/harness_failure' );
+ _runtests( $harness_whisper, "$source_tests/harness_failure" );
$status = pop @output;
$summary = pop @output;
@expected = (
- 't/source_tests/harness_failure....',
+ "$source_tests/harness_failure....",
'Failed 1/2 subtests',
'Test Summary Report',
'-------------------',
- 't/source_tests/harness_failure (Wstat: 0 Tests: 2 Failed: 1)',
+ "$source_tests/harness_failure (Wstat: 0 Tests: 2 Failed: 1)",
'Failed test:',
'2',
);
# really quiet tests with failures
@output = ();
- _runtests( $harness_mute, 't/source_tests/harness_failure' );
+ _runtests( $harness_mute, "$source_tests/harness_failure" );
$status = pop @output;
$summary = pop @output;
@expected = (
'Test Summary Report',
'-------------------',
- 't/source_tests/harness_failure (Wstat: 0 Tests: 2 Failed: 1)',
+ "$source_tests/harness_failure (Wstat: 0 Tests: 2 Failed: 1)",
'Failed test:',
'2',
);
@output = ();
_runtests(
$harness_directives,
- 't/source_tests/harness_directives'
+ "$source_tests/harness_directives"
);
chomp(@output);
@expected = (
- 't/source_tests/harness_directives....',
+ "$source_tests/harness_directives....",
'not ok 2 - we have a something # TODO some output',
"ok 3 houston, we don't have liftoff # SKIP no funding",
'ok',
# ~TODO {{{ this should be an option
#'Test Summary Report',
#'-------------------',
- #'t/source_tests/harness_directives (Wstat: 0 Tests: 3 Failed: 0)',
+ #"$source_tests/harness_directives (Wstat: 0 Tests: 3 Failed: 0)",
#'Tests skipped:',
#'3',
# }}}
);
@output = ();
- _runtests( $harness, 't/source_tests/harness_badtap' );
+ _runtests( $harness, "$source_tests/harness_badtap" );
chomp(@output);
@output = map { trim($_) } @output;
@summary = @output[ 12 .. ( $#output - 1 ) ];
@output = @output[ 0 .. 11 ];
@expected = (
- 't/source_tests/harness_badtap....',
+ "$source_tests/harness_badtap....",
'1..2',
'[[reset]]',
'ok 1 - this is a test',
'Test Summary Report',
'-------------------',
'[[red]]',
- 't/source_tests/harness_badtap (Wstat: 0 Tests: 2 Failed: 1)',
+ "$source_tests/harness_badtap (Wstat: 0 Tests: 2 Failed: 1)",
'[[reset]]',
'[[red]]',
'Failed test:',
# only show failures
@output = ();
- _runtests( $harness_failures, 't/source_tests/harness_failure' );
+ _runtests( $harness_failures, "$source_tests/harness_failure" );
chomp(@output);
@expected = (
- 't/source_tests/harness_failure....',
+ "$source_tests/harness_failure....",
'not ok 2 - this is another test',
'Failed 1/2 subtests',
'Test Summary Report',
'-------------------',
- 't/source_tests/harness_failure (Wstat: 0 Tests: 2 Failed: 1)',
+ "$source_tests/harness_failure (Wstat: 0 Tests: 2 Failed: 1)",
'Failed test:',
'2',
);
# check the status output for no tests
@output = ();
- _runtests( $harness_failures, 't/sample-tests/no_output' );
+ _runtests( $harness_failures, "$sample_tests/no_output" );
chomp(@output);
@expected = (
- 't/sample-tests/no_output....',
+ "$sample_tests/no_output....",
'No subtests run',
'Test Summary Report',
'-------------------',
- 't/sample-tests/no_output (Wstat: 0 Tests: 0 Failed: 0)',
+ "$sample_tests/no_output (Wstat: 0 Tests: 0 Failed: 0)",
'Parse errors: No plan found in TAP output',
);
}
);
- eval { _runtests( $harness, 't/data/catme.1' ) };
+ eval {
+ _runtests(
+ $harness,
+ $ENV{PERL_CORE} ? 'lib/data/catme.1' : 't/data/catme.1'
+ );
+ };
my @output = tied($$capture)->dump;
my $status = pop @output;
_runtests(
$harness,
- 't/source_tests/harness_complain'
+ "$source_tests/harness_complain"
, # will get mad if run with args
- 't/source_tests/harness',
+ "$source_tests/harness",
);
my @output = tied($$capture)->dump;
# coverage tests for the basically untested T::H::_open_spool
- $ENV{PERL_TEST_HARNESS_DUMP_TAP} = File::Spec->catfile(qw(t spool));
+ my @spool = ( $ENV{PERL_CORE} ? ('spool') : ( '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
# a cleanup hook
# normal tests in verbose mode
- my $parser = $harness->runtests(
- File::Spec->catfile(qw (t source_tests harness )) );
+ my $parser
+ = $harness->runtests( File::Spec->catfile( $source_tests, 'harness' ) );
isa_ok $parser, 'TAP::Parser::Aggregator',
'... runtests returns the aggregate';
ok -e File::Spec->catfile(
$ENV{PERL_TEST_HARNESS_DUMP_TAP},
- qw( t source_tests harness )
+ $source_tests, 'harness'
);
}
#!/usr/bin/perl -w
BEGIN {
- if ($ENV{PERL_CORE}) {
- # FIXME
- print "1..0 # Skip pending resolution of how to set the library with -I\n";
- exit 0;
+ if ( $ENV{PERL_CORE} ) {
+ chdir 't';
+ @INC = ( '../lib', 'lib' );
+ }
+ else {
+ unshift @INC, 't/lib';
}
}
# tests
use strict;
-use lib 't/lib';
-
use Test::More ( $^O eq 'VMS' ? ( skip_all => 'VMS' ) : ( tests => 3 ) );
use Config;
use TAP::Parser;
+my $lib_path = join( ', ', map "'$_'", grep !ref, grep defined, @INC );
+
sub run_test_file {
my ( $test_template, @args ) = @_;
- my $test_file = 't/temp_test.tmp';
+ my $test_file = 'temp_test.tmp';
open TEST, ">$test_file" or die $!;
printf TEST $test_template, @args;
{
local $ENV{PERL5LIB} = join $Config{path_sep}, grep defined, 'wibble',
$ENV{PERL5LIB};
- run_test_file(<<'END');
+ run_test_file( <<'END', $lib_path );
#!/usr/bin/perl -T
-use lib 't/lib';
+BEGIN { unshift @INC, ( %s ); }
use Test::More tests => 1;
-is( $INC[1], 'wibble' ) or diag join "\n", @INC;
+ok grep(/^wibble$/, @INC) or diag join "\n", @INC;
END
}
local $ENV{PERL5LIB};
local $ENV{PERLLIB} = join $Config{path_sep}, grep defined, 'wibble',
$perl5lib;
- run_test_file(<<'END');
+ run_test_file( <<'END', $lib_path );
#!/usr/bin/perl -T
-use lib 't/lib';
+BEGIN { unshift @INC, ( %s ); }
use Test::More tests => 1;
-is( $INC[1], 'wibble' ) or diag join "\n", @INC;
+ok grep(/^wibble$/, @INC) or diag join "\n", @INC;
END
}
{
+ local $ENV{PERL5LIB} = join $Config{path_sep}, @INC;
local $ENV{PERL5OPT} = '-Mstrict';
run_test_file(<<'END');
#!/usr/bin/perl -T