Change 20974 by [EMAIL PROTECTED] on 2003/08/31 15:40:42

        Integrate:
        [ 20970]
        List the switches tested in switches.t.
        
        [ 20971]
        Add test for -v.
        
        [ 20972]
        Add tests for -h and (unknown) -z.
        
        [ 20973]
        Add test for -i.

Affected files ...

... //depot/maint-5.8/perl/MANIFEST#108 integrate
... //depot/maint-5.8/perl/installperl#13 integrate
... //depot/maint-5.8/perl/t/run/switches.t#4 integrate

Differences ...

==== //depot/maint-5.8/perl/MANIFEST#108 (text) ====
Index: perl/MANIFEST
--- perl/MANIFEST#107~20966~    Sun Aug 31 01:58:09 2003
+++ perl/MANIFEST       Sun Aug 31 08:40:42 2003
@@ -2834,7 +2834,7 @@
 t/run/switcha.t                        Test the -a switch
 t/run/switchC.t                        Test the -C switch
 t/run/switchd.t                        Test the -d switch
-t/run/switches.t               Tests for the other switches (-0, -l, -c, -s, -M, -m, 
-V)
+t/run/switches.t               Tests for the other switches (-0, -l, -c, -s, -M, -m, 
-V, -v, -h, -z, -i)
 t/run/switchF.t                        Test the -F switch
 t/run/switchI.t                        Test the -I switch
 t/run/switchn.t                        Test the -n switch

==== //depot/maint-5.8/perl/installperl#13 (xtext) ====
Index: perl/installperl
--- perl/installperl#12~20740~  Sat Aug 16 14:13:53 2003
+++ perl/installperl    Sun Aug 31 08:40:42 2003
@@ -309,6 +309,9 @@
 # First we install the version-numbered executables.
 
 if ($Is_VMS) {
+    safe_unlink("$installbin/perl_setup.com");
+    copy("perl_setup.com", "$installbin/perl_setup.com");
+    chmod(0755, "$installbin/perl_setup.com");
     safe_unlink("$installbin/$dbg$perl$exe_ext");
     copy("$dbg$perl$exe_ext", "$installbin/$dbg$perl$exe_ext");
     chmod(0755, "$installbin/$dbg$perl$exe_ext");
@@ -316,9 +319,12 @@
     copy("$dbg${perl}shr$exe_ext", "$installbin/$dbg${perl}shr$exe_ext");
     chmod(0755, "$installbin/$dbg${perl}shr$exe_ext");
     if ($ndbg) {
-       safe_unlink("$installbin/$ndbg$perl$exe_ext");
-       copy("$ndbg$perl$exe_ext", "$installbin/$ndbg$perl$exe_ext");
-       chmod(0755, "$installbin/$ndbg$perl$exe_ext");
+        safe_unlink("$installbin/$ndbg$perl$exe_ext");
+        copy("$ndbg$perl$exe_ext", "$installbin/$ndbg$perl$exe_ext");
+        chmod(0755, "$installbin/$ndbg$perl$exe_ext");
+       safe_unlink("$installbin/${dbg}a2p$exe_ext");
+       copy("x2p/${dbg}a2p$exe_ext", "$installbin/${dbg}a2p$exe_ext");
+       chmod(0755, "$installbin/${dbg}a2p$exe_ext");
     }
 }
 elsif ($^O eq 'mpeix') {
@@ -508,7 +514,7 @@
 }
 
 # Make links to ordinary names if installbin directory isn't current directory.
-if (!$Is_NetWare) {
+if (!$Is_NetWare && $dbg eq '') {
     if (! samepath($installbin, 'x2p')) {
        my $base = 'a2p';
        $base .= $ver if $versiononly;

==== //depot/maint-5.8/perl/t/run/switches.t#4 (text) ====
Index: perl/t/run/switches.t
--- perl/t/run/switches.t#3~19704~      Fri Jun  6 22:24:27 2003
+++ perl/t/run/switches.t       Sun Aug 31 08:40:42 2003
@@ -1,6 +1,8 @@
 #!./perl -w
 
-# Tests for the command-line switches
+# Tests for the command-line switches:
+# -0, -c, -l, -s, -m, -M, -V, -v, -h, -z, -i
+# Some switches have their own tests, see MANIFEST.
 
 BEGIN {
     chdir 't' if -d 't';
@@ -9,7 +11,7 @@
 
 require "./test.pl";
 
-plan(tests => 20);
+plan(tests => 26);
 
 # due to a bug in VMS's piping which makes it impossible for runperl()
 # to emulate echo -n (ie. stdin always winds up with a newline), these 
@@ -182,10 +184,14 @@
     local $TODO = '';   # these ones should work on VMS
 
     # basic perl -V should generate significant output.
-    # we don't test actual format since it could change
+    # we don't test actual format too much since it could change
     like( runperl( switches => ['-V'] ), qr/(\n.*){20}/,
           '-V generates 20+ lines' );
 
+    like( runperl( switches => ['-V'] ),
+         qr/\ASummary of my perl5 .*configuration:/,
+          '-V looks okay' );
+
     # lookup a known config var
     chomp( $r=runperl( switches => ['-V:osname'] ) );
     is( $r, "osname='$^O';", 'perl -V:osname');
@@ -204,4 +210,74 @@
 
     # make sure each line we got matches the re
     ok( !( grep !/^i\D+size=/, split /^/, $r ), '-V:re correct' );
+}
+
+# Tests for -v
+
+{
+    local $TODO = '';   # these ones should work on VMS
+
+    my $v = sprintf "%vd", $^V;
+    use Config;
+    like( runperl( switches => ['-v'] ),
+         qr/This is perl, v$v built for $Config{archname}.+Copyright.+Larry 
Wall.+Artistic License.+GNU General Public License/s,
+          '-v looks okay' );
+
+}
+
+# Tests for -h
+
+{
+    local $TODO = '';   # these ones should work on VMS
+
+    like( runperl( switches => ['-h'] ),
+         qr/Usage: .+perl.+switches.+programfile.+arguments/,
+          '-h looks okay' );
+
+}
+
+# Tests for -z (which does not exist)
+
+{
+    local $TODO = '';   # these ones should work on VMS
+
+    like( runperl( switches => ['-z'], stderr => 1 ),
+         qr/\QUnrecognized switch: -z  (-h will show valid options)./,
+          '-z correctly unknown' );
+
+}
+
+# Tests for -i
+
+{
+    local $TODO = '';   # these ones should work on VMS
+
+    sub do_i_unlink { 1 while unlink("file", "file.bak") }
+
+    open(FILE, ">file") or die "$0: Failed to create 'file': $!";
+    print FILE <<__EOF__;
+foo yada dada
+bada foo bing
+king kong foo
+__EOF__
+    close FILE;
+
+    END { do_i_unlink() }
+
+    runperl( switches => ['-pi.bak'], prog => 's/foo/bar/', args => ['file'] );
+
+    open(FILE, "file") or die "$0: Failed to open 'file': $!";
+    chomp(my @file = <FILE>);
+    close FILE;
+
+    open(BAK, "file.bak") or die "$0: Failed to open 'file': $!";
+    chomp(my @bak = <BAK>);
+    close BAK;
+
+    is(join(":", @file),
+       "bar yada dada:bada bar bing:king kong bar",
+       "-i new file");
+    is(join(":", @bak),
+       "foo yada dada:bada foo bing:king kong foo",
+       "-i backup file");
 }
End of Patch.

Reply via email to