summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2012-02-26 15:24:21 +0100
committerNicholas Clark <nick@ccl4.org>2012-02-26 19:52:05 +0100
commit509a2f669223ac7ed75b674fa9b8bea43665a039 (patch)
treeb0220fde8469841b71dfc3ba5a28db8628f15ec2
parent58f4be15ca5c6af8391ddae5084f106eb8d59970 (diff)
downloadperl-smoke-me/tweak-run-tests.tar.gz
Improve the tests for -xsmoke-me/tweak-run-tests
Test the error message generated when -x can't find a "#!perl" line. Test that this error message still appears when -x is used with -e.
-rw-r--r--MANIFEST1
-rw-r--r--t/run/switchx.aux2
-rw-r--r--t/run/switchx.t19
-rw-r--r--t/run/switchx3.aux2
4 files changed, 22 insertions, 2 deletions
diff --git a/MANIFEST b/MANIFEST
index 720385ddf8..05a47fa1e8 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -5458,6 +5458,7 @@ t/run/switchn.t Test the -n switch
t/run/switchp.t Test the -p switch
t/run/switcht.t Test the -t switch
t/run/switchx2.aux Data for switchx.t
+t/run/switchx3.aux Data for switchx.t
t/run/switchx.aux Data for switchx.t
t/run/switchx.t Test the -x switch
t/TEST The regression tester
diff --git a/t/run/switchx.aux b/t/run/switchx.aux
index bfb79e1509..0db6103ee2 100644
--- a/t/run/switchx.aux
+++ b/t/run/switchx.aux
@@ -17,7 +17,7 @@ still not perl
#!/some/path/that/leads/to/perl -l
-print "1..4";
+print "1..7";
if (-f 'run/switchx.aux') {
print "ok 1";
}
diff --git a/t/run/switchx.t b/t/run/switchx.t
index 75dd50da10..bcea3d0ab6 100644
--- a/t/run/switchx.t
+++ b/t/run/switchx.t
@@ -4,6 +4,7 @@ BEGIN {
chdir 't' if -d 't';
@INC = '../lib';
}
+use strict;
require './test.pl';
@@ -16,4 +17,20 @@ print runperl( switches => ['-x./run'],
progfile => 'run/switchx2.aux',
args => [ 3 ] );
-# EOF
+curr_test(5);
+
+# Test the error message for not found
+like(runperl(switches => ['-x'], progfile => 'run/switchx3.aux', stderr => 1),
+ qr/^No Perl script found in input\r?\n\z/,
+ "Test the error message when -x can't find a #!perl line");
+
+SKIP: {
+ skip("These tests embed newlines in command line arguments, which isn't portable to $^O", 2)
+ if $^O eq 'MSWin32' or $^O eq 'VMS';
+ my @progs = ("die;\n", "#!perl\n", "warn;\n");
+ is(runperl(progs => \@progs, stderr => 1, non_portable => 1),
+ "Died at -e line 1.\n", 'Test program dies');
+ is(runperl(progs => \@progs, stderr => 1, non_portable => 1,
+ switches => ['-x']),
+ "No Perl script found in input\n", '-x and -e gives expected error');
+}
diff --git a/t/run/switchx3.aux b/t/run/switchx3.aux
new file mode 100644
index 0000000000..647947e285
--- /dev/null
+++ b/t/run/switchx3.aux
@@ -0,0 +1,2 @@
+print "not ok 5\n";
+die "You shouldn't get here";