RE: DB_File-1.79 on Cygwin 1.3.3
[p5sagit/p5-mst-13.2.git] / ext / DB_File / t / db-hash.t
index bd6fb58..f23c5f2 100755 (executable)
@@ -1,12 +1,23 @@
-#!./perl -w
+#!./perl 
+
+use warnings ;
+use strict ;
 
 BEGIN {
-    chdir 't' if -d 't';
-    @INC = '../lib';
-    require Config; import Config;
-    if ($Config{'extensions'} !~ /\bDB_File\b/) {
-       print "1..0 # Skip: DB_File was not built\n";
-       exit 0;
+    unless(grep /blib/, @INC) {
+        chdir 't' if -d 't';
+        @INC = '../lib' if -d '../lib';
+    }
+}
+use Config;
+BEGIN {
+    if(-d "lib" && -f "TEST") {
+        if ($Config{'extensions'} !~ /\bDB_File\b/ ) {
+            print "1..111\n";
+            exit 0;
+        }
     }
 }
 
@@ -55,10 +66,21 @@ sub docat_del
     open(CAT,$file) || die "Cannot open $file: $!";
     my $result = <CAT>;
     close(CAT);
+    $result = normalise($result) ;
     unlink $file ;
     return $result;
 }   
 
+sub normalise
+{
+    my $data = shift ;
+    $data =~ s#\r\n#\n#g 
+        if $^O eq 'cygwin' ;
+    return $data ;
+}
+
+
+
 my $Dfile = "dbhash.tmp";
 my $null_keys_allowed = ($DB_File::db_ver < 2.004010 
                                || $DB_File::db_ver >= 3.1 );
@@ -109,8 +131,11 @@ ok(15, $X = tie(%h, 'DB_File',$Dfile, O_RDWR|O_CREAT, 0640, $DB_HASH ) );
 
 my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
    $blksize,$blocks) = stat($Dfile);
+
+my %noMode = map { $_, 1} qw( amigaos MSWin32 NetWare cygwin ) ;
+
 ok(16, ($mode & 0777) == (($^O eq 'os2' || $^O eq 'MacOS') ? 0666 : 0640) ||
-   $^O eq 'amigaos' || $^O eq 'MSWin32' || $^O eq 'cygwin' || $^O eq 'NetWare');
+   $noMode{$^O} );
 
 my ($key, $value, $i);
 while (($key,$value) = each(%h)) {