Skip to content

Commit 198ab81

Browse files
author
Chris White
committed
Bugfix in PerlPP.pm; TEST_REQUIRES; decimal vernum
- PerlPP.pm was referring directly to ARGV in one place - that is now fixed - Changed to decimal-form version numbers, but still using semver - now version 0.500.001 so it will be sure to look bigger than v0.4 used to. - Added TEST_REQUIRES to Makefile.PL t/03-idempotency now passes.
1 parent 3b5b89a commit 198ab81

File tree

4 files changed

+32
-15
lines changed

4 files changed

+32
-15
lines changed

Makefile.PL

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,14 @@ WriteMakefile(
4343
'IPC::Run3' => '0',
4444
'Test::More' => '0',
4545
},
46-
# TODO add TEST_REQUIRES
46+
TEST_REQUIRES => {
47+
'Capture::Tiny' => '0',
48+
'Carp' => '0',
49+
'Config' => '0',
50+
'File::Spec' => '0',
51+
'Text::ParseWords' => '0',
52+
'Text::WordDiff' => '0',
53+
},
4754
PREREQ_PM => {
4855
'Getopt::Long' => '2.5', # Per issue #17
4956
'Pod::Usage' => '0',

lib/Text/PerlPP.pm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
package Text::PerlPP;
55

6-
our $VERSION = '0.4.0';
6+
our $VERSION = '0.500001';
77

88
use 5.010001;
99
use strict;
@@ -736,7 +736,7 @@ sub _parse_command_line {
736736
}
737737

738738
# Process other arguments. TODO? support multiple input filenames?
739-
$hrOptsOut->{INPUT_FILENAME} = $ARGV[0] // "";
739+
$hrOptsOut->{INPUT_FILENAME} = $lrArgs->[0] // "";
740740

741741
return true; # Go ahead and run
742742
} #_parse_command_line()

t/03-idempotency.t

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1-
#!/usr/bin/env perl -W
1+
#!/usr/bin/env perl
22
# Test running perlpp on itself - nothing should change.
3-
# Always uses the Text/PerlPP.pm in lib, for simplicity.
43
use rlib './lib';
54
use PerlPPTest;
6-
#use constant CMD => ($ENV{PERLPP_CMD} || 'perl -Iblib/lib blib/script/perlpp')
7-
#. ' lib/Text/PerlPP.pm';
8-
#diag 'idempotency-test command: ' . CMD;
5+
use Text::WordDiff;
6+
use File::Spec;
7+
use Data::Dumper;
98

109
plan tests => 1;
11-
my $fn = $INC{'Text/PerlPP.pm'};
10+
my $fn = File::Spec->rel2abs($INC{'Text/PerlPP.pm'});
1211

13-
my ($wholefile, $out);
12+
my $wholefile;
1413

1514
$wholefile = eval {
1615
my $fh;
@@ -19,15 +18,25 @@ $wholefile = eval {
1918
<$fh>;
2019
};
2120
my $loaderr = $@;
22-
my $err;
21+
my $out;
22+
2323
if($loaderr) {
2424
chomp $loaderr;
2525
fail("idempotency ($loaderr)");
2626
} else {
27-
run_perlpp [$fn], undef, \$out, \$err;
28-
is($out, $wholefile, 'leaves its own source unchanged');
29-
diag(substr($out,0,100));
30-
diag(substr($err,0,100));
27+
my $lrArgs = [$fn];
28+
unshift @$lrArgs, '-E' if @ARGV;
29+
# debugging help for running this test from the command line
30+
31+
diag "Checking $fn";
32+
#diag "args: ", Dumper(\@ARGV);
33+
run_perlpp $lrArgs, undef, \$out;
34+
35+
ok($out eq $wholefile, 'leaves its own source unchanged');
36+
diag "Diff:\n" . word_diff \$wholefile, \$out unless $out eq $wholefile;
37+
38+
#diag("Out:\n" . (@ARGV ? $out : substr($out,0,100)));
39+
#diag("Wholefile:\n" . $wholefile) if @ARGV;
3140
}
3241

3342
# vi: set ts=4 sts=0 sw=4 noet ai: #

t/lib/PerlPPTest.pm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ sub L {
3939
# run_perlpp: Run perlpp
4040
# Args: $lrArgs, $refStdin, $refStdout, $refStderr
4141
sub run_perlpp {
42+
#say STDERR "args ", Dumper(\@_);
4243
my $lrArgs = shift;
4344
my $refStdin = shift // \(my $nullstdin);
4445
my $refStdout = shift // \(my $nullstdout);

0 commit comments

Comments
 (0)