Commit | Line | Data |
adfe19db |
1 | ################################################################################ |
2 | # |
3 | # mktests.PL -- generate test files for Devel::PPPort |
4 | # |
5 | ################################################################################ |
6 | # |
9132e1a3 |
7 | # $Revision: 19 $ |
adfe19db |
8 | # $Author: mhx $ |
9132e1a3 |
9 | # $Date: 2005/01/31 08:10:50 +0100 $ |
adfe19db |
10 | # |
11 | ################################################################################ |
12 | # |
9132e1a3 |
13 | # Version 3.x, Copyright (C) 2004-2005, Marcus Holland-Moritz. |
adfe19db |
14 | # Version 2.x, Copyright (C) 2001, Paul Marquess. |
15 | # Version 1.x, Copyright (C) 1999, Kenneth Albanowski. |
16 | # |
17 | # This program is free software; you can redistribute it and/or |
18 | # modify it under the same terms as Perl itself. |
19 | # |
20 | ################################################################################ |
21 | |
22 | use strict; |
23 | $^W = 1; |
24 | require "parts/ppptools.pl"; |
25 | |
26 | my $template = do { local $/; <DATA> }; |
27 | |
28 | my $file; |
29 | for $file (glob 'parts/inc/*') { |
30 | my($testfile) = $file =~ /(\w+)$/; |
31 | $testfile = "t/$testfile.t"; |
32 | |
33 | my $spec = parse_partspec($file); |
34 | my $plan = 0; |
35 | |
36 | if (exists $spec->{tests}) { |
37 | exists $spec->{OPTIONS}{tests} && |
38 | exists $spec->{OPTIONS}{tests}{plan} |
39 | or die "No plan for tests in $file\n"; |
40 | |
41 | print "generating $testfile\n"; |
42 | |
43 | my $tmpl = $template; |
44 | $tmpl =~ s/__SOURCE__/$file/mg; |
45 | $tmpl =~ s/__PLAN__/$spec->{OPTIONS}{tests}{plan}/mg; |
46 | $tmpl =~ s/^__TESTS__$/$spec->{tests}/mg; |
47 | |
48 | open FH, ">$testfile" or die "$testfile: $!\n"; |
49 | print FH $tmpl; |
50 | close FH; |
51 | } |
52 | } |
53 | |
54 | exit 0; |
55 | |
56 | __DATA__ |
57 | ################################################################################ |
58 | # |
59 | # !!!!! Do NOT edit this file directly! !!!!! |
60 | # |
61 | # Edit mktests.PL and/or __SOURCE__ instead. |
62 | # |
63 | ################################################################################ |
64 | |
65 | BEGIN { |
66 | if ($ENV{'PERL_CORE'}) { |
67 | chdir 't' if -d 't'; |
68 | @INC = ('../lib', '../ext/Devel/PPPort/t') if -d '../lib' && -d '../ext'; |
69 | require Config; import Config; |
70 | use vars '%Config'; |
a745474a |
71 | if (" $Config{'extensions'} " !~ m[ Devel/PPPort ]) { |
adfe19db |
72 | print "1..0 # Skip -- Perl configured without Devel::PPPort module\n"; |
73 | exit 0; |
74 | } |
75 | } |
76 | else { |
77 | unshift @INC, 't'; |
78 | } |
79 | |
80 | eval "use Test"; |
81 | if ($@) { |
82 | require 'testutil.pl'; |
83 | print "1..__PLAN__\n"; |
84 | } |
85 | else { |
86 | plan(tests => __PLAN__); |
87 | } |
88 | } |
89 | |
90 | use Devel::PPPort; |
91 | use strict; |
92 | $^W = 1; |
93 | |
94 | __TESTS__ |