Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 160 lines (131 sloc) 4.348 kb
d7e6ed9 @chromatic Created Parrot::Test::Harness.
chromatic authored
1 #! perl
2
af9452e @petdance use lexical filehandles, not global; Check for .git dirs as skippable…
petdance authored
3 # note: Due to a limitation in Getopt::Long options that should be passed
fa9d590 @pmichaud [rakudo]:
pmichaud authored
4 # through to fudgeall have to come after all other options
5
af9452e @petdance use lexical filehandles, not global; Check for .git dirs as skippable…
petdance authored
6 use strict;
7 use warnings;
8
222b3ea @audreyt * copy all Pugs's sanity tests into languages/perl6/ harness.
audreyt authored
9 use FindBin;
cac6628 @particle [rakudo]: filter tests through fudging utils -- TimToady++
particle authored
10 use File::Spec;
fa9d590 @pmichaud [rakudo]:
pmichaud authored
11 use Getopt::Long qw(:config pass_through);
3b2529b @shlomif Add a --help/-h flag to t/harness.
shlomif authored
12 use Pod::Usage;
cac6628 @particle [rakudo]: filter tests through fudging utils -- TimToady++
particle authored
13
85e5b9c @jnthn Twiddle the test harness patch to perl6 on Win32 so env.t works under…
jnthn authored
14 my $slash = $^O eq 'MSWin32' ? '\\' : '/';
15 $ENV{'HARNESS_PERL'} = ".${slash}perl6";
b09c6f8 @moritz remove . from default @*INC
moritz authored
16 my $path_sep = $^O eq 'MSWin32' ? ';' : ':';
17 $ENV{'PERL6LIB'} = join $path_sep, qw/ lib . /;
5944501 @pmichaud Updated harness that doesn't rely on Parrot::Test::Harness.
pmichaud authored
18 use Test::Harness;
19 $Test::Harness::switches = '';
fb66ff6 @moritz [t/harness] fix testing if not checked out as languages/rakudo
moritz authored
20
fa9d590 @pmichaud [rakudo]:
pmichaud authored
21 GetOptions(
5944501 @pmichaud Updated harness that doesn't rely on Parrot::Test::Harness.
pmichaud authored
22 'tests-from-file=s' => \my $list_file,
23 'fudge' => \my $do_fudge,
023bb60 @pmichaud Re-enable --verbosity option in t/harness (RT #63566).
pmichaud authored
24 'verbosity=i' => \$Test::Harness::verbose,
edf0072 @moritz default to one test job at a time, due to complaints from avar++ and …
moritz authored
25 'jobs:1' => \my $jobs,
07af82b @pmichaud Update the harness to recognize icu flags on spectest.data,
pmichaud authored
26 'icu:1' => \my $do_icu,
5c75d0c @pmichaud Add 'quicktest' target, omits testfiles that have been marked with "#…
pmichaud authored
27 'long:1' => \my $do_long,
894e793 @pmichaud Fix bug with --long and --stress option handling.
pmichaud authored
28 'stress:1' => \my $do_stress,
2c40a5b @moritz support smolder reports in harness and Makefile. Patch courtesy by jd…
moritz authored
29 'archive=s' => \my $archive,
30 'parrot_revision=s' => \my $parrot_revision,
3b2529b @shlomif Add a --help/-h flag to t/harness.
shlomif authored
31 'help|h' => sub { pod2usage(1); },
32 ) or pod2usage(2);
ea94175 @moritz re-enable parallel testing in t/harness again
moritz authored
33
894e793 @pmichaud Fix bug with --long and --stress option handling.
pmichaud authored
34 $do_long = 1 unless defined $do_long;
35 $do_stress = 0 unless defined $do_stress;
36
fa9d590 @pmichaud [rakudo]:
pmichaud authored
37 my @pass_through_options = grep m/^--?[^-]/, @ARGV;
38 my @files = grep m/^[^-]/, @ARGV;
39
65382bc @pmichaud [rakudo]: Allow single-test make targets, refactor fudge/harness.
pmichaud authored
40 if ($list_file) {
fdf3e70 @particle [rakudo] [perl #54988] [PATCH] enhance t/harness (again)
particle authored
41 open(my $f, '<', $list_file)
42 or die "Can't open file '$list_file' for reading: $!";
5944501 @pmichaud Updated harness that doesn't rely on Parrot::Test::Harness.
pmichaud authored
43 while (<$f>) {
fa9d590 @pmichaud [rakudo]:
pmichaud authored
44 next if m/^\s*#/;
45 next unless m/\S/;
b74a4dd @moritz [t/harness] be more permissive with leading and trailing whiteapces i…
moritz authored
46 s/^\s+//;
47 s/\s+\z//;
07af82b @pmichaud Update the harness to recognize icu flags on spectest.data,
pmichaud authored
48 my ($fn, $fudgespec) = split /\s+#\s*/;
0ba07fa @pmichaud Refactor 'make stresstest' to draw from t/spectest.data, and eliminat…
pmichaud authored
49 if ($fudgespec) {
50 next if ($fudgespec =~ m/icu/) && !$do_icu;
51 next if ($fudgespec =~ m/long/) && !$do_long;
52 next if ($fudgespec =~ m/stress/) && !$do_stress;
53 }
40e27cf @particle [rakudo] allow leading 't/spec/' path in filenames specified in test …
particle authored
54 $fn = "t/spec/$fn" unless $fn =~ m/^t\Q$slash\Espec\Q$slash\E/;
5944501 @pmichaud Updated harness that doesn't rely on Parrot::Test::Harness.
pmichaud authored
55 $fn =~ s{/}{$slash}g;
56 if ( -r $fn ) {
65382bc @pmichaud [rakudo]: Allow single-test make targets, refactor fudge/harness.
pmichaud authored
57 push @files, $fn;
9c3d19d @moritz [rakudo] t/harness warns on no-existiing test files.
moritz authored
58 } else {
59 warn "Missing test file: $fn\n";
60 }
8702168 @particle [rakudo] generalize command-line argument processing in the test harness
particle authored
61 }
af9452e @petdance use lexical filehandles, not global; Check for .git dirs as skippable…
petdance authored
62 close $f or die $!;
fa9d590 @pmichaud [rakudo]:
pmichaud authored
63 }
8702168 @particle [rakudo] generalize command-line argument processing in the test harness
particle authored
64
65382bc @pmichaud [rakudo]: Allow single-test make targets, refactor fudge/harness.
pmichaud authored
65 my @tfiles = map { all_in($_) } sort @files;
fdf3e70 @particle [rakudo] [perl #54988] [PATCH] enhance t/harness (again)
particle authored
66
65382bc @pmichaud [rakudo]: Allow single-test make targets, refactor fudge/harness.
pmichaud authored
67 if ($do_fudge) {
68 @tfiles = fudge(@tfiles);
fa9d590 @pmichaud [rakudo]:
pmichaud authored
69 }
70
2c40a5b @moritz support smolder reports in harness and Makefile. Patch courtesy by jd…
moritz authored
71 my $tap_harness_class = 'TAP::Harness';
72 $tap_harness_class .= '::Archive' if $archive;
73
74 my $extra_properties;
a61b17f @moritz [t/harness] only provide extra_properties when we use ::Archive
moritz authored
75 if ($archive) {
76 $extra_properties->{'Parrot Revision'} = $parrot_revision
77 if $parrot_revision;
78 $extra_properties->{'Submitter'} = $ENV{SMOLDER_SUBMITTER}
79 if $ENV{SMOLDER_SUBMITTER};
80 }
2c40a5b @moritz support smolder reports in harness and Makefile. Patch courtesy by jd…
moritz authored
81
82 if (eval "require $tap_harness_class;") {
ea94175 @moritz re-enable parallel testing in t/harness again
moritz authored
83 my %harness_options = (
068cad4 @moritz [t/harness] use backslash on windows
moritz authored
84 exec => [$ENV{HARNESS_PERL}],
eda5f51 @pmichaud Instruct the harness to ignore exit code errors for now.
pmichaud authored
85 verbosity => 0+$Test::Harness::verbose,
b3c8d37 @perlpilot Update test harness and Makefile
perlpilot authored
86 jobs => $jobs || $ENV{TEST_JOBS} || 1,
eda5f51 @pmichaud Instruct the harness to ignore exit code errors for now.
pmichaud authored
87 ignore_exit => 1,
2c40a5b @moritz support smolder reports in harness and Makefile. Patch courtesy by jd…
moritz authored
88 merge => 1,
89 $archive ? ( archive => $archive ) : (),
90 $extra_properties ? ( extra_properties => $extra_properties ) : (),
ea94175 @moritz re-enable parallel testing in t/harness again
moritz authored
91 );
2c40a5b @moritz support smolder reports in harness and Makefile. Patch courtesy by jd…
moritz authored
92 $tap_harness_class->new( \%harness_options )->runtests(@tfiles);
ea94175 @moritz re-enable parallel testing in t/harness again
moritz authored
93 }
33788e8 @moritz die on spectest_smolder if TAP::Harness::Archive cannot be loaded
moritz authored
94 elsif ($archive) {
95 die "Can't load $tap_harness_class, which is needed for smolder submissions: $@";
96 }
ea94175 @moritz re-enable parallel testing in t/harness again
moritz authored
97 else {
98 runtests(@tfiles);
99 }
fdf3e70 @particle [rakudo] [perl #54988] [PATCH] enhance t/harness (again)
particle authored
100
fa9d590 @pmichaud [rakudo]:
pmichaud authored
101 # adapted to return only files ending in '.t'
102 sub all_in {
103 my $start = shift;
104
fdf3e70 @particle [rakudo] [perl #54988] [PATCH] enhance t/harness (again)
particle authored
105 return $start unless -d $start;
106
af9452e @petdance use lexical filehandles, not global; Check for .git dirs as skippable…
petdance authored
107 my @skip = ( File::Spec->updir, File::Spec->curdir, qw( .svn CVS .git ) );
108 my %skip = map {($_,1)} @skip;
109
fa9d590 @pmichaud [rakudo]:
pmichaud authored
110 my @hits = ();
111
af9452e @petdance use lexical filehandles, not global; Check for .git dirs as skippable…
petdance authored
112 if ( opendir( my $dh, $start ) ) {
113 my @files = sort readdir $dh;
114 closedir $dh or die $!;
fa9d590 @pmichaud [rakudo]:
pmichaud authored
115 for my $file ( @files ) {
af9452e @petdance use lexical filehandles, not global; Check for .git dirs as skippable…
petdance authored
116 next if $skip{$file};
fa9d590 @pmichaud [rakudo]:
pmichaud authored
117
118 my $currfile = File::Spec->catfile( $start, $file );
119 if ( -d $currfile ) {
1951708 @moritz [t/harness] remove variable $recurse
moritz authored
120 push( @hits, all_in( $currfile ) );
fa9d590 @pmichaud [rakudo]:
pmichaud authored
121 } else {
122 push( @hits, $currfile ) if $currfile =~ /\.t$/;
cac6628 @particle [rakudo]: filter tests through fudging utils -- TimToady++
particle authored
123 }
124 }
fa9d590 @pmichaud [rakudo]:
pmichaud authored
125 } else {
126 warn "$start: $!\n";
cac6628 @particle [rakudo]: filter tests through fudging utils -- TimToady++
particle authored
127 }
128
fa9d590 @pmichaud [rakudo]:
pmichaud authored
129 return @hits;
130 }
cf9a773 @particle [perl6]:
particle authored
131
5944501 @pmichaud Updated harness that doesn't rely on Parrot::Test::Harness.
pmichaud authored
132 sub fudge {
133 my $impl = 'rakudo';
af9452e @petdance use lexical filehandles, not global; Check for .git dirs as skippable…
petdance authored
134 my $cmd = join ' ', $^X, 't/spec/fudgeall',
5944501 @pmichaud Updated harness that doesn't rely on Parrot::Test::Harness.
pmichaud authored
135 @pass_through_options, $impl, @_;
136 return split ' ', `$cmd`;
137 }
3b2529b @shlomif Add a --help/-h flag to t/harness.
shlomif authored
138
139 =head1 NAME
140
a0e9d2f @kyleha [t/harness] spelling fix
kyleha authored
141 t/harness - run the harness tests for Rakudo.
3b2529b @shlomif Add a --help/-h flag to t/harness.
shlomif authored
142
143 =head1 SYNOPSIS
144
145 t/harness [options] [files]
146
147 Options:
148
149 --help / -h - display the help message.
150 --tests-from-file=[filename] - get the tests from the filename.
151 --fudge - fudge (?)
152 --verbosity=[level] - set the verbosity level.
153 --jobs - number of jobs.
154 --icu - do icu.
155 --long - do long.
156 --stress - perform the stress tests/
157 --archive=[archive] - write to an archive.
158 --parrot_revision=[rev] - test with Parrot revision.
159
Something went wrong with that request. Please try again.