build/unix/test/runtest

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/build/unix/test/runtest	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,95 @@
     1.4 +#!/usr/bin/env perl
     1.5 +###########################################################################
     1.6 +## Intent:
     1.7 +##   Test::Harness is a testing wrapper that will process output
     1.8 +##   from Test.pm module tests.  Sumarize results, report stats
     1.9 +##   and exit with overall status for the testing suites.
    1.10 +##
    1.11 +## Run testing suite:
    1.12 +##   % make clean test
    1.13 +##   % perl runtest
    1.14 +##
    1.15 +## Run Individual tests
    1.16 +##   % perl tUtils0
    1.17 +###########################################################################
    1.18 +
    1.19 +##----------------------------##
    1.20 +##---] CORE/CPAN INCLUDES [---##
    1.21 +##----------------------------##
    1.22 +use strict;
    1.23 +use warnings;
    1.24 +use Getopt::Long;
    1.25 +
    1.26 +use Test::Harness;
    1.27 +
    1.28 +##-------------------##
    1.29 +##---]  EXPORTS  [---##
    1.30 +##-------------------##
    1.31 +our $VERSION = qw(1.0);
    1.32 +use FindBin;
    1.33 +
    1.34 +##-------------------##
    1.35 +##---]  GLOBALS  [---##
    1.36 +##-------------------##
    1.37 +my %argv;
    1.38 +
    1.39 +##----------------##
    1.40 +##---]  MAIN  [---##
    1.41 +##----------------##
    1.42 +unless(GetOptions(\%argv,
    1.43 +		  qw(debug|d)
    1.44 +		 ))
    1.45 +{
    1.46 +    print "Usage: $0\n";
    1.47 +    print "  --debug  Enable debug mode\n";
    1.48 +    exit 1;
    1.49 +}
    1.50 +
    1.51 +if (2 > $Test::Harness::VERSION)
    1.52 +{
    1.53 +    print "Unit tests will not be run, Test::Harness is too old\n"
    1.54 +	if ($argv{debug});
    1.55 +    exit 0;
    1.56 +}
    1.57 +
    1.58 +
    1.59 +my @tests;
    1.60 +
    1.61 +########################################
    1.62 +## Gather a list of tests if none passed
    1.63 +########################################
    1.64 +unless (@tests = @ARGV)
    1.65 +{
    1.66 +  local *D;
    1.67 +    opendir(D, '.');
    1.68 +    while($_ = readdir(D)) {
    1.69 +	next unless /.t\S+$/;
    1.70 +	next if (/\.ts$/);
    1.71 +	push(@tests, $_);
    1.72 +    }
    1.73 +    closedir(D);
    1.74 +}
    1.75 +
    1.76 +###############################################
    1.77 +## Glob a list of tests when directories passed
    1.78 +###############################################
    1.79 +my @tmp;
    1.80 +foreach (@tests)
    1.81 +{
    1.82 +  local *D;
    1.83 +    if (-d $_ && (my $dir = $_))
    1.84 +    {
    1.85 +        opendir(D, $_) || die "opendir(D) failed: $!";
    1.86 +	my @tests = grep(/\.t[^\.\s]+/o, readdir(D));
    1.87 +	closedir(D);
    1.88 +	push(@tmp, map{ join('/', $dir, $_); } @tests);
    1.89 +    } else {
    1.90 +        push(@tmp, $_);
    1.91 +    }
    1.92 +}
    1.93 +@tests = @tmp;
    1.94 +
    1.95 +print "$0: @ARGV\n" if ($argv{debug});
    1.96 +runtests(@tests);
    1.97 +
    1.98 +# EOF

mercurial