t/io/fs.t: code cleanup

--------------42BEAB57EE2F5B14C99B73D9
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit

While examining https://rt.perl.org/Ticket/Display.html?id=132663 today 
and communicating with patch contributor Sevan Janiyan on #p5p, I had 
occasion to examine the code in t/io/fs.t -- the test file under 
discussion in that RT.

I found that test file hard to read -- which is not surprising given 
that it has been around since 1987!  It has acquired a lot of variety in 
indentation patterns; identical test descriptions for multiple tests; a 
non-encapsulated subroutine; code commented out 16 years ago but never 
deleted; etc.

The patches attached -- which can also be found in the 
smoke-me/jkeenan/cleanup-t-io-fs branch -- perform code cleanup one 
little step at a time.  I ran the test file after each commit to ensure 
that the results would DWIM.  I would like to get the code in the file 
cleaned up before applying the RT 132663 patch, so I plan to apply these 
patches tomorrow unless someone has a serious objection.

Thank you very much.
Jim Keenan

--------------42BEAB57EE2F5B14C99B73D9
Content-Type: text/x-patch;
 name="0008-Move-subroutine-definition-to-end-of-file.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="0008-Move-subroutine-definition-to-end-of-file.patch"

From 167698623cbaa3e5aeab8736f1c62ecb89be2a1f Mon Sep 17 00:00:00 2001
From: James E Keenan <jkeenan@cpan.org>
Date: Mon, 29 Oct 2018 17:56:20 -0400
Subject: [PATCH 8/8] Move subroutine definition to end of file.

Thereby improving readability of main program.
---
 t/io/fs.t | 117 +++++++++++++++++++++++++++---------------------------
 1 file changed, 58 insertions(+), 59 deletions(-)

diff --git a/t/io/fs.t b/t/io/fs.t
index 970d0d5432..ecab714846 100644
--- a/t/io/fs.t
+++ b/t/io/fs.t
@@ -270,65 +270,6 @@ SKIP: {
     isnt($!+0, 0, "and errno was set");
 }
 
-
-sub check_utime_result {
-    ($ut, $accurate_timestamps, $delta) = @_;
-    ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
-     $blksize,$blocks) = stat('b');
-
-    SKIP: {
-        skip "bogus inode num", 1 if ($^O eq 'MSWin32') || ($^O eq 'NetWare');
-        ok($ino,    'non-zero inode num');
-    }
-
-    SKIP: {
-        skip "filesystem atime/mtime granularity too low", 2
-            unless $accurate_timestamps;
-
-        if ($^O eq 'vos') {
-            skip ("# TODO - hit VOS bug posix-2055 - access time does not follow POSIX rules for an open file.", 2);
-        }
-
-        note("# atime - $atime  mtime - $mtime  delta - $delta");
-        if($atime == $ut && $mtime == $ut + $delta) {
-            pass('atime: granularity test');
-            pass('mtime: granularity test');
-        }
-        else {
-            if ($^O =~ /\blinux\b/i) {
-                note("# Maybe stat() cannot get the correct atime, ".
-                    "as happens via NFS on linux?");
-                $foo = (utime 400000000,$ut + 2*$delta,'b');
-                my ($new_atime, $new_mtime) = (stat('b'))[8,9];
-                note("# newatime - $new_atime  nemtime - $new_mtime");
-                if ($new_atime == $atime && $new_mtime - $mtime == $delta) {
-                    pass("atime - accounted for possible NFS/glibc2.2 bug on linux");
-                    pass("mtime - accounted for possible NFS/glibc2.2 bug on linux");
-                }
-                else {
-                    fail("atime - $atime/$new_atime $mtime/$new_mtime");
-                    fail("mtime - $atime/$new_atime $mtime/$new_mtime");
-                }
-            }
-            elsif ($^O eq 'VMS') {
-                # why is this 1 second off?
-                is( $atime, $ut + 1,      'atime: VMS' );
-                is( $mtime, $ut + $delta, 'mtime: VMS' );
-            }
-            elsif ($^O eq 'haiku') {
-                SKIP: {
-                    skip "atime not updated", 1;
-                }
-                is($mtime, 500000001, 'mtime');
-            }
-            else {
-                fail("atime: default case");
-                fail("mtime: default case");
-            }
-        } # END failed atime mtime 'else' block
-    } # END granularity SKIP block
-}
-
 SKIP: {
     skip "has futimes", 1 if ($Config{d_futimes} || "") eq "define";
     open(my $fh, "<", "b") || die;
@@ -532,3 +473,61 @@ SKIP: {
 
 # need to remove $tmpdir if rename() in test 28 failed!
 END { rmdir $tmpdir1; rmdir $tmpdir; }
+
+sub check_utime_result {
+    ($ut, $accurate_timestamps, $delta) = @_;
+    ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
+     $blksize,$blocks) = stat('b');
+
+    SKIP: {
+        skip "bogus inode num", 1 if ($^O eq 'MSWin32') || ($^O eq 'NetWare');
+        ok($ino,    'non-zero inode num');
+    }
+
+    SKIP: {
+        skip "filesystem atime/mtime granularity too low", 2
+            unless $accurate_timestamps;
+
+        if ($^O eq 'vos') {
+            skip ("# TODO - hit VOS bug posix-2055 - access time does not follow POSIX rules for an open file.", 2);
+        }
+
+        note("# atime - $atime  mtime - $mtime  delta - $delta");
+        if($atime == $ut && $mtime == $ut + $delta) {
+            pass('atime: granularity test');
+            pass('mtime: granularity test');
+        }
+        else {
+            if ($^O =~ /\blinux\b/i) {
+                note("# Maybe stat() cannot get the correct atime, ".
+                    "as happens via NFS on linux?");
+                $foo = (utime 400000000,$ut + 2*$delta,'b');
+                my ($new_atime, $new_mtime) = (stat('b'))[8,9];
+                note("# newatime - $new_atime  nemtime - $new_mtime");
+                if ($new_atime == $atime && $new_mtime - $mtime == $delta) {
+                    pass("atime - accounted for possible NFS/glibc2.2 bug on linux");
+                    pass("mtime - accounted for possible NFS/glibc2.2 bug on linux");
+                }
+                else {
+                    fail("atime - $atime/$new_atime $mtime/$new_mtime");
+                    fail("mtime - $atime/$new_atime $mtime/$new_mtime");
+                }
+            }
+            elsif ($^O eq 'VMS') {
+                # why is this 1 second off?
+                is( $atime, $ut + 1,      'atime: VMS' );
+                is( $mtime, $ut + $delta, 'mtime: VMS' );
+            }
+            elsif ($^O eq 'haiku') {
+                SKIP: {
+                    skip "atime not updated", 1;
+                }
+                is($mtime, 500000001, 'mtime');
+            }
+            else {
+                fail("atime: default case");
+                fail("mtime: default case");
+            }
+        } # END failed atime mtime 'else' block
+    } # END granularity SKIP block
+}
-- 
2.17.1


--------------42BEAB57EE2F5B14C99B73D9
Content-Type: text/x-patch;
 name="0007-Regularize-indents-within-subroutine-definition.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename*0="0007-Regularize-indents-within-subroutine-definition.patch"

From e2d86708785babacdb3e7379f1f97ebcd4a75b50 Mon Sep 17 00:00:00 2001
From: James E Keenan <jkeenan@cpan.org>
Date: Mon, 29 Oct 2018 17:39:48 -0400
Subject: [PATCH 7/8] Regularize indents within subroutine definition.

Over decades, the code within the subroutine acquired many different
combinations of tabs and whitespace for indents, thereby making the code
less readable.  Standardize on 4 whitespaces.

For readability, comment end of two blocks.
---
 t/io/fs.t | 105 +++++++++++++++++++++++++++---------------------------
 1 file changed, 52 insertions(+), 53 deletions(-)

diff --git a/t/io/fs.t b/t/io/fs.t
index 31b8ca515c..970d0d5432 100644
--- a/t/io/fs.t
+++ b/t/io/fs.t
@@ -122,8 +122,8 @@ SKIP: {
         skip "hard links not that hard in $^O", 1 if $^O eq 'amigaos';
         skip "no mode checks", 1 if $skip_mode_checks;
 
-        is(sprintf("0%o", $mode & 0777), 
-            sprintf("0%o", $a_mode & 0777), 
+        is(sprintf("0%o", $mode & 0777),
+            sprintf("0%o", $a_mode & 0777),
             "mode of triply-linked file");
     }
 }
@@ -193,7 +193,7 @@ SKIP: {
     }
     is(chmod($newmode, "a"), 1, "fchmod");
     $mode = (stat $fh)[2];
-    SKIP: { 
+    SKIP: {
         skip "no mode checks", 1 if $skip_mode_checks;
         is($mode & 0777, $newmode, "perm restored");
     }
@@ -276,58 +276,57 @@ sub check_utime_result {
     ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
      $blksize,$blocks) = stat('b');
 
- SKIP: {
-	skip "bogus inode num", 1 if ($^O eq 'MSWin32') || ($^O eq 'NetWare');
-
-	ok($ino,    'non-zero inode num');
+    SKIP: {
+        skip "bogus inode num", 1 if ($^O eq 'MSWin32') || ($^O eq 'NetWare');
+        ok($ino,    'non-zero inode num');
     }
 
- SKIP: {
-	skip "filesystem atime/mtime granularity too low", 2
-	    unless $accurate_timestamps;
-
-     if ($^O eq 'vos') {
-	    skip ("# TODO - hit VOS bug posix-2055 - access time does not follow POSIX rules for an open file.", 2);
-     }
-
-	note("# atime - $atime  mtime - $mtime  delta - $delta");
-	if($atime == $ut && $mtime == $ut + $delta) {
-	    pass('atime: granularity test');
-	    pass('mtime: granularity test');
-	}
-	else {
-	    if ($^O =~ /\blinux\b/i) {
-		note("# Maybe stat() cannot get the correct atime, ".
-		    "as happens via NFS on linux?");
-		$foo = (utime 400000000,$ut + 2*$delta,'b');
-		my ($new_atime, $new_mtime) = (stat('b'))[8,9];
-		note("# newatime - $new_atime  nemtime - $new_mtime");
-		if ($new_atime == $atime && $new_mtime - $mtime == $delta) {
-		    pass("atime - accounted for possible NFS/glibc2.2 bug on linux");
-		    pass("mtime - accounted for possible NFS/glibc2.2 bug on linux");
-		}
-		else {
-		    fail("atime - $atime/$new_atime $mtime/$new_mtime");
-		    fail("mtime - $atime/$new_atime $mtime/$new_mtime");
-		}
-	    }
-	    elsif ($^O eq 'VMS') {
-		# why is this 1 second off?
-		is( $atime, $ut + 1,      'atime: VMS' );
-		is( $mtime, $ut + $delta, 'mtime: VMS' );
-	    }
-	    elsif ($^O eq 'haiku') {
-            SKIP: {
-		    skip "atime not updated", 1;
-		}
-		is($mtime, 500000001, 'mtime');
-	    }
-	    else {
-		fail("atime: default case");
-		fail("mtime: default case");
-	    }
-	}
-    }
+    SKIP: {
+        skip "filesystem atime/mtime granularity too low", 2
+            unless $accurate_timestamps;
+
+        if ($^O eq 'vos') {
+            skip ("# TODO - hit VOS bug posix-2055 - access time does not follow POSIX rules for an open file.", 2);
+        }
+
+        note("# atime - $atime  mtime - $mtime  delta - $delta");
+        if($atime == $ut && $mtime == $ut + $delta) {
+            pass('atime: granularity test');
+            pass('mtime: granularity test');
+        }
+        else {
+            if ($^O =~ /\blinux\b/i) {
+                note("# Maybe stat() cannot get the correct atime, ".
+                    "as happens via NFS on linux?");
+                $foo = (utime 400000000,$ut + 2*$delta,'b');
+                my ($new_atime, $new_mtime) = (stat('b'))[8,9];
+                note("# newatime - $new_atime  nemtime - $new_mtime");
+                if ($new_atime == $atime && $new_mtime - $mtime == $delta) {
+                    pass("atime - accounted for possible NFS/glibc2.2 bug on linux");
+                    pass("mtime - accounted for possible NFS/glibc2.2 bug on linux");
+                }
+                else {
+                    fail("atime - $atime/$new_atime $mtime/$new_mtime");
+                    fail("mtime - $atime/$new_atime $mtime/$new_mtime");
+                }
+            }
+            elsif ($^O eq 'VMS') {
+                # why is this 1 second off?
+                is( $atime, $ut + 1,      'atime: VMS' );
+                is( $mtime, $ut + $delta, 'mtime: VMS' );
+            }
+            elsif ($^O eq 'haiku') {
+                SKIP: {
+                    skip "atime not updated", 1;
+                }
+                is($mtime, 500000001, 'mtime');
+            }
+            else {
+                fail("atime: default case");
+                fail("mtime: default case");
+            }
+        } # END failed atime mtime 'else' block
+    } # END granularity SKIP block
 }
 
 SKIP: {
-- 
2.17.1


--------------42BEAB57EE2F5B14C99B73D9
Content-Type: text/x-patch;
 name="0006-Fully-encapsulate-check_utime_result.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="0006-Fully-encapsulate-check_utime_result.patch"

From cb1116ee76e531ce8af0ccea4a35a33c328ebe92 Mon Sep 17 00:00:00 2001
From: James E Keenan <jkeenan@cpan.org>
Date: Mon, 29 Oct 2018 17:34:22 -0400
Subject: [PATCH 6/8] Fully encapsulate check_utime_result()

This will permit us to move the subroutine's definition to the end of
the file, thereby improving readability of main program.
---
 t/io/fs.t | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/t/io/fs.t b/t/io/fs.t
index cb3cad5fb5..31b8ca515c 100644
--- a/t/io/fs.t
+++ b/t/io/fs.t
@@ -248,7 +248,7 @@ $ut = 500000000;
 note("basic check of atime and mtime");
 $foo = (utime $ut,$ut + $delta,'b');
 is($foo, 1, "utime");
-check_utime_result();
+check_utime_result($ut, $accurate_timestamps, $delta);
 
 utime undef, undef, 'b';
 ($atime,$mtime) = (stat 'b')[8,9];
@@ -262,7 +262,7 @@ SKIP: {
     open(my $fh, "<", 'b');
     $foo = (utime $ut,$ut + $delta, $fh);
     is($foo, 1, "futime");
-    check_utime_result();
+    check_utime_result($ut, $accurate_timestamps, $delta);
     # [perl #122703]
     close $fh;
     ok(!utime($ut,$ut + $delta, $fh),
@@ -272,6 +272,7 @@ SKIP: {
 
 
 sub check_utime_result {
+    ($ut, $accurate_timestamps, $delta) = @_;
     ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
      $blksize,$blocks) = stat('b');
 
-- 
2.17.1


--------------42BEAB57EE2F5B14C99B73D9
Content-Type: text/x-patch;
 name="0005-Remove-code-commented-out-since-March-2002.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="0005-Remove-code-commented-out-since-March-2002.patch"

From 260cbecce3740eb8bfc4cc7b2fe38ccc00025242 Mon Sep 17 00:00:00 2001
From: James E Keenan <jkeenan@cpan.org>
Date: Mon, 29 Oct 2018 17:19:07 -0400
Subject: [PATCH 5/8] Remove code commented out since March 2002.

Align indents after removal of comments.
---
 t/io/fs.t | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/t/io/fs.t b/t/io/fs.t
index 68f23fceab..cb3cad5fb5 100644
--- a/t/io/fs.t
+++ b/t/io/fs.t
@@ -120,15 +120,11 @@ SKIP: {
 
     SKIP: {
         skip "hard links not that hard in $^O", 1 if $^O eq 'amigaos';
-	skip "no mode checks", 1 if $skip_mode_checks;
+        skip "no mode checks", 1 if $skip_mode_checks;
 
-#      if ($^O eq 'cygwin') { # new files on cygwin get rwx instead of rw-
-#          is($mode & 0777, 0777, "mode of triply-linked file");
-#      } else {
-            is(sprintf("0%o", $mode & 0777), 
-               sprintf("0%o", $a_mode & 0777), 
-               "mode of triply-linked file");
-#      }
+        is(sprintf("0%o", $mode & 0777), 
+            sprintf("0%o", $a_mode & 0777), 
+            "mode of triply-linked file");
     }
 }
 
-- 
2.17.1


--------------42BEAB57EE2F5B14C99B73D9
Content-Type: text/x-patch;
 name="0004-Repeatedly-hard-coding-an-integer-is-a-mistake.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename*0="0004-Repeatedly-hard-coding-an-integer-is-a-mistake.patch"

From b2c282bdf9854c13ec19a2e9098e65bfefc2cb45 Mon Sep 17 00:00:00 2001
From: James E Keenan <jkeenan@cpan.org>
Date: Mon, 29 Oct 2018 17:07:09 -0400
Subject: [PATCH 4/8] Repeatedly hard-coding an integer is a mistake.

Place 500000000 in variable $ut.
---
 t/io/fs.t | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/t/io/fs.t b/t/io/fs.t
index 3ed0919310..68f23fceab 100644
--- a/t/io/fs.t
+++ b/t/io/fs.t
@@ -247,27 +247,29 @@ is($ino, undef, "ino of renamed file a should be undef");
 $delta = $accurate_timestamps ? 1 : 2;	# Granularity of time on the filesystem
 chmod 0777, 'b';
 
+$ut = 500000000;
+
 note("basic check of atime and mtime");
-$foo = (utime 500000000,500000000 + $delta,'b');
+$foo = (utime $ut,$ut + $delta,'b');
 is($foo, 1, "utime");
 check_utime_result();
 
 utime undef, undef, 'b';
 ($atime,$mtime) = (stat 'b')[8,9];
 note("# utime undef, undef --> $atime, $mtime");
-isnt($atime, 500000000,          'atime: utime called with two undefs');
-isnt($mtime, 500000000 + $delta, 'mtime: utime called with two undefs');
+isnt($atime, $ut,          'atime: utime called with two undefs');
+isnt($mtime, $ut + $delta, 'mtime: utime called with two undefs');
 
 SKIP: {
     skip "no futimes", 6 unless ($Config{d_futimes} || "") eq "define";
     note("check futimes");
     open(my $fh, "<", 'b');
-    $foo = (utime 500000000,500000000 + $delta, $fh);
+    $foo = (utime $ut,$ut + $delta, $fh);
     is($foo, 1, "futime");
     check_utime_result();
     # [perl #122703]
     close $fh;
-    ok(!utime(500000000,500000000 + $delta, $fh),
+    ok(!utime($ut,$ut + $delta, $fh),
        "utime fails on a closed file handle");
     isnt($!+0, 0, "and errno was set");
 }
@@ -292,7 +294,7 @@ sub check_utime_result {
      }
 
 	note("# atime - $atime  mtime - $mtime  delta - $delta");
-	if($atime == 500000000 && $mtime == 500000000 + $delta) {
+	if($atime == $ut && $mtime == $ut + $delta) {
 	    pass('atime: granularity test');
 	    pass('mtime: granularity test');
 	}
@@ -300,7 +302,7 @@ sub check_utime_result {
 	    if ($^O =~ /\blinux\b/i) {
 		note("# Maybe stat() cannot get the correct atime, ".
 		    "as happens via NFS on linux?");
-		$foo = (utime 400000000,500000000 + 2*$delta,'b');
+		$foo = (utime 400000000,$ut + 2*$delta,'b');
 		my ($new_atime, $new_mtime) = (stat('b'))[8,9];
 		note("# newatime - $new_atime  nemtime - $new_mtime");
 		if ($new_atime == $atime && $new_mtime - $mtime == $delta) {
@@ -314,8 +316,8 @@ sub check_utime_result {
 	    }
 	    elsif ($^O eq 'VMS') {
 		# why is this 1 second off?
-		is( $atime, 500000001,          'atime: VMS' );
-		is( $mtime, 500000000 + $delta, 'mtime: VMS' );
+		is( $atime, $ut + 1,      'atime: VMS' );
+		is( $mtime, $ut + $delta, 'mtime: VMS' );
 	    }
 	    elsif ($^O eq 'haiku') {
             SKIP: {
-- 
2.17.1


--------------42BEAB57EE2F5B14C99B73D9
Content-Type: text/x-patch;
 name="0003-Make-descriptions-more-self-documenting.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="0003-Make-descriptions-more-self-documenting.patch"

From 8ac5e8457b91a2eb3cbca25bbda941729e3e9814 Mon Sep 17 00:00:00 2001
From: James E Keenan <jkeenan@cpan.org>
Date: Mon, 29 Oct 2018 17:00:50 -0400
Subject: [PATCH 3/8] Make descriptions more self-documenting

So that while debugging we can see which 'atime' and 'utime' cases we
are handling.
---
 t/io/fs.t | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/t/io/fs.t b/t/io/fs.t
index 7f5be246c5..3ed0919310 100644
--- a/t/io/fs.t
+++ b/t/io/fs.t
@@ -255,8 +255,8 @@ check_utime_result();
 utime undef, undef, 'b';
 ($atime,$mtime) = (stat 'b')[8,9];
 note("# utime undef, undef --> $atime, $mtime");
-isnt($atime, 500000000, 'atime');
-isnt($mtime, 500000000 + $delta, 'mtime');
+isnt($atime, 500000000,          'atime: utime called with two undefs');
+isnt($mtime, 500000000 + $delta, 'mtime: utime called with two undefs');
 
 SKIP: {
     skip "no futimes", 6 unless ($Config{d_futimes} || "") eq "define";
@@ -314,8 +314,8 @@ sub check_utime_result {
 	    }
 	    elsif ($^O eq 'VMS') {
 		# why is this 1 second off?
-		is( $atime, 500000001,          'atime' );
-		is( $mtime, 500000000 + $delta, 'mtime' );
+		is( $atime, 500000001,          'atime: VMS' );
+		is( $mtime, 500000000 + $delta, 'mtime: VMS' );
 	    }
 	    elsif ($^O eq 'haiku') {
             SKIP: {
@@ -324,8 +324,8 @@ sub check_utime_result {
 		is($mtime, 500000001, 'mtime');
 	    }
 	    else {
-		fail("atime");
-		fail("mtime");
+		fail("atime: default case");
+		fail("mtime: default case");
 	    }
 	}
     }
-- 
2.17.1


--------------42BEAB57EE2F5B14C99B73D9
Content-Type: text/x-patch;
 name="0002-Add-notes-so-it-s-easier-to-see-where-we-are-in-test.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename*0="0002-Add-notes-so-it-s-easier-to-see-where-we-are-in-test.pa";
 filename*1="tch"

From 22f784f41d7bab3f83ddb4fe142ecf99ae269d21 Mon Sep 17 00:00:00 2001
From: James E Keenan <jkeenan@cpan.org>
Date: Mon, 29 Oct 2018 16:44:31 -0400
Subject: [PATCH 2/8] Add notes so it's easier to see where we are in test
 file.

---
 t/io/fs.t | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/t/io/fs.t b/t/io/fs.t
index d5aa336393..7f5be246c5 100644
--- a/t/io/fs.t
+++ b/t/io/fs.t
@@ -247,6 +247,7 @@ is($ino, undef, "ino of renamed file a should be undef");
 $delta = $accurate_timestamps ? 1 : 2;	# Granularity of time on the filesystem
 chmod 0777, 'b';
 
+note("basic check of atime and mtime");
 $foo = (utime 500000000,500000000 + $delta,'b');
 is($foo, 1, "utime");
 check_utime_result();
@@ -259,6 +260,7 @@ isnt($mtime, 500000000 + $delta, 'mtime');
 
 SKIP: {
     skip "no futimes", 6 unless ($Config{d_futimes} || "") eq "define";
+    note("check futimes");
     open(my $fh, "<", 'b');
     $foo = (utime 500000000,500000000 + $delta, $fh);
     is($foo, 1, "futime");
@@ -291,8 +293,8 @@ sub check_utime_result {
 
 	note("# atime - $atime  mtime - $mtime  delta - $delta");
 	if($atime == 500000000 && $mtime == 500000000 + $delta) {
-	    pass('atime');
-	    pass('mtime');
+	    pass('atime: granularity test');
+	    pass('mtime: granularity test');
 	}
 	else {
 	    if ($^O =~ /\blinux\b/i) {
-- 
2.17.1


--------------42BEAB57EE2F5B14C99B73D9
Content-Type: text/x-patch;
 name="0001-Use-t-test.pl-s-note-function.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="0001-Use-t-test.pl-s-note-function.patch"

From d22fcecc31c1d549a5b27df0bc627711c08a77db Mon Sep 17 00:00:00 2001
From: James E Keenan <jkeenan@cpan.org>
Date: Mon, 29 Oct 2018 16:35:35 -0400
Subject: [PATCH 1/8] Use t/test.pl's note() function

.... rather than print(), for informational statements.
---
 t/io/fs.t | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/t/io/fs.t b/t/io/fs.t
index f35b907d5d..d5aa336393 100644
--- a/t/io/fs.t
+++ b/t/io/fs.t
@@ -253,7 +253,7 @@ check_utime_result();
 
 utime undef, undef, 'b';
 ($atime,$mtime) = (stat 'b')[8,9];
-print "# utime undef, undef --> $atime, $mtime\n";
+note("# utime undef, undef --> $atime, $mtime");
 isnt($atime, 500000000, 'atime');
 isnt($mtime, 500000000 + $delta, 'mtime');
 
@@ -289,18 +289,18 @@ sub check_utime_result {
 	    skip ("# TODO - hit VOS bug posix-2055 - access time does not follow POSIX rules for an open file.", 2);
      }
 
-	print "# atime - $atime  mtime - $mtime  delta - $delta\n";
+	note("# atime - $atime  mtime - $mtime  delta - $delta");
 	if($atime == 500000000 && $mtime == 500000000 + $delta) {
 	    pass('atime');
 	    pass('mtime');
 	}
 	else {
 	    if ($^O =~ /\blinux\b/i) {
-		print "# Maybe stat() cannot get the correct atime, ".
-		    "as happens via NFS on linux?\n";
+		note("# Maybe stat() cannot get the correct atime, ".
+		    "as happens via NFS on linux?");
 		$foo = (utime 400000000,500000000 + 2*$delta,'b');
 		my ($new_atime, $new_mtime) = (stat('b'))[8,9];
-		print "# newatime - $new_atime  nemtime - $new_mtime\n";
+		note("# newatime - $new_atime  nemtime - $new_mtime");
 		if ($new_atime == $atime && $new_mtime - $mtime == $delta) {
 		    pass("atime - accounted for possible NFS/glibc2.2 bug on linux");
 		    pass("mtime - accounted for possible NFS/glibc2.2 bug on linux");
-- 
2.17.1


--------------42BEAB57EE2F5B14C99B73D9--
0
jkeenan
10/29/2018 10:12:00 PM
perl.perl5.porters 47402 articles. 0 followers. Follow

1 Replies
10 Views

Similar Articles

[PageSpeed] 19

On 10/29/18 6:12 PM, James E Keenan wrote:
> While examining https://rt.perl.org/Ticket/Display.html?id=132663 today 
> and communicating with patch contributor Sevan Janiyan on #p5p, I had 
> occasion to examine the code in t/io/fs.t -- the test file under 
> discussion in that RT.
> 
> I found that test file hard to read -- which is not surprising given 
> that it has been around since 1987!  It has acquired a lot of variety in 
> indentation patterns; identical test descriptions for multiple tests; a 
> non-encapsulated subroutine; code commented out 16 years ago but never 
> deleted; etc.
> 
> The patches attached -- which can also be found in the 
> smoke-me/jkeenan/cleanup-t-io-fs branch -- perform code cleanup one 
> little step at a time.  I ran the test file after each commit to ensure 
> that the results would DWIM.  I would like to get the code in the file 
> cleaned up before applying the RT 132663 patch, so I plan to apply these 
> patches tomorrow unless someone has a serious objection.
> 
> Thank you very much.
> Jim Keenan

8 patches pushed to blead, the last of which was 
9eccdb0c883aba75b8e69f4550a95d8f90a54cf8
0
jkeenan
10/30/2018 10:39:44 PM
Reply: