4 # Copyright (c) 1996-2003 Jesse Vincent <jesse@bestpractical.com>
6 # (Except where explictly superceded by other copyright notices)
8 # This work is made available to you under the terms of Version 2 of
9 # the GNU General Public License. A copy of that license should have
10 # been provided with this software, but in any event can be snarfed
13 # This work is distributed in the hope that it will be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 # General Public License for more details.
18 # Unless otherwise specified, all modifications, corrections or
19 # extensions to this work which alter its source code become the
20 # property of Best Practical Solutions, LLC when submitted for
21 # inclusion in the work.
27 use vars qw($VERSION);
37 extract_pod_tests - RT-specific variant of pod2tests
41 pod2test [-Mmodule] [input [output]]
45 B<pod2test> is a front-end for Test::Inline. It generates the
46 "Bodies" of MakeMaker style .t testing files from embedded tests and
49 If output is not specified, the resulting .t file will go to STDOUT.
50 Otherwise, it will go to the given output file. If input is not
51 given, it will draw from STDIN.
53 If the given file contains no tests or code examples, no output will
54 be given and no output file will be created.
58 my($infile, $outfile) = @ARGV;
62 if( defined $infile ) {
64 open($infh, $infile) or
65 die "Can't open the POD file $infile: $!";
72 ( my $test = $infile ) =~ s/\.(pm|pod)$//;
77 $outfile = "lib/t/autogen/autogen-$test.t";
81 my $p = Pod::Tests->new;
84 # XXX Hack to put the filename into the #line directive
85 $p->{file} = $infile || '';
87 my @tests = $p->build_tests($p->tests);
88 my @examples = $p->build_examples($p->examples);
90 exit unless @tests or @examples;
93 if( defined $outfile) {
95 open($outfh, ">$outfile") or
96 die "Can't open the test file $outfile: $!";
104 foreach my $test (@tests, @examples) {
105 print $outfh "$test\n";
112 =head1 BUGS and CAVEATS
114 This is a very simple rough cut. It only does very rudimentary tests
121 Based on pod2tests by Michael G Schwern <schwern@pobox.com>