This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Devel;:PPPort: Skip tests invalid on EBCDIC
[perl5.git] / dist / Devel-PPPort / mktests.PL
1 ################################################################################
2 #
3 #  mktests.PL -- generate test files for Devel::PPPort
4 #
5 ################################################################################
6 #
7 #  Version 3.x, Copyright (C) 2004-2013, Marcus Holland-Moritz.
8 #  Version 2.x, Copyright (C) 2001, Paul Marquess.
9 #  Version 1.x, Copyright (C) 1999, Kenneth Albanowski.
10 #
11 #  This program is free software; you can redistribute it and/or
12 #  modify it under the same terms as Perl itself.
13 #
14 ################################################################################
15
16 use strict;
17 $^W = 1;
18 require "./parts/ppptools.pl";
19
20 my $template = do { local $/; <DATA> };
21
22 generate_tests();
23
24 sub generate_tests
25 {
26   my @tests;
27   my $file;
28
29   for $file (all_files_in_dir('parts/inc')) {
30     my($testfile) = $file =~ /(\w+)\.?$/;  # VMS has a trailing dot
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       push @tests, $testfile;
53     }
54   }
55
56   return @tests;
57 }
58
59 __DATA__
60 ################################################################################
61 #
62 #            !!!!!   Do NOT edit this file directly!   !!!!!
63 #
64 #            Edit mktests.PL and/or __SOURCE__ instead.
65 #
66 #  This file was automatically generated from the definition files in the
67 #  parts/inc/ subdirectory by mktests.PL. To learn more about how all this
68 #  works, please read the F<HACKERS> file that came with this distribution.
69 #
70 ################################################################################
71
72 BEGIN {
73   if ($ENV{'PERL_CORE'}) {
74     chdir 't' if -d 't';
75     @INC = ('../lib', '../ext/Devel-PPPort/t') if -d '../lib' && -d '../ext';
76     require Config; import Config;
77     use vars '%Config';
78     if (" $Config{'extensions'} " !~ m[ Devel/PPPort ]) {
79       print "1..0 # Skip -- Perl configured without Devel::PPPort module\n";
80       exit 0;
81     }
82   }
83   else {
84     unshift @INC, 't';
85   }
86
87   sub load {
88     eval "use Test";
89     require 'testutil.pl' if $@;
90   }
91
92   if (__PLAN__) {
93     load();
94     plan(tests => __PLAN__);
95   }
96 }
97
98 use Devel::PPPort;
99 use strict;
100 $^W = 1;
101
102 package Devel::PPPort;
103 use vars '@ISA';
104 require DynaLoader;
105 @ISA = qw(DynaLoader);
106 bootstrap Devel::PPPort;
107
108 package main;
109
110 __TESTS__