Attached is a patch that uses the same perl to run the scripts as to run the tests. It also fixes running the tests in a directory with spaces in the name.
--- a/t/lib/Bin/Test.pm 2013-05-02 21:47:57.000000000 +0100
+++ b/t/lib/Bin/Test.pm 2013-05-16 10:52:42.544455269 +0100
@@ -35,8 +35,9 @@
sub capture_ok {
my ($cmd, $stdout_ok, $stderr_ok, $testmsg) = @_;
+ my ($script, @args) = @{$cmd};
my $msg = $testmsg ? " - $testmsg" : "";
- my ($stdout, $stderr) = capture { system("$TBin/$cmd") };
+ my ($stdout, $stderr) = capture { system($^X, "$TBin/$script", @args) };
eq_or_diff $stdout, $stdout_ok, "$cmd STDOUT$msg";
eq_or_diff $stderr, $stderr_ok, "$cmd STDERR$msg";
}
@@ -50,7 +51,7 @@
skip "No $ok_file to test with", 2 unless -f $ok_file;
my $stdout_ok = slurp($ok_file);
- capture_ok( "$cmd --usage", $stdout_ok, "" );
+ capture_ok( [$cmd, "--usage"], $stdout_ok, "" );
}
$ok_file = "$Bin/bin.ok/$cmd.man.ok";
@@ -58,7 +59,7 @@
skip "No $ok_file to test with", 2 unless -f $ok_file;
my $stdout_ok = slurp($ok_file);
- capture_ok( "$cmd --man", $stdout_ok, "" );
+ capture_ok( [$cmd, "--man"], $stdout_ok, "" );
}
}
@@ -68,7 +69,7 @@
my $stdout_ok = slurp("$Bin/bin.ok/basic.usage.ok");
foreach my $flag (qw/-? --help --usage/) {
- capture_ok( "basic $flag", $stdout_ok, "" );
+ capture_ok( [basic => $flag], $stdout_ok, "" );
}
}
--- a/t/lib/Basic/Test.pm 2013-05-02 21:47:57.000000000 +0100
+++ b/t/lib/Basic/Test.pm 2013-05-16 10:46:56.655677698 +0100
@@ -15,9 +15,10 @@
sub cmd_stdout_like {
my $cmd = shift;
my $re = shift;
- my $tname = shift || "$cmd; stdout like $re";
+ my $tname = shift || "@$cmd; stdout like $re";
+ my ($script, @args) = @{$cmd};
- my ($stdout, $stderr) = capture { system("$TBin/$cmd") };
+ my ($stdout, $stderr) = capture { system($^X, "$TBin/$script", @args) };
like $stdout, $re, $tname;
}
@@ -59,9 +60,9 @@
sub cmd_line_errors : Tests(2) {
my $self = shift;
- cmd_stdout_like 'basic --notanoption',
+ cmd_stdout_like [qw'basic --notanoption'],
qr/^Unknown option: notanoption\nUsage/;
- cmd_stdout_like 'basic --verbose=2',
+ cmd_stdout_like [qw'basic --verbose=2'],
qr/^Option verbose does not take an argument\nUsage/;
# TODO : Test all the error traps and test status code.