This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Too fast for FAT filesystems
[perl5.git] / lib / AutoSplit.t
index 7723a53..256b43f 100644 (file)
@@ -7,6 +7,10 @@ my $incdir;
 my $lib = '"-I../lib"'; # ok on unix, nt, The extra \" are for VMS
 BEGIN {
     chdir 't' if -d 't';
 my $lib = '"-I../lib"'; # ok on unix, nt, The extra \" are for VMS
 BEGIN {
     chdir 't' if -d 't';
+    if ($^O eq 'dos') {
+       print "1..0 # This test is not 8.3-aware.\n";
+           exit 0;
+    }
     if ($^O eq 'MacOS') {
        $incdir = ":auto-$$";
         $lib = '-x -I::lib:'; # -x overcomes MPW $Config{startperl} anomaly
     if ($^O eq 'MacOS') {
        $incdir = ":auto-$$";
         $lib = '-x -I::lib:'; # -x overcomes MPW $Config{startperl} anomaly
@@ -45,6 +49,8 @@ my @tests;
   close DATA;
 }
 
   close DATA;
 }
 
+my $pathsep = $^O eq 'MSWin32' ? '\\' : '/';
 sub split_a_file {
   my $contents = shift;
   my $file = $_[0];
 sub split_a_file {
   my $contents = shift;
   my $file = $_[0];
@@ -56,7 +62,7 @@ sub split_a_file {
 
   # Assumption: no characters in arguments need escaping from the shell or perl
   my $com = qq($runperl -e "use AutoSplit; autosplit (qw(@_))");
 
   # Assumption: no characters in arguments need escaping from the shell or perl
   my $com = qq($runperl -e "use AutoSplit; autosplit (qw(@_))");
-  print "# $com\n";
+  print "# command: $com\n";
   # There may be a way to capture STDOUT without spawning a child process, but
   # it's probably worthwhile spawning, as it ensures that nothing in AutoSplit
   # can load functions from split modules into this perl.
   # There may be a way to capture STDOUT without spawning a child process, but
   # it's probably worthwhile spawning, as it ensures that nothing in AutoSplit
   # can load functions from split modules into this perl.
@@ -65,16 +71,6 @@ sub split_a_file {
   return $output;
 }
 
   return $output;
 }
 
-# Brackets are valid in VMS filespecs and this test puts filespecs
-# into regexes a lot.
-
-sub _escape_brackets {
-  my $str = shift;
-  $str =~ s/\[/\\\[/g;   
-  $str =~ s/\]/\\\]/g;
-  return $str;
-}
-
 my $i = 0;
 my $dir = File::Spec->catdir($incdir, 'auto');
 if ($^O eq 'VMS') {
 my $i = 0;
 my $dir = File::Spec->catdir($incdir, 'auto');
 if ($^O eq 'VMS') {
@@ -87,6 +83,7 @@ foreach (@tests) {
   s/\*INC\*/$incdir/gm;
   s/\*DIR\*/$dir/gm;
   s/\*MOD\*/$module/gm;
   s/\*INC\*/$incdir/gm;
   s/\*DIR\*/$dir/gm;
   s/\*MOD\*/$module/gm;
+  s/\*PATHSEP\*/$pathsep/gm;
   s#//#/#gm;
   # Build a hash for this test.
   my %args = /^\#\#\ ([^\n]*)\n        # Key is on a line starting ##
   s#//#/#gm;
   # Build a hash for this test.
   my %args = /^\#\#\ ([^\n]*)\n        # Key is on a line starting ##
@@ -112,9 +109,8 @@ foreach (@tests) {
      while ($output =~ m/(\[.+\])/) {
        $filespec = $1;
        $replacement =  VMS::Filespec::unixify($filespec);
      while ($output =~ m/(\[.+\])/) {
        $filespec = $1;
        $replacement =  VMS::Filespec::unixify($filespec);
-       $filespec = _escape_brackets($filespec);
        $replacement =~ s/\/$//;
        $replacement =~ s/\/$//;
-       $output =~ s/$filespec/$replacement/;
+       $output =~ s/\Q$filespec\E/$replacement/;
      }
   }
 
      }
   }
 
@@ -147,6 +143,7 @@ foreach (@tests) {
   }
   if ($args{Require}) {
     my $com = 'require "' . File::Spec->catfile ('auto', $args{Require}) . '"';
   }
   if ($args{Require}) {
     my $com = 'require "' . File::Spec->catfile ('auto', $args{Require}) . '"';
+    $com =~ s{\\}{/}gm if ($^O eq 'MSWin32');
     eval $com;
     # test n+3
     ok ($@ eq '', $com) or print "# \$\@ = '$@'\n";
     eval $com;
     # test n+3
     ok ($@ eq '', $com) or print "# \$\@ = '$@'\n";
@@ -170,7 +167,6 @@ foreach (@tests) {
   if ($args{Tests}) {
     foreach my $code (split /\n/, $args{Tests}) {
       next if $code =~ /^\#/;
   if ($args{Tests}) {
     foreach my $code (split /\n/, $args{Tests}) {
       next if $code =~ /^\#/;
-      $code =~ s/\[(File::Spec->catfile\(.*\))\]/[_escape_brackets($1)]/ if $^O eq 'VMS';
       defined eval $code or fail(), print "# Code:  $code\n# Error: $@";
     }
   }
       defined eval $code or fail(), print "# Code:  $code\n# Error: $@";
     }
   }
@@ -225,11 +221,11 @@ sub test_a2 : locked { 1; }
 # And that was all it has. You were expected to manually inspect the output
 ## Get
 Warning: AutoSplit had to create top-level *DIR* unexpectedly.
 # And that was all it has. You were expected to manually inspect the output
 ## Get
 Warning: AutoSplit had to create top-level *DIR* unexpectedly.
-AutoSplitting *INC*/*MOD*.pm (*DIR*/*MOD*)
-*INC*/*MOD*.pm: some names are not unique when truncated to 8 characters:
- directory *DIR*/*MOD*:
+AutoSplitting *INC**PATHSEP**MOD*.pm (*DIR**PATHSEP**MOD*)
+*INC**PATHSEP**MOD*.pm: some names are not unique when truncated to 8 characters:
+ directory *DIR**PATHSEP**MOD*:
   testtesttesttest4_1.al, testtesttesttest4_2.al truncate to testtest
   testtesttesttest4_1.al, testtesttesttest4_2.al truncate to testtest
- directory *DIR*/Yet/Another/AutoSplit:
+ directory *DIR**PATHSEP*Yet*PATHSEP*Another*PATHSEP*AutoSplit:
   testtesttesttest4_1.al, testtesttesttest4_2.al truncate to testtest
 ## Files
 *DIR*/*MOD*/autosplit.ix
   testtesttesttest4_1.al, testtesttesttest4_2.al truncate to testtest
 ## Files
 *DIR*/*MOD*/autosplit.ix
@@ -265,7 +261,7 @@ is (&*MOD*::testtesttesttest4_2, "duplicate test 4");
 is (&Just::Another::test5, "another test 5");
 # very messy way to interpolate function into regexp, but it's going to be
 # needed to get : for Mac filespecs
 is (&Just::Another::test5, "another test 5");
 # very messy way to interpolate function into regexp, but it's going to be
 # needed to get : for Mac filespecs
-like (&*MOD*::test6, qr!^*INC*/*MOD*.pm \(autosplit into @{[File::Spec->catfile('*DIR*','*MOD*', 'test6.al')]}\):\d+$!);
+like (&*MOD*::test6, qr!^\Q*INC**PATHSEP**MOD*\E\.pm \(autosplit into \Q@{[File::Spec->catfile('*DIR*','*MOD*', 'test6.al')]}\E\):\d+$!);
 ok (Yet::Another::AutoSplit->testtesttesttest4_1 eq "another test 4");
 ################################################################
 ## Name
 ok (Yet::Another::AutoSplit->testtesttesttest4_1 eq "another test 4");
 ################################################################
 ## Name
@@ -285,7 +281,7 @@ missing use AutoLoader; (but don't skip)
 1;
 __END__
 ## Get
 1;
 __END__
 ## Get
-AutoSplitting *INC*/*MOD*.pm (*DIR*/*MOD*)
+AutoSplitting *INC**PATHSEP**MOD*.pm (*DIR**PATHSEP**MOD*)
 ## Require
 *MOD*/autosplit.ix
 ## Files
 ## Require
 *MOD*/autosplit.ix
 ## Files
@@ -300,7 +296,7 @@ __END__
 sub obsolete {my $a if 0; return $a++;}
 sub gonner {warn "This gonner function should never get called"}
 ## Get
 sub obsolete {my $a if 0; return $a++;}
 sub gonner {warn "This gonner function should never get called"}
 ## Get
-AutoSplitting *INC*/*MOD*.pm (*DIR*/*MOD*)
+AutoSplitting *INC**PATHSEP**MOD*.pm (*DIR**PATHSEP**MOD*)
 ## Require
 *MOD*/autosplit.ix
 ## Files
 ## Require
 *MOD*/autosplit.ix
 ## Files
@@ -311,7 +307,7 @@ AutoSplitting *INC*/*MOD*.pm (*DIR*/*MOD*)
 is (&*MOD*::obsolete, 0);
 is (&*MOD*::obsolete, 1);
 ## Sleep
 is (&*MOD*::obsolete, 0);
 is (&*MOD*::obsolete, 1);
 ## Sleep
-2
+4
 ## SameAgain
 True, so don't scrub this directory.
 IIRC DOS FAT filesystems have only 2 second granularity.
 ## SameAgain
 True, so don't scrub this directory.
 IIRC DOS FAT filesystems have only 2 second granularity.
@@ -328,7 +324,7 @@ sub ghoul {"wail"};
 sub zombie {"You didn't use fire."};
 sub flying_pig {"Oink oink flap flap"};
 ## Get
 sub zombie {"You didn't use fire."};
 sub flying_pig {"Oink oink flap flap"};
 ## Get
-AutoSplitting *INC*/*MOD*.pm (*DIR*/*MOD*)
+AutoSplitting *INC**PATHSEP**MOD*.pm (*DIR**PATHSEP**MOD*)
 ## Require
 *MOD*/autosplit.ix
 ## Files
 ## Require
 *MOD*/autosplit.ix
 ## Files
@@ -342,7 +338,7 @@ AutoSplitting *INC*/*MOD*.pm (*DIR*/*MOD*)
 is (&*MOD*::skeleton, "bones", "skeleton");
 eval {&*MOD*::gonner}; ok ($@ =~ m!^Can't locate auto/*MOD*/gonner.al in \@INC!, "Check &*MOD*::gonner is now a gonner") or print "# \$\@='$@'\n";
 ## Sleep
 is (&*MOD*::skeleton, "bones", "skeleton");
 eval {&*MOD*::gonner}; ok ($@ =~ m!^Can't locate auto/*MOD*/gonner.al in \@INC!, "Check &*MOD*::gonner is now a gonner") or print "# \$\@='$@'\n";
 ## Sleep
-2
+4
 ## SameAgain
 True, so don't scrub this directory.
 ################################################################
 ## SameAgain
 True, so don't scrub this directory.
 ################################################################
@@ -357,7 +353,7 @@ __END__
 sub ghost {"bump"};
 sub wraith {9};
 ## Get
 sub ghost {"bump"};
 sub wraith {9};
 ## Get
-AutoSplitting *INC*/*MOD*.pm (*DIR*/*MOD*)
+AutoSplitting *INC**PATHSEP**MOD*.pm (*DIR**PATHSEP**MOD*)
 ## Require
 *MOD*/autosplit.ix
 ## Files
 ## Require
 *MOD*/autosplit.ix
 ## Files
@@ -372,12 +368,12 @@ AutoSplitting *INC*/*MOD*.pm (*DIR*/*MOD*)
 is (&*MOD*::ghost, "bump");
 is (&*MOD*::zombie, "You didn't use fire.", "Are our zombies undead?");
 ## Sleep
 is (&*MOD*::ghost, "bump");
 is (&*MOD*::zombie, "You didn't use fire.", "Are our zombies undead?");
 ## Sleep
-2
+4
 ## SameAgain
 True, so don't scrub this directory.
 ################################################################
 ## Name
 ## SameAgain
 True, so don't scrub this directory.
 ################################################################
 ## Name
-Without the the timestamp check make sure that nothing happens
+Without the timestamp check make sure that nothing happens
 ## Extra
 0, 1, 1
 ## Require
 ## Extra
 0, 1, 1
 ## Require
@@ -394,16 +390,16 @@ Without the the timestamp check make sure that nothing happens
 is (&*MOD*::ghoul, "wail", "still haunted");
 is (&*MOD*::zombie, "You didn't use fire.", "Are our zombies still undead?");
 ## Sleep
 is (&*MOD*::ghoul, "wail", "still haunted");
 is (&*MOD*::zombie, "You didn't use fire.", "Are our zombies still undead?");
 ## Sleep
-2
+4
 ## SameAgain
 True, so don't scrub this directory.
 ################################################################
 ## Name
 ## SameAgain
 True, so don't scrub this directory.
 ################################################################
 ## Name
-With the the timestamp check make sure that things happen (stuff gets deleted)
+With the timestamp check make sure that things happen (stuff gets deleted)
 ## Extra
 0, 1, 0
 ## Get
 ## Extra
 0, 1, 0
 ## Get
-AutoSplitting *INC*/*MOD*.pm (*DIR*/*MOD*)
+AutoSplitting *INC**PATHSEP**MOD*.pm (*DIR**PATHSEP**MOD*)
 ## Require
 *MOD*/autosplit.ix
 ## Files
 ## Require
 *MOD*/autosplit.ix
 ## Files