1Apache::TestMB(3) User Contributed Perl Documentation Apache::TestMB(3)
2
3
4
6 Apache::TestMB - Subclass of Module::Build to support Apache::Test
7
9 Standard process for building & installing modules:
10
11 perl Build.PL
12 ./Build
13 ./Build test
14 ./Build install
15
16 Or, if you're on a platform (like DOS or Windows) that doesn't like the
17 "./" notation, you can do this:
18
19 perl Build.PL
20 perl Build
21 perl Build test
22 perl Build install
23
25 This class subclasses "Module::Build" to add support for testing Apache
26 integration with Apache::Test. It is broadly based on "Apache::TestMM",
27 and as such adds a number of build actions to a the Build script, while
28 simplifying the process of creating Build.PL scripts.
29
30 Here's how to use "Apache::TestMB" in a Build.PL script:
31
32 use Module::Build;
33
34 my $build_pkg = eval { require Apache::TestMB }
35 ? 'Apache::TestMB' : 'Module::Build';
36
37 my $build = $build_pkg->new(
38 module_name => 'My::Module',
39 );
40 $build->create_build_script;
41
42 This is identical to how "Module::Build" is used. Not all target sys‐
43 tems may have "Apache::Test" (and therefore "Apache::TestMB" installed,
44 so we test for it to be installed, first. But otherwise, its use can be
45 exactly the same. Consult the Module::Build documentation for more
46 information on how to use it; Module::Build::Cookbook may be especially
47 useful for those looking to migrate from "ExtUtils::MakeMaker".
48
50 Build
51
52 With the above script, users can build your module in the usual "Mod‐
53 ule::Build" way:
54
55 perl Build.PL
56 ./Build
57 ./Build test
58 ./Build install
59
60 If "Apache::TestMB" is installed, then Apache will be started before
61 tests are run by the "test" action, and shut down when the tests com‐
62 plete. Note that "Build.PL" can be called "Apache::Test"-specific
63 options in addition to the usual "Module::Build" options. For example:
64
65 perl Build.PL -apxs=/usr/local/apache/bin/apxs
66
67 Consult the Apache::Test documentation for a complete list of options.
68
69 In addition to the actions provided by "Module::Build" ("build",
70 "clean", "code", "test", etc.), "Apache::TestMB" adds a few extra
71 actions:
72
73 test_clean
74 This action cleans out the files generated by the test script,
75 t/TEST. It is also executed by the "clean" action.
76
77 run_tests
78 This action actually the tests by executing the test script,
79 t/TEST. It is executed by the "test" action, so most of the time it
80 won't be executed directly.
81
82 testcover
83 "Apache::TestMB" overrides this action from "Module::Build" in
84 order to prevent the "Apache::Test" preference files from being
85 included in the test coverage.
86
87 Constructor
88
89 new
90
91 The "new()" constructor takes all the same arguments as its parent in
92 "Module::Build", but can optionally accept one other parameter:
93
94 apache_test_script
95 The name of the "Apache::Test" test script. The default value is
96 t/TEST, which will work in the vast majority of cases. If you wish
97 to specify your own file name, do so with a relative file name
98 using Unix-style paths; the file name will automatically be con‐
99 verted for the local platform.
100
101 When "new()" is called it does the following:
102
103 · Processes the "Apache::Test"-specific options in @ARGV. See the
104 Apache::Test documentation for a complete list of options.
105
106 · Sets the name of the "Apache::Test" test script to t/TEST, unless
107 it was explicitly specified by the "apache_test_script" parameter.
108
109 · Calls "generate_script()" to generate "Apache::Test" test script,
110 usually t/TEST.
111
112 Instance Methods
113
114 apache_test_args
115
116 Returns a hash reference containing all of the settings specified by
117 options passed to Build.PL, or explicitly added to @ARGV in Build.PL.
118 Consult the Apache::Test documentation for a complete list of options.
119
120 apache_test_script
121
122 Gets or sets the file name of the "Apache::Test" test script.
123
124 generate_script
125
126 $build->generate_script;
127 $build->generate_script('t/FOO');
128 $build->generate_script(undef, 'Apache::TestRun');
129
130 This method is called by "new()", so in most cases it can be ignored.
131 If you'd like it to use other than the default arguments, you can call
132 it explicitly in Build.PL and pass it the arguments you desire. It
133 takes two optional arguments:
134
135 · The name of the "Apache::Test" test script. Defaults to the value
136 returned by "apache_test_script()".
137
138 · The name of an "Apache::Test" test running class. Defaults to
139 "Apache::TestRunPerl".
140
141 If there is an existing t/TEST.PL (or a script with the same name as
142 specified by the "apache_test_script" parameter but with .PL appended
143 to it), then that script will be used as the template for the test
144 script. Otherwise, a simple test script will be written similar to
145 what would be written by "Apache::TestRun::generate_script()" (although
146 that function is not aware of the arguments passed to Build.PL, so use
147 this one instead!).
148
150 Apache::TestRequest
151 Demonstrates how to write tests to send requests to the Apache
152 server run by "./Build test".
153
154 Module::Build
155 The parent class for "Apache::TestMB"; consult it's documentation
156 for more on its interface.
157
158 <http://www.perl.com/pub/a/2003/05/22/testing.html>
159 This article by Geoffrey Young explains how to configure Apache and
160 write tests for your module using Apache::Test. Just use
161 "Apache::TestMB" instead of "Apache::TestMM" to update it for use
162 with "Module::Build".
163
165 David Wheeler
166
167 Questions can be asked at the test-dev <at> httpd.apache.org list. For
168 more information see: http://httpd.apache.org/test/ and
169 http://perl.apache.org/docs/general/testing/testing.html.
170
171
172
173perl v5.8.8 2006-11-19 Apache::TestMB(3)