-
Notifications
You must be signed in to change notification settings - Fork 11
/
maketest
92 lines (69 loc) · 2.29 KB
/
maketest
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
#!perl -w
#############################################################################
#
# If your platform/installation does not support make test, you can try this:
#
# perl maketest
#
#############################################################################
use strict;
use File::Spec;
use Test::Harness qw(&runtests $verbose);
$verbose = 0;
#############################################################################
# Are we in the right directory? If not, the pathname component of $0
# must be pointing to it or we wouldn't be running this script.
#
unless(-f 'MANIFEST') {
my($script_name, $script_dir) = File::Basename::fileparse($0);
if($script_dir) {
chdir($script_dir) || die "chdir($script_dir): $!";
}
}
#############################################################################
# Confirm distribution is complete (read MANIFEST file without assuming it
# has been converted to platform's native text format).
# Build up a list of test files as we go.
#
my @tests = ();
{
open(MNFST, 'MANIFEST') || die "open(MANIFEST): $!";
local($/) = undef;
foreach(split(/[\r\n]+/, <MNFST>)) {
next unless(/\S/);
my $src_file = File::Spec->catfile(split('/'));
(-f $src_file ) || die "Could not find expected file: $src_file";
push @tests, $src_file if($src_file =~ /^t\b.*\.t$/);
}
close(MNFST);
}
print "XML::Distribution appears complete\n";
#############################################################################
# Build and populate what we need of blib (the build library)
#
my $path = 'blib';
(-d $path) || mkdir($path, 0777) || die "mkdir($path): $!";
$path = File::Spec->catdir($path, 'lib');
(-d $path) || mkdir($path, 0777) || die "mkdir($path): $!";
$path = File::Spec->catdir($path, 'XML');
(-d $path) || mkdir($path, 0777) || die "mkdir($path): $!";
$path = File::Spec->catfile($path, 'Simple.pm');
unless(-f $path) {
open(MOD, 'Simple.pm') || die "open(Simple.pm): $!";
{
local($/) = undef;
my $module = <MOD>;
close(MOD);
open(MOD, ">$path") || die "open($path): $!";
print MOD $module;
close(MOD);
}
print "Created $path\n";
}
#############################################################################
# Run the tests
#
print "Running tests...\n";
unshift @INC, 'blib/lib';
@tests = @ARGV if(@ARGV);
runtests @tests;