source: trunk/essentials/dev-lang/perl/t/TEST@ 3400

Last change on this file since 3400 was 3181, checked in by bird, 19 years ago

perl 5.8.8

File size: 17.2 KB
Line 
1#!./perl
2
3# This is written in a peculiar style, since we're trying to avoid
4# most of the constructs we'll be testing for. (This comment is
5# probably obsolete on the avoidance side, though still currrent
6# on the peculiarity side.)
7
8$| = 1;
9
10# for testing TEST only
11#BEGIN { require '../lib/strict.pm'; strict->import() };
12#BEGIN { require '../lib/warnings.pm'; warnings->import() };
13
14# Let tests know they're running in the perl core. Useful for modules
15# which live dual lives on CPAN.
16$ENV{PERL_CORE} = 1;
17
18# remove empty elements due to insertion of empty symbols via "''p1'" syntax
19@ARGV = grep($_,@ARGV) if $^O eq 'VMS';
20our $show_elapsed_time = $ENV{HARNESS_TIMER} || 0;
21
22# Cheesy version of Getopt::Std. Maybe we should replace it with that.
23{
24 my @argv = ();
25 foreach my $idx (0..$#ARGV) {
26 push( @argv, $ARGV[$idx] ), next unless $ARGV[$idx] =~ /^-(\S+)$/;
27 $::core = 1 if $1 eq 'core';
28 $::verbose = 1 if $1 eq 'v';
29 $::torture = 1 if $1 eq 'torture';
30 $::with_utf8 = 1 if $1 eq 'utf8';
31 $::with_utf16 = 1 if $1 eq 'utf16';
32 $::bytecompile = 1 if $1 eq 'bytecompile';
33 $::compile = 1 if $1 eq 'compile';
34 $::taintwarn = 1 if $1 eq 'taintwarn';
35 $ENV{PERL_CORE_MINITEST} = 1 if $1 eq 'minitest';
36 if ($1 =~ /^deparse(,.+)?$/) {
37 $::deparse = 1;
38 $::deparse_opts = $1;
39 }
40 }
41 @ARGV = @argv;
42}
43
44chdir 't' if -f 't/TEST';
45
46die "You need to run \"make test\" first to set things up.\n"
47 unless -e 'perl' or -e 'perl.exe' or -e 'perl.pm';
48
49if ($ENV{PERL_3LOG}) { # Tru64 third(1) tool, see perlhack
50 unless (-x 'perl.third') {
51 unless (-x '../perl.third') {
52 die "You need to run \"make perl.third first.\n";
53 }
54 else {
55 print "Symlinking ../perl.third as perl.third...\n";
56 die "Failed to symlink: $!\n"
57 unless symlink("../perl.third", "perl.third");
58 die "Symlinked but no executable perl.third: $!\n"
59 unless -x 'perl.third';
60 }
61 }
62}
63
64# check leakage for embedders
65$ENV{PERL_DESTRUCT_LEVEL} = 2 unless exists $ENV{PERL_DESTRUCT_LEVEL};
66
67$ENV{EMXSHELL} = 'sh'; # For OS/2
68
69# Roll your own File::Find!
70use TestInit;
71use File::Spec;
72if ($show_elapsed_time) { require Time::HiRes }
73my $curdir = File::Spec->curdir;
74my $updir = File::Spec->updir;
75
76sub _find_tests {
77 my($dir) = @_;
78 opendir DIR, $dir or die "Trouble opening $dir: $!";
79 foreach my $f (sort { $a cmp $b } readdir DIR) {
80 next if $f eq $curdir or $f eq $updir or
81 $f =~ /^(?:CVS|RCS|SCCS|\.svn)$/;
82
83 my $fullpath = File::Spec->catfile($dir, $f);
84
85 _find_tests($fullpath) if -d $fullpath;
86 $fullpath = VMS::Filespec::unixify($fullpath) if $^O eq 'VMS';
87 push @ARGV, $fullpath if $f =~ /\.t$/;
88 }
89}
90
91sub _quote_args {
92 my ($args) = @_;
93 my $argstring = '';
94
95 foreach (split(/\s+/,$args)) {
96 # In VMS protect with doublequotes because otherwise
97 # DCL will lowercase -- unless already doublequoted.
98 $_ = q(").$_.q(") if ($^O eq 'VMS') && !/^\"/ && length($_) > 0;
99 $argstring .= ' ' . $_;
100 }
101 return $argstring;
102}
103
104sub _populate_hash {
105 return map {$_, 1} split /\s+/, $_[0];
106}
107
108unless (@ARGV) {
109 foreach my $dir (qw(base comp cmd run io op uni)) {
110 _find_tests($dir);
111 }
112 _find_tests("lib") unless $::core;
113 # Config.pm may be broken for make minitest. And this is only a refinement