Debian lenny version packages
[pkg-perl] / deb-src / libtest-harness-perl / libtest-harness-perl-3.12 / t / state.t
1 #!/usr/bin/perl -w
2
3 BEGIN {
4     if ( $ENV{PERL_CORE} ) {
5         chdir 't';
6         @INC = '../lib';
7     }
8     else {
9         unshift @INC, 't/lib';
10     }
11 }
12
13 use strict;
14 use Test::More;
15 use App::Prove::State;
16
17 sub mn {
18     my $pfx = $ENV{PERL_CORE} ? '../lib/Test/Harness/' : '';
19     return map {"$pfx$_"} @_;
20 }
21
22 my @schedule = (
23     {   options        => 'all',
24         get_tests_args => [],
25         expect         => [
26             't/compat/env.t',
27             't/compat/failure.t',
28             't/compat/inc_taint.t',
29             't/compat/version.t',
30             't/source.t',
31             't/yamlish-writer.t',
32         ],
33     },
34     {   options        => 'failed',
35         get_tests_args => [],
36         expect         => [
37             't/compat/inc_taint.t',
38             't/compat/version.t',
39         ],
40     },
41     {   options        => 'passed',
42         get_tests_args => [],
43         expect         => [
44             't/compat/env.t',
45             't/compat/failure.t',
46             't/source.t',
47             't/yamlish-writer.t',
48         ],
49     },
50     {   options        => 'last',
51         get_tests_args => [],
52         expect         => [
53             't/compat/env.t',
54             't/compat/failure.t',
55             't/compat/inc_taint.t',
56             't/compat/version.t',
57             't/source.t',
58         ],
59     },
60     {   options        => 'todo',
61         get_tests_args => [],
62         expect         => [
63             't/compat/version.t',
64             't/compat/failure.t',
65         ],
66
67     },
68     {   options        => 'hot',
69         get_tests_args => [],
70         expect         => [
71             't/compat/version.t',
72             't/yamlish-writer.t',
73             't/compat/env.t',
74         ],
75     },
76     {   options        => 'adrian',
77         get_tests_args => [],
78         expect         => [
79             't/compat/version.t',
80             't/yamlish-writer.t',
81             't/compat/env.t',
82             't/compat/failure.t',
83             't/compat/inc_taint.t',
84             't/source.t',
85         ],
86     },
87     {   options        => 'failed,passed',
88         get_tests_args => [],
89         expect         => [
90             't/compat/inc_taint.t',
91             't/compat/version.t',
92             't/compat/env.t',
93             't/compat/failure.t',
94             't/source.t',
95             't/yamlish-writer.t',
96         ],
97     },
98     {   options        => [ 'failed', 'passed' ],
99         get_tests_args => [],
100         expect         => [
101             't/compat/inc_taint.t',
102             't/compat/version.t',
103             't/compat/env.t',
104             't/compat/failure.t',
105             't/source.t',
106             't/yamlish-writer.t',
107         ],
108     },
109     {   options        => 'slow',
110         get_tests_args => [],
111         expect         => [
112             't/yamlish-writer.t',
113             't/compat/env.t',
114             't/compat/inc_taint.t',
115             't/compat/version.t',
116             't/compat/failure.t',
117             't/source.t',
118         ],
119     },
120     {   options        => 'fast',
121         get_tests_args => [],
122         expect         => [
123             't/source.t',
124             't/compat/failure.t',
125             't/compat/version.t',
126             't/compat/inc_taint.t',
127             't/compat/env.t',
128             't/yamlish-writer.t',
129         ],
130     },
131     {   options        => 'old',
132         get_tests_args => [],
133         expect         => [
134             't/source.t',
135             't/compat/inc_taint.t',
136             't/compat/version.t',
137             't/yamlish-writer.t',
138             't/compat/failure.t',
139             't/compat/env.t',
140         ],
141     },
142     {   options        => 'new',
143         get_tests_args => [],
144         expect         => [
145             't/compat/env.t',
146             't/compat/failure.t',
147             't/yamlish-writer.t',
148             't/compat/version.t',
149             't/compat/inc_taint.t',
150             't/source.t',
151         ],
152     },
153 );
154
155 plan tests => @schedule * 2;
156
157 for my $test (@schedule) {
158     my $state = App::Prove::State->new;
159     isa_ok $state, 'App::Prove::State';
160
161     my $desc = $test->{options};
162
163     # Naughty
164     $state->{_} = get_state();
165     my $options = $test->{options};
166     $options = [$options] unless 'ARRAY' eq ref $options;
167     $state->apply_switch(@$options);
168
169     my @got    = $state->get_tests( @{ $test->{get_tests_args} } );
170     my @expect = mn( @{ $test->{expect} } );
171     unless ( is_deeply \@got, \@expect, "$desc: order OK" ) {
172         use Data::Dumper;
173         diag( Dumper( { got => \@got, want => \@expect } ) );
174     }
175 }
176
177 sub get_state {
178     return {
179         'generation' => '51',
180         'tests'      => {
181             mn('t/compat/failure.t') => {
182                 'last_result'    => '0',
183                 'last_run_time'  => '1196371471.57738',
184                 'last_pass_time' => '1196371471.57738',
185                 'total_passes'   => '48',
186                 'seq'            => '1549',
187                 'gen'            => '51',
188                 'elapsed'        => 0.1230,
189                 'last_todo'      => '1',
190                 'mtime'          => 1196285623,
191             },
192             mn('t/yamlish-writer.t') => {
193                 'last_result'    => '0',
194                 'last_run_time'  => '1196371480.5761',
195                 'last_pass_time' => '1196371480.5761',
196                 'last_fail_time' => '1196368609',
197                 'total_passes'   => '41',
198                 'seq'            => '1578',
199                 'gen'            => '49',
200                 'elapsed'        => 12.2983,
201                 'last_todo'      => '0',
202                 'mtime'          => 1196285400,
203             },
204             mn('t/compat/env.t') => {
205                 'last_result'    => '0',
206                 'last_run_time'  => '1196371471.42967',
207                 'last_pass_time' => '1196371471.42967',
208                 'last_fail_time' => '1196368608',
209                 'total_passes'   => '48',
210                 'seq'            => '1548',
211                 'gen'            => '52',
212                 'elapsed'        => 3.1290,
213                 'last_todo'      => '0',
214                 'mtime'          => 1196285739,
215             },
216             mn('t/compat/version.t') => {
217                 'last_result'    => '2',
218                 'last_run_time'  => '1196371472.96476',
219                 'last_pass_time' => '1196371472.96476',
220                 'last_fail_time' => '1196368609',
221                 'total_passes'   => '47',
222                 'seq'            => '1555',
223                 'gen'            => '51',
224                 'elapsed'        => 0.2363,
225                 'last_todo'      => '4',
226                 'mtime'          => 1196285239,
227             },
228             mn('t/compat/inc_taint.t') => {
229                 'last_result'    => '3',
230                 'last_run_time'  => '1196371471.89682',
231                 'last_pass_time' => '1196371471.89682',
232                 'total_passes'   => '47',
233                 'seq'            => '1551',
234                 'gen'            => '51',
235                 'elapsed'        => 1.6938,
236                 'last_todo'      => '0',
237                 'mtime'          => 1196185639,
238             },
239             mn('t/source.t') => {
240                 'last_result'    => '0',
241                 'last_run_time'  => '1196371479.72508',
242                 'last_pass_time' => '1196371479.72508',
243                 'total_passes'   => '41',
244                 'seq'            => '1570',
245                 'gen'            => '51',
246                 'elapsed'        => 0.0143,
247                 'last_todo'      => '0',
248                 'mtime'          => 1186285639,
249             },
250         }
251     };
252 }