forked from plainblack/webgui
/
testCodebase.pl
executable file
·131 lines (90 loc) · 3.22 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
#!/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 lib "$FindBin::Bin/../t/lib";
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,
);
pod2usage( verbose => 2 ) if $help;
pod2usage() unless $configFile ne '';
my $verboseFlag = "-v" if ($verbose);
$perlBase .= '/bin/' if ($perlBase);
##Defaults to command-line switch
$configFile ||= $ENV{WEBGUI_CONFIG};
if (! -e $configFile) {
##Probably given the name of the config file with no path,
##attempt to prepend the path to it.
$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 $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 ../t'); print "\n";
system(join ' ', $prefix, $perlBase."prove", $verboseFlag, '-r ../t');
__END__
=head1 NAME
testCodebase - Test WebGUI's code base.
=head1 SYNOPSIS
testCodebase --configFile 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 config.conf>
The WebGUI config file to use. Only the file name needs to be specified,
since it will be looked up inside WebGUI's configuration directory. Be
aware that some of the tests may be destructive. This parameter is required.
=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