2
# Copyright (C) 2006 MySQL AB
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; version 2 of the License.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17
use Test::Harness qw(&runtests $verbose);
30
unit - Run unit tests in directory
40
if (defined $cmd && exists $dispatch{$cmd}) {
41
$dispatch{$cmd}->(@ARGV);
43
print "Unknown command", (defined $cmd ? " $cmd" : ""), ".\n";
44
print "Available commands are: ", join(", ", keys %dispatch), "\n";
49
Run all unit tests in the current directory and all subdirectories.
54
sub _find_test_files (@) {
58
$File::Find::prune = 1 if /^SCCS$/;
59
push(@files, $File::Find::name) if -x _ && (/-t\z/ || /-t\.exe\z/);
67
# If no directories were supplied, we add all directories in the
68
# current directory except 'mytap' since it is not part of the
71
# Ignore these directories
72
my @ignore = qw(mytap SCCS);
74
# Build an expression from the directories above that tests if a
75
# directory should be included in the list or not.
76
my $ignore = join(' && ', map { '$_ ne ' . "'$_'"} @ignore);
78
# Open and read the directory. Filter out all files, hidden
79
# directories, and directories named above.
80
opendir(DIR, ".") or die "Cannot open '.': $!\n";
81
@_ = grep { -d $_ && $_ !~ /^\..*/ && eval $ignore } readdir(DIR);
85
print "Running tests: @_\n";
87
foreach my $name (@_) {
88
push(@files, _find_test_files $name) if -d $name;
89
push(@files, $name) if -f $name;
93
# Removing the first './' from the file names
94
foreach (@files) { s!^\./!! }
95
$ENV{'HARNESS_PERL_SWITCHES'} .= ' -e "exec @ARGV"';