bring Test::Harness up to 3.06
[p5sagit/p5-mst-13.2.git] / lib / Test / Harness / t / state.t
CommitLineData
b965d173 1#!/usr/bin/perl -w
2
69f36734 3BEGIN {
4 if ( $ENV{PERL_CORE} ) {
5 chdir 't';
6 @INC = '../lib';
7 }
8 else {
9 unshift @INC, 't/lib';
10 }
11}
b965d173 12
69f36734 13use strict;
b965d173 14use Test::More;
15use App::Prove::State;
16
69f36734 17sub mn {
18 my $pfx = $ENV{PERL_CORE} ? '../lib/Test/Harness/' : '';
19 return map {"$pfx$_"} @_;
20}
b965d173 21
69f36734 22my @schedule = (
b965d173 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 => [
69f36734 134 't/source.t',
b965d173 135 't/compat/inc_taint.t',
136 't/compat/version.t',
b965d173 137 't/yamlish-writer.t',
69f36734 138 't/compat/failure.t',
139 't/compat/env.t',
b965d173 140 ],
141 },
142 { options => 'new',
143 get_tests_args => [],
144 expect => [
b965d173 145 't/compat/env.t',
146 't/compat/failure.t',
69f36734 147 't/yamlish-writer.t',
148 't/compat/version.t',
149 't/compat/inc_taint.t',
150 't/source.t',
b965d173 151 ],
152 },
153);
154
155plan tests => @schedule * 2;
156
157for 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
69f36734 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" ) {
b965d173 172 use Data::Dumper;
69f36734 173 diag( Dumper( { got => \@got, want => \@expect } ) );
b965d173 174 }
175}
176
177sub get_state {
178 return {
179 'generation' => '51',
180 'tests' => {
69f36734 181 mn('t/compat/failure.t') => {
b965d173 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,
69f36734 189 'last_todo' => '1',
190 'mtime' => 1196285623,
b965d173 191 },
69f36734 192 mn('t/yamlish-writer.t') => {
b965d173 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,
69f36734 201 'last_todo' => '0',
202 'mtime' => 1196285400,
b965d173 203 },
69f36734 204 mn('t/compat/env.t') => {
b965d173 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,
69f36734 213 'last_todo' => '0',
214 'mtime' => 1196285739,
b965d173 215 },
69f36734 216 mn('t/compat/version.t') => {
b965d173 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,
69f36734 225 'last_todo' => '4',
226 'mtime' => 1196285239,
b965d173 227 },
69f36734 228 mn('t/compat/inc_taint.t') => {
b965d173 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,
69f36734 236 'last_todo' => '0',
237 'mtime' => 1196185639,
b965d173 238 },
69f36734 239 mn('t/source.t') => {
b965d173 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,
69f36734 247 'last_todo' => '0',
248 'mtime' => 1186285639,
b965d173 249 },
250 }
251 };
252}