Upgrade to Devel::PPPort 3.08_06
[p5sagit/p5-mst-13.2.git] / ext / Devel / PPPort / mktests.PL
1 ################################################################################
2 #
3 #  mktests.PL -- generate test files for Devel::PPPort
4 #
5 ################################################################################
6 #
7 #  $Revision: 25 $
8 #  $Author: mhx $
9 #  $Date: 2006/06/25 06:30:35 +0200 $
10 #
11 ################################################################################
12 #
13 #  Version 3.x, Copyright (C) 2004-2006, Marcus Holland-Moritz.
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 generate_tests();
29
30 sub generate_tests
31 {
32   my @tests;
33   my $file;
34
35   for $file (glob 'parts/inc/*') {
36     my($testfile) = $file =~ /(\w+)\.?$/;  # VMS has a trailing dot
37     $testfile = "t/$testfile.t";
38   
39     my $spec = parse_partspec($file);
40     my $plan = 0;
41   
42     if (exists $spec->{tests}) {
43       exists $spec->{OPTIONS}{tests} &&
44       exists $spec->{OPTIONS}{tests}{plan}
45           or die "No plan for tests in $file\n";
46   
47       print "generating $testfile\n";
48   
49       my $tmpl = $template;
50       $tmpl =~ s/__SOURCE__/$file/mg;
51       $tmpl =~ s/__PLAN__/$spec->{OPTIONS}{tests}{plan}/mg;
52       $tmpl =~ s/^__TESTS__$/$spec->{tests}/mg;
53   
54       open FH, ">$testfile" or die "$testfile: $!\n";
55       print FH $tmpl;
56       close FH;
57   
58       push @tests, $testfile;
59     }
60   }
61   
62   return @tests;
63 }
64
65 __DATA__
66 ################################################################################
67 #
68 #            !!!!!   Do NOT edit this file directly!   !!!!!
69 #
70 #            Edit mktests.PL and/or __SOURCE__ instead.
71 #
72 ################################################################################
73
74 BEGIN {
75   if ($ENV{'PERL_CORE'}) {
76     chdir 't' if -d 't';
77     @INC = ('../lib', '../ext/Devel/PPPort/t') if -d '../lib' && -d '../ext';
78     require Config; import Config;
79     use vars '%Config';
80     if (" $Config{'extensions'} " !~ m[ Devel/PPPort ]) {
81       print "1..0 # Skip -- Perl configured without Devel::PPPort module\n";
82       exit 0;
83     }
84   }
85   else {
86     unshift @INC, 't';
87   }
88
89   sub load {
90     eval "use Test";
91     require 'testutil.pl' if $@;
92   }
93
94   if (__PLAN__) {
95     load();
96     plan(tests => __PLAN__);
97   }
98 }
99
100 use Devel::PPPort;
101 use strict;
102 $^W = 1;
103
104 package Devel::PPPort;
105 use vars '@ISA';
106 require DynaLoader;
107 @ISA = qw(DynaLoader);
108 bootstrap Devel::PPPort;
109
110 package main;
111
112 __TESTS__