Skip to content

Commit b684fd6

Browse files
authored
Merge pull request #25 from cxw42/capture-tests
Rework tests to run more cleanly in a sandbox. v0.500.1.
2 parents 01ff3c2 + 8d80aa4 commit b684fd6

19 files changed

+816
-414
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
/tags
33
/fatlib
44
/stuff
5+
*.stackdump
6+
core
57

68
# Dist
79
/Text-PerlPP*

MANIFEST

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ pack.PL Script to make the packed version
99
README
1010
README.md The tutorial
1111
t/00-load.t
12-
t/01-basic.t
13-
t/01-readme.t
14-
t/02-cmdline.t
12+
t/01-capture.t
13+
t/02-basic.t
14+
t/02-readme.t
15+
t/03-cmdline.t
1516
t/03-idempotency.t
1617
t/04-include.t
1718
t/05-external-command.t
@@ -21,5 +22,7 @@ t/a.txt
2122
t/b.txt
2223
t/c.txt
2324
t/included.txt
25+
t/lib/PerlPPTest.pm The test kit
26+
t/lib/TestcaseList.pm Helper library for autonumbering testcases
2427
t/multiline.txt
2528
t/unclosed.txt

MANIFEST.SKIP

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,4 @@
7575
# Skip some specific files
7676
^Makefile-premodule
7777
^tags
78-
79-
# Things we're still working on
80-
^t\/lib
78+
\.stackdump$

Makefile.PL

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,38 @@ use 5.010;
22
use strict;
33
use warnings;
44
use ExtUtils::MakeMaker;
5+
use Config;
56

6-
sub MY::postamble {
7+
# Get the filename of the Perl interpreter running this. Modified from perlvar.
8+
# The -x test is for cygwin or other systems where $Config{perlpath} has no
9+
# extension and $Config{_exe} is nonempty. E.g., symlink perl->perl5.10.1.exe.
10+
# There is no "perl.exe" on such a system.
11+
sub get_perl_filename {
12+
my $secure_perl_path = $Config{perlpath};
13+
if ($^O ne 'VMS') {
14+
$secure_perl_path .= $Config{_exe}
15+
unless (-x $secure_perl_path) ||
16+
($secure_perl_path =~ m/$Config{_exe}$/i);
17+
}
18+
return $secure_perl_path;
19+
} # get_perl_filename()
20+
21+
my $secure_perl_path = get_perl_filename();
22+
23+
sub MY::postamble { # TODO also handle Windows nmake syntax (SET vs. export)
724
return <<EOT;
825
authortest:
926
\tRELEASE_TESTING=1 prove -l xt"
1027
1128
testhere: # Run the tests from lib rather than blib
12-
\texport PERLPP_CMD="perl -Ilib bin/perlpp"; \\
13-
\tperl -Ilib -e 'use Test::Harness "runtests"; runtests \@ARGV;' -- t/*.t
29+
\t"$secure_perl_path" -Ilib -e 'use Test::Harness "runtests"; runtests \@ARGV;' -- t/*.t
1430
15-
testpacked: pack # Test the packed version
16-
\texport PERLPP_NOUSE=1 PERLPP_CMD="perl blib/perlpp"; \\
17-
\tperl -e 'use Test::Harness "runtests"; runtests \@ARGV;' -- t/*.t
31+
testpacked: pack # Test the packed version.
32+
\tPERLPP_NOUSE=1 PERLPP_PERLOPTS="blib/perlpp" \\
33+
\t"$secure_perl_path" -Ilib -e 'use Test::Harness "runtests"; runtests \@ARGV;' -- t/*.t
1834
EOT
35+
# Note: testpacked uses -Ilib so that I don't have to conditionally
36+
# use Text::PerlPP in t/lib/PerlPPTest.pm.
1937
} #postamble
2038

2139
WriteMakefile(
@@ -32,8 +50,17 @@ WriteMakefile(
3250
},
3351
BUILD_REQUIRES => {
3452
'App::FatPacker' => '0',
53+
},
54+
TEST_REQUIRES => {
55+
'Capture::Tiny' => '0',
56+
'Carp' => '0',
57+
'Config' => '0',
58+
'File::Spec' => '0',
3559
'IPC::Run3' => '0',
60+
'rlib' => '0',
3661
'Test::More' => '0',
62+
'Text::ParseWords' => '0',
63+
'Text::Diff' => '0', # for t/03-idempotency.t
3764
},
3865
PREREQ_PM => {
3966
'Getopt::Long' => '2.5', # Per issue #17

bin/perlpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# To run this manually from the source tree, do
33
# perl -Ilib bin/perlpp
44
use strict; use warnings; use Text::PerlPP;
5-
exit(Text::PerlPP::Main(\@ARGV));
5+
exit(Text::PerlPP->new->Main(\@ARGV));
66
__END__
77
# ### Documentation #######################################################
88

0 commit comments

Comments
 (0)