[TT# 1592][t] Improve test for open opcode delegation. All tests in the file pass...
[parrot.git] / t / harness
blob85da76c2525b8fc3b93158c61fbe11c969fcf858
1 #!perl
2 # Copyright (C) 2001-2009, Parrot Foundation.
3 # $Id$
5 use strict;
6 use warnings;
7 use lib qw( lib );
9 use Getopt::Std;
11 # need runtests from T::H, but avoid running all our parrot invocations with -w
12 use Test::Harness ();
13 undef $Test::Harness::Switches;
15 use Parrot::Harness::DefaultTests qw(
16     get_common_tests
17     @developing_tests
19 use Parrot::Harness::Options qw(
20     handle_long_options
21     get_test_prog_args
22     Usage
24 use Parrot::Harness::Smoke qw(
25     generate_html_smoke_report
26     send_archive_to_smolder
27     collect_test_environment_data
30 local @ARGV = @ARGV;
31 (my $longopts, @ARGV) = handle_long_options(@ARGV);
33 # Suck the short options into the TEST_PROG_ARGS
34 # environmental variable.
35 my %opts;
36 getopts('wgGjPCSefbvdr?hO:D:', \%opts);
38 if ($opts{'?'} || $opts{h} || $longopts->{help}) {
39     Usage();
40     exit;
43 # add -D40;  merge it with any existing -D argument
44 $opts{D} = sprintf( '%x', hex(40) | (exists $opts{D} ? hex($opts{D}) : 0));
46 my $args = get_test_prog_args(
47     \%opts, $longopts->{gc_debug}, $longopts->{run_exec}
49 $ENV{TEST_PROG_ARGS} = $args;
51 my @tests;
52 if ($longopts->{code}) {
53     @tests = @developing_tests;
55 else {
56     @tests = map { glob($_) } (@ARGV
57         ? @ARGV
58         : get_common_tests( $longopts )
59     );
62 my $harness;
63 if ($longopts->{archive}) {
64     eval { require TAP::Harness::Archive };
65     if ($@) {
66         die "\n" . ('-' x 55) . "\nCould not load TAP::Harness::Archive."
67             . "\nPlease install it if you want to create TAP archives.\n"
68             . ('-' x 55) . "\n\n$@\n";
69     }
70     # for extra_properties we need TAP::Harness::Archive >= .10
71     if ($TAP::Harness::Archive::VERSION < .10) {
72         die "\n" . ('-' x 55) . "\nWe need TAP::Harness::Archive >= .10."
73             . "\nPlease install it if you want to create TAP archives.\n"
74             . ('-' x 55) . "\n";
75     }
77     my %env_data = collect_test_environment_data();
78     $harness = TAP::Harness::Archive->new(
79         {
80             verbosity        => $ENV{HARNESS_VERBOSE},
81             archive          => 'parrot_test_run.tar.gz',
82             merge            => 1,
83             extra_properties => \%env_data,
84             extra_files      => [ 'myconfig', 'config_lib.pir' ],
85         }
86     );
87     $harness->runtests(@tests);
88     send_archive_to_smolder(%env_data) if $longopts->{send_to_smolder};
91 elsif ($longopts->{html}) {
92     generate_html_smoke_report(
93         {
94             tests => \@tests,
95             args  => $args,
96             file  => 'smoke.html',
97         }
98     );
100 else {
101     eval { require TAP::Harness };
102     if ($@) {
103         Test::Harness::runtests(@tests);
104         exit;
105     }
106     else {
107         $harness = TAP::Harness->new({
108             verbosity => $ENV{HARNESS_VERBOSE},
109             merge     => 0,
110             jobs      => $ENV{TEST_JOBS} || 1,
111             directives => 1,
112         });
113     }
114     my $results = $harness->runtests(@tests);
116     exit ( $results->all_passed() ? 0 : 1 );
119 =head1 NAME
121 t/harness - Parrot Test Harness
123 =head1 SYNOPSIS
125     % perl t/harness [options] [testfiles]
127 =head1 DESCRIPTION
129 The short command line options are:
131 =over 4
133 =item C<-w>
135 Turn warnings on.
137 =item C<-G>
139 Run the C<GCDebug> core.
141 =item C<-j>
143 Alias for running with the fast core.
145 =item C<-b>
147 Run bounds checking enabled.
149 =item C<-d>
151 Run with debugging enabled.
153 =item C<-f>
155 Run fast core.
157 =item C<-r>
159 compile to Parrot bytecode and then run the bytecode.
161 =item C<-O[012]>
163 Run optimized to the specified level.
165 =item C<-D[number]>
167 Pass the specified debug bits to the parrot interpreter.  Note that
168 C<-D40> (fill I, N registers with garbage) is always enabled.
169 See 'parrot --help-debug' for available flags.
171 =back
173 There are also long command line options:
175 =over 4
177 =item C<--gc-debug>
179 Invoke parrot with '--gc-debug'.
181 =item C<--html>
183 Emit a C<smoke.html> file instead of displaying results.
185 =item C<--code-tests>
187 Run only the file metadata and basic coding standards tests.
189 =back
191 =head1 HISTORY
193 Mike Lambert stole F<t/harness> for F<languages/perl6/t/harness>.
195 Leo Toetsch stole F<languages/perl6/t/harness> for F<imcc/t/harness>.
197 Bernhard Schmalhofer merged F<imcc/t/harness> back into F<t/harness>.
199 =cut
202 # Local Variables:
203 #   mode: cperl
204 #   cperl-indent-level: 4
205 #   fill-column: 100
206 # End:
207 # vim: expandtab shiftwidth=4: