From 9bf7bde644de0056028f2c6d03f0e41bb635d134 Mon Sep 17 00:00:00 2001 From: steve Date: Sat, 16 Jun 2007 13:36:41 +0000 Subject: [PATCH] 2007-06-16 13:36:41 by steve Added test : Make sure our scripts have no trailing whitespace, it is icky. --- tests/test-trailing-whitespace.t | 61 ++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 tests/test-trailing-whitespace.t diff --git a/tests/test-trailing-whitespace.t b/tests/test-trailing-whitespace.t new file mode 100644 index 0000000..9f5124f --- /dev/null +++ b/tests/test-trailing-whitespace.t @@ -0,0 +1,61 @@ +#!/usr/bin/perl -w +# +# Test that every script in ./bin/ has no trailing whitespace. +# +# Steve +# -- +# $Id: test-trailing-whitespace.t,v 1.1 2007-06-16 13:36:41 steve Exp $ + + +use strict; +use File::Find; +use Test::More qw( no_plan ); + + +# +# Find our bin/ directory. +# +my $dir = undef; + +$dir = "./bin/" if ( -d "./bin/" ); +$dir = "../bin/" if ( -d "../bin/" ); + +plan skip_all => "No bin directory found" if (!defined( $dir ) ); + + +# +# Process each file. +# +foreach my $file (sort( glob ( $dir . "*" ) ) ) +{ + # skip backups, and directories. + next if ( $file =~ /~$/ ); + next if ( -d $file ); + + ok( -e $file, "Found file : $file" ); + + checkFile( $file ); +} + + +# +# Check a file. +# +# +sub checkFile +{ + my( $file ) = (@_); + + my $trailing = 0; + + # Read the file. + open( INPUT, "<", $file ); + foreach my $line ( ) + { + $trailing = 1 if ( $line =~ /^(.*)[ \t]+$/ ) + } + close( INPUT ); + + is( $trailing, 0, "File has no trailing whitespace" ); +} +