tagged release 0.6.4
[parrot.git] / t / harness
blobce550a9edec81cea21c940ed366c7c3a5123af0e
1 #!perl
2 # Copyright (C) 2001-2008, The Perl 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_default_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
29 local @ARGV = @ARGV;
30 (my $longopts, @ARGV) = handle_long_options(@ARGV);
32 $ENV{RUNNING_MAKE_TEST} = $longopts->{running_make_test};
34 # Suck the short options into the TEST_PROG_ARGS 
35 # environmental variable.
36 my %opts;
37 getopts('wgjPCSefbvdr?hO:D:', \%opts);
39 if ($opts{'?'} || $opts{h} || $longopts->{help}) {
40     Usage();
41     exit;
44 # add -D40;  merge it with any existing -D argument
45 $opts{D} = sprintf( '%x', hex(40) | (exists $opts{D} ? hex($opts{D}) : 0));
47 my $args = get_test_prog_args(
48     \%opts, $longopts->{gc_debug}, $longopts->{run_exec}
50 $ENV{TEST_PROG_ARGS} = $args;
52 # now build the list of tests to run, either from the command
53 # line or from @default tests
54 my @default_tests = get_default_tests(
55     $longopts->{core_tests_only},
56     $longopts->{runcore_tests_only}
59 my @tests;
60 if ($longopts->{code}) {
61     @tests = @developing_tests;
62 } else {
63     @tests = map { glob($_) } (@ARGV ? @ARGV : @default_tests);
66 if ($longopts->{html}) {
67     generate_html_smoke_report(
68         {
69             tests => \@tests,
70             args  => $args,
71             file  => 'smoke.html',
72         }
73     );
74 } else {
75     my $harness;
76     if ($longopts->{archive}) {
77         eval { require TAP::Harness::Archive };
78         if ($@) {
79             die "\n" . ('-' x 55) . "\nCould not load TAP::Harness::Archive."
80                 . "\nPlease install it if you want to create TAP archives.\n"
81                 . ('-' x 55) . "\n\n$@\n";
82         }
83         $harness = TAP::Harness::Archive->new(
84             {
85                 verbosity => $ENV{HARNESS_VERBOSE},
86                 archive   => 'parrot_test_run.tar.gz',
87                 merge     => 1,
88             }
89         );
90     } else {
91         eval { require TAP::Harness };
92         if ($@) {
93             Test::Harness::runtests(@tests);
94             exit;
95         }
96         else {
97             $harness = TAP::Harness->new({
98                 verbosity => $ENV{HARNESS_VERBOSE}, merge => 0
99             });
100         }
101     }
103     $harness->runtests(@tests);
105     if ($longopts->{send_to_smolder}) {
106         send_archive_to_smolder();
107     }
110 =head1 NAME
112 t/harness - Parrot Test Harness
114 =head1 SYNOPSIS
116     % perl t/harness [options] [testfiles]
118 =head1 DESCRIPTION
120 The short command line options are:
122 =over 4
124 =item C<-w>
126 Turn warnings on.
128 =item C<-g>
130 Run the C<CGoto> core.
132 =item C<-j>
134 Run with JIT enabled.
136 =item C<-C>
138 Run the C<CGP> core.
140 =item C<-S>
142 Run Switched.
144 =item C<-b>
146 Run bounds checking enabled.
148 =item C<-d>
150 Run with debugging enabled.
152 =item C<-f>
154 Run fast core.
156 =item C<-r>
158 compile to Parrot bytecode and then run the bytecode.
160 =item C<-O[012]>
162 Run optimized to the specified level.
164 =item C<-D[number]>
166 Pass the specified debug bits to the parrot interpreter.  Note that 
167 C<-D40> (fill I, N registers with garbage) is always enabled.  
168 See 'parrot --help-debug' for available flags.
170 =back
172 There are also long command line options:
174 =over 4
176 =item C<--running-make-test>
178 Some test scripts run more quickly when this is set.
180 =item C<--gc-debug>
182 Invoke parrot with '--gc-debug'.
184 =item C<--html>
186 Emit a C<smoke.html> file instead of displaying results.
188 =item C<--code-tests>
190 Run only the file metadata and basic coding standards tests.
192 =back
194 =head1 HISTORY
196 Mike Lambert stole F<t/harness> for F<languages/perl6/t/harness>.
198 Leo Toetsch stole F<languages/perl6/t/harness> for F<imcc/t/harness>.
200 Bernhard Schmalhofer merged F<imcc/t/harness> back into F<t/harness>.
202 =cut
205 # Local Variables:
206 #   mode: cperl
207 #   cperl-indent-level: 4
208 #   fill-column: 100
209 # End:
210 # vim: expandtab shiftwidth=4: