Skip to content

Commit 6d555f8

Browse files
author
Chris White
committed
Skip external-command test on non-POSIX platforms
Also, added quote_string to PerlPPTest for use in diagnostics, and updated dependency information.
1 parent 2c6a964 commit 6d555f8

File tree

3 files changed

+34
-6
lines changed

3 files changed

+34
-6
lines changed

Makefile.PL

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ WriteMakefile(
5656
'Carp' => '0',
5757
'Config' => '0',
5858
'File::Spec' => '0',
59+
'Import::Into' => '0',
5960
'IPC::Run3' => '0',
61+
'List::Util' => '0',
6062
'rlib' => '0',
6163
'Test::More' => '0',
6264
'Text::ParseWords' => '0',

t/05-external-command.t

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@
44
# TODO: On non-Unix, test only `echo` with no parameters.
55

66
use rlib './lib';
7-
use PerlPPTest;
7+
use PerlPPTest qw(:DEFAULT quote_string);
8+
use List::Util 'any';
9+
10+
if(any { $_ eq $^O } 'VMS', 'os390', 'os400', 'riscos', 'amigaos') {
11+
plan skip_all => "I don't know how to run this test on $^O";
12+
exit;
13+
}
814

915
(my $whereami = __FILE__) =~ s/macro\.t$//;
1016
my $incfn = '\"' . $whereami . 'included.txt\"';
@@ -22,13 +28,26 @@ my @testcases=(
2228

2329
); #@testcases
2430

25-
plan tests => count_tests(\@testcases, 2, 3);
31+
my $ntests = 1 + count_tests(\@testcases, 2, 3);
32+
plan tests => $ntests;
33+
34+
# First check, which will hopefully work everywhere.
35+
do {
36+
my ($out, $err);
37+
run_perlpp [], \'<?! echo howdy', \$out, \$err;
38+
is($out, "howdy\n", "basic echo");
39+
};
40+
41+
if (any { $_ eq $^O } 'dos', 'os2', 'MSWin') {
42+
skip "I don't know how to run the rest of the tests on $^O", $ntests-1;
43+
exit;
44+
}
2645

2746
for my $lrTest (@testcases) {
2847
my ($opts, $testin, $out_re, $err_re) = @$lrTest;
29-
3048
my ($out, $err);
31-
#diag "perlpp $opts <<<@{[Text::PerlPP::_QuoteString $testin]}";
49+
50+
#diag "perlpp $opts <<<@{[quote_string $testin]}";
3251
run_perlpp $opts, \$testin, \$out, \$err;
3352

3453
if(defined $out_re) {
@@ -37,7 +56,6 @@ for my $lrTest (@testcases) {
3756
if(defined $err_re) {
3857
like($err, $err_re);
3958
}
40-
#print STDERR "$err\n";
4159

4260
} # foreach test
4361

t/lib/PerlPPTest.pm

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use Text::ParseWords qw(shellwords);
2626
#use Devel::StackTrace;
2727

2828
our @EXPORT = qw(run_perlpp L count_tests);
29-
our @EXPORT_OK = qw(get_perl_filename);
29+
our @EXPORT_OK = qw(get_perl_filename quote_string);
3030

3131
# L: given a list, return an array ref that includes that list, with the
3232
# caller's filename:line number at the front of the list
@@ -127,6 +127,14 @@ sub count_tests {
127127
return $testcount;
128128
} # count_tests()
129129

130+
sub quote_string { # wrap $_[0] in single-quotes, escaped properly
131+
my $s = shift;
132+
133+
$s =~ s{\\}{\\\\}g;
134+
$s =~ s{'}{\\'}g;
135+
return "'" . $s . "'";
136+
} # quote_string()
137+
130138
#########################################
131139

132140
sub import {

0 commit comments

Comments
 (0)