-
Notifications
You must be signed in to change notification settings - Fork 51
/
runtests.pl
114 lines (79 loc) · 2.82 KB
/
runtests.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
#!/usr/bin/perl -w
=head1 NAME
runtests.pl - Runs Bricolage's Tests
=head1 VERSION
$LastChangedRevision$
=head1 DATE
$LastChangedDate$
=head1 SYNOPSIS
# In Makefile:
TEST_VERBOSE=0
test :
PERL_DL_NONLAZY=1 $(PERL) inst/runtests.pl
devtest :
PERL_DL_NONLAZY=1 $(PERL) inst/runtests.pl -d
# Run standard tests from the shell.
make test
make test TEST_VERBOSE=1
# Do the same with all tests.
make devtest
make devtest TEST_VERBOSE=1
# Or simply execute this script.
perl inst/runtests.pl
perl inst/runtests.pl Bric::TestClass Bric::TestClass2 ...
perl inst/runtests.pl t/Bric/TestClass, t/Bric/TestClass2 ...
perl inst/runtests.pl -V
perl inst/runtests.pl -V Bric::TestClass Bric::TestClass2 ...
perl inst/runtests.pl -V t/Bric/TestClass, t/Bric/TestClass2 ...
perl inst/runtests.pl -d
perl inst/runtests.pl -dV
=head1 DESCRIPTION
This script is called during "make test" and "make devtest" to run the
Bricolage test suite. Passing in the "-d" argument is what causes the script
to run I<all> of the tests, including developer tests, while no arguments
cause the script to only run the 'Test.pm' scripts.
If the environment variable C<TEST_VERBOSE> is set, or the C<-V> option is
passed in, then the tests will be run in verbose mode.
If a list of one or more test classes and/or test class files are passed in,
then only the tests in those files and/or classes will be run.
All tests are executed in the Bricolage distribution root directory. If you're
writing tests that need to output test files or something, please use
C<< File::Spec->tmpdir >> and clean up after yourself!
=head1 AUTHOR
David Wheeler <david@justatheory.com>
=head1 SEE ALSO
L<Test::Class|Test::Class>, L<Test::More|Test::More>.
=cut
use strict;
use warnings;
use File::Spec;
use Test::Harness qw(runtests $verbose);
use Getopt::Std;
# Add the requisite library paths to @INC.
unshift @INC, 'lib', File::Spec->catdir('t');
# Get arguments.
my %opts;
getopts('dV', \%opts);
# Prepare for 'make devtest'. The test runner will check this environment
# variable.
$ENV{BRIC_DEV_TEST} ||= $opts{d} if $opts{d};
$ENV{BRIC_TEST_CLASSES} = join ',', @ARGV if @ARGV;
#Set option to enable test cache
#This only enables the code that checks if it should do test
#caching
$ENV{BRIC_CACHE_DEBUG_MODE} = 1;
# Set verbosity.
if ($opts{V}) {
# This environment variable tells Test::Class to be verbose.
$ENV{TEST_VERBOSE} = 1;
# This variable tells Test::Harness to be verbose.
$verbose = 1;
} else {
# Tell Test::Harness to be verbose if the TEST_VERBOSE environment
# variable is set.
$verbose = 1 if $ENV{TEST_VERBOSE};
}
# Make sure that all tests are run with warnings enabled.
$ENV{HARNESS_PERL_SWITCHES} = '-w';
# Run the tests!
runtests(File::Spec->catfile(qw(t Bric Test Runner.pm)));