Change 11039 by jhi@alpha on 2001/06/30 12:59:25

        Subject: [PATCH t/run/exit.t] Another shot at testing exit codes.
        From: Michael G Schwern <[EMAIL PROTECTED]>
        Date: Fri, 29 Jun 2001 19:39:11 -0400
        Message-ID: <20010629193910.D25304@blackrider>

Affected files ...

... //depot/perl/MANIFEST#487 edit
... //depot/perl/t/run/exit.t#1 add

Differences ...

==== //depot/perl/MANIFEST#487 (text) ====
Index: perl/MANIFEST
--- perl/MANIFEST.~1~   Sat Jun 30 07:00:06 2001
+++ perl/MANIFEST       Sat Jun 30 07:00:06 2001
@@ -2060,6 +2060,7 @@
 t/pod/testpchk.pl              Module to test Pod::Checker for a given file
 t/pod/testpods/lib/Pod/Stuff.pm                        Sample data for find.t
 t/README                       Instructions for regression tests
+t/run/exit.t                    Test perl's exit status.
 t/run/runenv.t                 Test if perl honors its environment variables.
 t/TEST                         The regression tester
 t/TestInit.pm                  Preamble library for core tests

==== //depot/perl/t/run/exit.t#1 (text) ====
Index: perl/t/run/exit.t
--- perl/t/run/exit.t.~1~       Sat Jun 30 07:00:06 2001
+++ perl/t/run/exit.t   Sat Jun 30 07:00:06 2001
@@ -0,0 +1,32 @@
+#!./perl
+#
+# Tests for perl exit codes, playing with $?, etc...
+
+
+BEGIN {
+    chdir 't' if -d 't';
+    @INC = '../lib';
+}
+
+# VMS needs -e "...", most everything else works better with '
+my $quote = $^O eq 'VMS' ? q{"} : q{'};
+
+# Run some code, return its wait status.
+sub run {
+    my($code) = shift;
+    my $cmd = "$^X -e ";
+    return system($cmd.$quote.$code.$quote);
+}
+
+use Test::More tests => 3;
+
+my $exit;
+
+$exit = run('exit');
+is( $exit >> 8, 0,              'Normal exit' );
+
+$exit = run('exit 42');
+is( $exit >> 8, 42,             'Non-zero exit' );
+
+$exit = run('END { $? = 42 }');
+is( $exit >> 8, 42,             'Changing $? in END block' );
End of Patch.

Reply via email to