This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Throw away uncleanable scopes when exiting a pseudo-forked process.
[perl5.git] / cpan / Devel-PPPort / mktests.PL
1 ################################################################################
2 #
3 #  mktests.PL -- generate test files for Devel::PPPort
4 #
5 ################################################################################
6 #
7 #  $Revision: 31 $
8 #  $Author: mhx $
9 #  $Date: 2009/06/11 20:53:42 +0200 $
10 #
11 ################################################################################
12 #
13 #  Version 3.x, Copyright (C) 2004-2009, 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 (all_files_in_dir('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 #  This file was automatically generated from the definition files in the
73 #  parts/inc/ subdirectory by mktests.PL. To learn more about how all this
74 #  works, please read the F<HACKERS> file that came with this distribution.
75 #
76 ################################################################################
77
78 BEGIN {
79   if ($ENV{'PERL_CORE'}) {
80     require Config; import Config;
81     use vars '%Config';
82     if (" $Config{'extensions'} " !~ m[ Devel/PPPort ]) {
83       print "1..0 # Skip -- Perl configured without Devel::PPPort module\n";
84       exit 0;
85     }
86   }
87   else {
88     unshift @INC, 't';
89   }
90
91   sub load {
92     eval "use Test";
93     require 'testutil.pl' if $@;
94   }
95
96   if (__PLAN__) {
97     load();
98     plan(tests => __PLAN__);
99   }
100 }
101
102 use Devel::PPPort;
103 use strict;
104 $^W = 1;
105
106 package Devel::PPPort;
107 use vars '@ISA';
108 require DynaLoader;
109 @ISA = qw(DynaLoader);
110 bootstrap Devel::PPPort;
111
112 package main;
113
114 __TESTS__