[cage] Update release manager guide about committing to trunk near a release, based...
[parrot.git] / t / harness
blobfb980e9f52558038b42678a89e6c1fd2840d448c
1 #!perl
2 # Copyright (C) 2001-2009, Parrot Foundation.
3 # $Id$
5 use strict;
6 use warnings;
7 use Data::Dumper;$Data::Dumper::Indent=1;
8 use lib qw( lib );
10 use Getopt::Std;
12 # need runtests from T::H, but avoid running all our parrot invocations with -w
13 use Test::Harness ();
14 undef $Test::Harness::Switches;
16 use Parrot::Harness::DefaultTests qw(
17     get_common_tests
18     @developing_tests
20 use Parrot::Harness::Options qw(
21     handle_long_options
22     get_test_prog_args
23     Usage
25 use Parrot::Harness::Smoke qw(
26     generate_html_smoke_report
27     send_archive_to_smolder
28     collect_test_environment_data
31 local @ARGV = @ARGV;
32 (my $longopts, @ARGV) = handle_long_options(@ARGV);
34 $ENV{RUNNING_MAKE_TEST} = $longopts->{running_make_test};
36 # Suck the short options into the TEST_PROG_ARGS
37 # environmental variable.
38 my %opts;
39 getopts('wgjPCSefbvdr?hO:D:', \%opts);
41 if ($opts{'?'} || $opts{h} || $longopts->{help}) {
42     Usage();
43     exit;
46 # add -D40;  merge it with any existing -D argument
47 $opts{D} = sprintf( '%x', hex(40) | (exists $opts{D} ? hex($opts{D}) : 0));
49 my $args = get_test_prog_args(
50     \%opts, $longopts->{gc_debug}, $longopts->{run_exec}
52 $ENV{TEST_PROG_ARGS} = $args;
54 my @tests;
55 if ($longopts->{code}) {
56     @tests = @developing_tests;
58 else {
59     @tests = map { glob($_) } (@ARGV
60         ? @ARGV
61         : get_common_tests( $longopts )
62     );
65 my $harness;
66 if ($longopts->{archive}) {
67     eval { require TAP::Harness::Archive };
68     if ($@) {
69         die "\n" . ('-' x 55) . "\nCould not load TAP::Harness::Archive."
70             . "\nPlease install it if you want to create TAP archives.\n"
71             . ('-' x 55) . "\n\n$@\n";
72     }
73     # for extra_properties we need TAP::Harness::Archive >= .10
74     if ($TAP::Harness::Archive::VERSION < .10) {
75         die "\n" . ('-' x 55) . "\nWe need TAP::Harness::Archive >= .10."
76             . "\nPlease install it if you want to create TAP archives.\n"
77             . ('-' x 55) . "\n";
78     }
80     my %env_data = collect_test_environment_data();
81     $harness = TAP::Harness::Archive->new(
82         {
83             verbosity        => $ENV{HARNESS_VERBOSE},
84             archive          => 'parrot_test_run.tar.gz',
85             merge            => 1,
86             extra_properties => \%env_data,
87             extra_files      => [ 'myconfig', 'config_lib.pasm' ],
88         }
89     );
90     $harness->runtests(@tests);
91     send_archive_to_smolder(%env_data) if $longopts->{send_to_smolder};
94 elsif ($longopts->{html}) {
95     generate_html_smoke_report(
96         {
97             tests => \@tests,
98             args  => $args,
99             file  => 'smoke.html',
100         }
101     );
103 else {
104     eval { require TAP::Harness };
105     if ($@) {
106         Test::Harness::runtests(@tests);
107         exit;
108     }
109     else {
110         $harness = TAP::Harness->new({
111             verbosity => $ENV{HARNESS_VERBOSE},
112             merge     => 0,
113             jobs      => $ENV{TEST_JOBS} || 1,
114             directives => 1,
115         });
116     }
117     my $results = $harness->runtests(@tests);
119     # a non-zero code stops make after test failures (RT #60116)
120     exit ( $results->all_passed() ? 0 : 1 );
123 =head1 NAME
125 t/harness - Parrot Test Harness
127 =head1 SYNOPSIS
129     % perl t/harness [options] [testfiles]
131 =head1 DESCRIPTION
133 The short command line options are:
135 =over 4
137 =item C<-w>
139 Turn warnings on.
141 =item C<-g>
143 Run the C<CGoto> core.
145 =item C<-j>
147 Alias for running with the fast core.
149 =item C<-C>
151 Run the C<CGP> core.
153 =item C<-S>
155 Run Switched.
157 =item C<-b>
159 Run bounds checking enabled.
161 =item C<-d>
163 Run with debugging enabled.
165 =item C<-f>
167 Run fast core.
169 =item C<-r>
171 compile to Parrot bytecode and then run the bytecode.
173 =item C<-O[012]>
175 Run optimized to the specified level.
177 =item C<-D[number]>
179 Pass the specified debug bits to the parrot interpreter.  Note that
180 C<-D40> (fill I, N registers with garbage) is always enabled.
181 See 'parrot --help-debug' for available flags.
183 =back
185 There are also long command line options:
187 =over 4
189 =item C<--running-make-test>
191 Some test scripts run more quickly when this is set.
193 =item C<--gc-debug>
195 Invoke parrot with '--gc-debug'.
197 =item C<--html>
199 Emit a C<smoke.html> file instead of displaying results.
201 =item C<--code-tests>
203 Run only the file metadata and basic coding standards tests.
205 =back
207 =head1 HISTORY
209 Mike Lambert stole F<t/harness> for F<languages/perl6/t/harness>.
211 Leo Toetsch stole F<languages/perl6/t/harness> for F<imcc/t/harness>.
213 Bernhard Schmalhofer merged F<imcc/t/harness> back into F<t/harness>.
215 =cut
218 # Local Variables:
219 #   mode: cperl
220 #   cperl-indent-level: 4
221 #   fill-column: 100
222 # End:
223 # vim: expandtab shiftwidth=4: