File: mktests.PL

package info (click to toggle)
perl 5.24.1-3+deb9u5
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 103,716 kB
  • sloc: perl: 559,611; ansic: 293,886; sh: 67,316; pascal: 7,632; cpp: 3,895; makefile: 2,436; xml: 2,410; yacc: 989; sed: 6; lisp: 1
file content (110 lines) | stat: -rw-r--r-- 2,720 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
################################################################################
#
#  mktests.PL -- generate test files for Devel::PPPort
#
################################################################################
#
#  Version 3.x, Copyright (C) 2004-2013, Marcus Holland-Moritz.
#  Version 2.x, Copyright (C) 2001, Paul Marquess.
#  Version 1.x, Copyright (C) 1999, Kenneth Albanowski.
#
#  This program is free software; you can redistribute it and/or
#  modify it under the same terms as Perl itself.
#
################################################################################

use strict;
$^W = 1;
require "parts/ppptools.pl";

my $template = do { local $/; <DATA> };

generate_tests();

sub generate_tests
{
  my @tests;
  my $file;

  for $file (all_files_in_dir('parts/inc')) {
    my($testfile) = $file =~ /(\w+)\.?$/;  # VMS has a trailing dot
    $testfile = "t/$testfile.t";

    my $spec = parse_partspec($file);
    my $plan = 0;

    if (exists $spec->{tests}) {
      exists $spec->{OPTIONS}{tests} &&
      exists $spec->{OPTIONS}{tests}{plan}
          or die "No plan for tests in $file\n";

      print "generating $testfile\n";

      my $tmpl = $template;
      $tmpl =~ s/__SOURCE__/$file/mg;
      $tmpl =~ s/__PLAN__/$spec->{OPTIONS}{tests}{plan}/mg;
      $tmpl =~ s/^__TESTS__$/$spec->{tests}/mg;

      open FH, ">$testfile" or die "$testfile: $!\n";
      print FH $tmpl;
      close FH;

      push @tests, $testfile;
    }
  }

  return @tests;
}

__DATA__
################################################################################
#
#            !!!!!   Do NOT edit this file directly!   !!!!!
#
#            Edit mktests.PL and/or __SOURCE__ instead.
#
#  This file was automatically generated from the definition files in the
#  parts/inc/ subdirectory by mktests.PL. To learn more about how all this
#  works, please read the F<HACKERS> file that came with this distribution.
#
################################################################################

BEGIN {
  if ($ENV{'PERL_CORE'}) {
    chdir 't' if -d 't';
    @INC = ('../lib', '../ext/Devel-PPPort/t') if -d '../lib' && -d '../ext';
    require Config; import Config;
    use vars '%Config';
    if (" $Config{'extensions'} " !~ m[ Devel/PPPort ]) {
      print "1..0 # Skip -- Perl configured without Devel::PPPort module\n";
      exit 0;
    }
  }
  else {
    unshift @INC, 't';
  }

  sub load {
    eval "use Test";
    require 'testutil.pl' if $@;
  }

  if (__PLAN__) {
    load();
    plan(tests => __PLAN__);
  }
}

use Devel::PPPort;
use strict;
$^W = 1;

package Devel::PPPort;
use vars '@ISA';
require DynaLoader;
@ISA = qw(DynaLoader);
bootstrap Devel::PPPort;

package main;

__TESTS__