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
16use strict;
17BEGIN { $^W = 1; }
18require "./parts/ppptools.pl";
19
20my $template = do { local $/; <DATA> };
21
22generate_tests();
23
24sub 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      my $canonfile = $file;
45      $canonfile =~ tr!\\!/!; # MSWin32 use backslashes
46      $tmpl =~ s/__SOURCE__/$canonfile/mg;
47      $tmpl =~ s/__PLAN__/$spec->{OPTIONS}{tests}{plan}/mg;
48      $tmpl =~ s/^__TESTS__$/$spec->{tests}/mg;
49
50      open FH, ">$testfile" or die "$testfile: $!\n";
51      binmode FH;
52      print FH $tmpl;
53      close FH;
54
55      push @tests, $testfile;
56    }
57  }
58
59  return @tests;
60}
61
62__DATA__
63################################################################################
64#
65#            !!!!!   Do NOT edit this file directly!   !!!!!
66#
67#            Edit mktests.PL and/or __SOURCE__ instead.
68#
69#  This file was automatically generated from the definition files in the
70#  parts/inc/ subdirectory by mktests.PL. To learn more about how all this
71#  works, please read the F<HACKERS> file that came with this distribution.
72#
73################################################################################
74
75use FindBin ();
76
77BEGIN {
78  if ($ENV{'PERL_CORE'}) {
79    chdir 't' if -d 't';
80    unshift @INC, '../lib' if -d '../lib' && -d '../ext';
81    require Config; Config->import;
82    use vars '%Config';
83    if (" $Config{'extensions'} " !~ m[ Devel/PPPort ]) {
84      print "1..0 # Skip -- Perl configured without Devel::PPPort module\n";
85      exit 0;
86    }
87  }
88
89  use lib "$FindBin::Bin";
90  use lib "$FindBin::Bin/../parts/inc";
91
92  die qq[Cannot find "$FindBin::Bin/../parts/inc"] unless -d "$FindBin::Bin/../parts/inc";
93
94  sub load {
95    require 'testutil.pl';
96    require 'inctools';
97  }
98
99  if (__PLAN__) {
100    load();
101    plan(tests => __PLAN__);
102  }
103}
104
105use Devel::PPPort;
106use strict;
107BEGIN { $^W = 1; }
108
109package Devel::PPPort;
110use vars '@ISA';
111require DynaLoader;
112@ISA = qw(DynaLoader);
113Devel::PPPort->bootstrap;
114
115package main;
116
117__TESTS__
118