michael@0: #!/usr/bin/env perl michael@0: ########################################################################### michael@0: ## Intent: michael@0: ## Test::Harness is a testing wrapper that will process output michael@0: ## from Test.pm module tests. Sumarize results, report stats michael@0: ## and exit with overall status for the testing suites. michael@0: ## michael@0: ## Run testing suite: michael@0: ## % make clean test michael@0: ## % perl runtest michael@0: ## michael@0: ## Run Individual tests michael@0: ## % perl tUtils0 michael@0: ########################################################################### michael@0: michael@0: ##----------------------------## michael@0: ##---] CORE/CPAN INCLUDES [---## michael@0: ##----------------------------## michael@0: use strict; michael@0: use warnings; michael@0: use Getopt::Long; michael@0: michael@0: use Test::Harness; michael@0: michael@0: ##-------------------## michael@0: ##---] EXPORTS [---## michael@0: ##-------------------## michael@0: our $VERSION = qw(1.0); michael@0: use FindBin; michael@0: michael@0: ##-------------------## michael@0: ##---] GLOBALS [---## michael@0: ##-------------------## michael@0: my %argv; michael@0: michael@0: ##----------------## michael@0: ##---] MAIN [---## michael@0: ##----------------## michael@0: unless(GetOptions(\%argv, michael@0: qw(debug|d) michael@0: )) michael@0: { michael@0: print "Usage: $0\n"; michael@0: print " --debug Enable debug mode\n"; michael@0: exit 1; michael@0: } michael@0: michael@0: if (2 > $Test::Harness::VERSION) michael@0: { michael@0: print "Unit tests will not be run, Test::Harness is too old\n" michael@0: if ($argv{debug}); michael@0: exit 0; michael@0: } michael@0: michael@0: michael@0: my @tests; michael@0: michael@0: ######################################## michael@0: ## Gather a list of tests if none passed michael@0: ######################################## michael@0: unless (@tests = @ARGV) michael@0: { michael@0: local *D; michael@0: opendir(D, '.'); michael@0: while($_ = readdir(D)) { michael@0: next unless /.t\S+$/; michael@0: next if (/\.ts$/); michael@0: push(@tests, $_); michael@0: } michael@0: closedir(D); michael@0: } michael@0: michael@0: ############################################### michael@0: ## Glob a list of tests when directories passed michael@0: ############################################### michael@0: my @tmp; michael@0: foreach (@tests) michael@0: { michael@0: local *D; michael@0: if (-d $_ && (my $dir = $_)) michael@0: { michael@0: opendir(D, $_) || die "opendir(D) failed: $!"; michael@0: my @tests = grep(/\.t[^\.\s]+/o, readdir(D)); michael@0: closedir(D); michael@0: push(@tmp, map{ join('/', $dir, $_); } @tests); michael@0: } else { michael@0: push(@tmp, $_); michael@0: } michael@0: } michael@0: @tests = @tmp; michael@0: michael@0: print "$0: @ARGV\n" if ($argv{debug}); michael@0: runtests(@tests); michael@0: michael@0: # EOF