forked from plainblack/webgui
/
testCodebase.pl
executable file
·144 lines (100 loc) · 3.96 KB
/
testCodebase.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/usr/bin/env perl
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2009 Plain Black Corporation.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
$|=1;
use strict;
use FindBin;
use File::Spec qw[];
use Getopt::Long;
use Pod::Usage;
my $configFile;
my $help;
my $verbose;
my $perlBase;
my $noLongTests;
my $coverage;
GetOptions(
'verbose'=>\$verbose,
'configFile=s'=>\$configFile,
'perlBase=s'=>\$perlBase,
'noLongTests'=>\$noLongTests,
'help'=>\$help,
'coverage'=>\$coverage,
);
##Defaults to command-line switch
$configFile ||= $ENV{WEBGUI_CONFIG};
pod2usage( verbose => 2 ) if $help;
pod2usage() unless $configFile ne '';
my $verboseFlag = "-v" if ($verbose);
$perlBase .= '/bin/' if ($perlBase);
if (! -e $configFile) {
##Probably given the name of the config file with no path,
##attempt to prepend the path to it.
warn "Config file $configFile does not exist, assuming that you supplied a bare config and are running from inside the sbin directory\n";
$configFile = File::Spec->canonpath($FindBin::Bin.'/../etc/'.$configFile);
}
die "Unable to use $configFile as a WebGUI config file\n"
unless(-e $configFile and -f _);
my (undef, $directories, $file) = File::Spec->splitpath($configFile);
my $webguiRoot = File::Spec->canonpath(File::Spec->catdir($directories, File::Spec->updir));
my $webguiTest = File::Spec->catdir($webguiRoot, 't');
my $prefix = "WEBGUI_CONFIG=".$configFile;
##Run all tests unless explicitly forbidden
$prefix .= " CODE_COP=1" unless $noLongTests;
# Add coverage tests
$prefix .= " HARNESS_PERL_SWITCHES='-MDevel::Cover=-db,/tmp/coverdb'" if $coverage;
print(join ' ', $prefix, $perlBase."prove", $verboseFlag, '-r', $webguiTest); print "\n";
system(join ' ', $prefix, $perlBase."prove", $verboseFlag, '-r', $webguiTest);
__END__
=head1 NAME
testCodebase - Test WebGUI's code base.
=head1 SYNOPSIS
testCodebase --configFile /data/WebGUI/etc/config.conf
[--coverage]
[--noLongTests]
[--perlBase path]
[--verbose]
testCodebase --help
=head1 DESCRIPTION
This WebGUI utility script tests all of WebGUI's installed code base
using a particular confiuration file. It uses B<prove> to run all
the WebGUI supplied test routines, located in the B<t> subdirectory
of the WebGUI root.
You should B<NOT> use a production config file for testing, since some
of the test may be destructive.
=over
=item B<--configFile /data/WebGUI/etc/config.conf>
A WebGUI config file is required for testing. If one cannot be
found based on input from the user, then the script aborts
without running any tests.
Config files can be supplied on the command line, or via the environment
variable, WEBGUI_CONFIG being used as a fallback. If the config file
cannot be found, the script assumes that a bare filename was provided and
that it is being from from the WebGUI sbin directory. It then looks in
the parallel directory, '../etc', for the config file.
Be aware that some of the tests are destructive, and running tests
on production sites is not recommended.
=item B<--coverage>
Turns on additional L<Devel::Cover> based coverage tests. Note that
this can take a long time to run.
=item B<--noLongTests>
Prevent long tests from being run
=item B<--perlBase path>
Specify a path to an alternative Perl installation you wish to use for the
tests. If left unspecified, it defaults to the Perl installation in the
current PATH.
=item B<--verbose>
Turns on additional information during tests.
=item B<--help>
Shows this documentation, then exits.
=back
=head1 AUTHOR
Copyright 2001-2009 Plain Black Corporation.
=cut