Quick trailing whitespace testing
authorGreg Sabino Mullane <greg@endpoint.com>
Fri, 6 Jun 2014 19:47:59 +0000 (15:47 -0400)
committerGreg Sabino Mullane <greg@endpoint.com>
Fri, 6 Jun 2014 19:47:59 +0000 (15:47 -0400)
t/99-lint.t

index 423324ea8a7b8f2db626bc4d0469dfc8c5e99b93..b5d65ba71ca1d91d191fbf45c5c418077e1c0ac6 100644 (file)
@@ -30,6 +30,8 @@ if (! open $fh, '<', $file) {
 
 check_subroutines($file, $fh);
 
+check_whitespace($file, $fh);
+
 done_testing();
 
 sub check_subroutines {
@@ -147,3 +149,37 @@ sub check_subroutines {
 } ## end of check_for_contract
 
 
+sub check_whitespace {
+
+    ## Check various whitespace rules
+    ## Arguments: two
+    ## 1. File name
+    ## 2. file handle
+    ## Returns: undef
+
+    my $filename = shift;
+    my $fh = shift;
+
+    ## Rewind to the beginning
+    seek $fh, 0, 0;
+
+    my %found;
+
+    ## Just in case, reset the line counter
+    $. = 0;
+
+    while (<$fh>) {
+
+        if (/ +$/) {
+            fail "Trailing whitespace found at line $. of file $filename";
+        }
+    }
+
+    ## Do *not* close the file handle!
+
+    return;
+
+
+} ## end of check_whitespace
+
+