summaryrefslogtreecommitdiff
path: root/cpan/Test-Harness/t/state.t
blob: a2a58e729ce6310585a4fcdd61592bffb855f4e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
#!/usr/bin/perl -w

BEGIN {
    if ( $ENV{PERL_CORE} ) {
        chdir 't';
        @INC = '../lib';
    }
    else {
        unshift @INC, 't/lib';
    }
}

use strict;
use Test::More;
use App::Prove::State;
use App::Prove::State::Result;

sub mn {
    my $pfx = $ENV{PERL_CORE} ? '../ext/Test-Harness/' : '';
    return map {"$pfx$_"} @_;
}

my @schedule = (
    {   options        => 'all',
        get_tests_args => [],
        expect         => [
            't/compat/env.t',
            't/compat/failure.t',
            't/compat/inc_taint.t',
            't/compat/version.t',
            't/source_handler.t',
            't/yamlish-writer.t',
        ],
    },
    {   options        => 'failed',
        get_tests_args => [],
        expect         => [
            't/compat/inc_taint.t',
            't/compat/version.t',
        ],
    },
    {   options        => 'passed',
        get_tests_args => [],
        expect         => [
            't/compat/env.t',
            't/compat/failure.t',
            't/source_handler.t',
            't/yamlish-writer.t',
        ],
    },
    {   options        => 'last',
        get_tests_args => [],
        expect         => [
            't/compat/env.t',
            't/compat/failure.t',
            't/compat/inc_taint.t',
            't/compat/version.t',
            't/source_handler.t',
        ],
    },
    {   options        => 'todo',
        get_tests_args => [],
        expect         => [
            't/compat/version.t',
            't/compat/failure.t',
        ],

    },
    {   options        => 'hot',
        get_tests_args => [],
        expect         => [
            't/compat/version.t',
            't/yamlish-writer.t',
            't/compat/env.t',
        ],
    },
    {   options        => 'adrian',
        get_tests_args => [],
        expect         => [
            't/compat/version.t',
            't/yamlish-writer.t',
            't/compat/env.t',
            't/compat/failure.t',
            't/compat/inc_taint.t',
            't/source_handler.t',
        ],
    },
    {   options        => 'failed,passed',
        get_tests_args => [],
        expect         => [
            't/compat/inc_taint.t',
            't/compat/version.t',
            't/compat/env.t',
            't/compat/failure.t',
            't/source_handler.t',
            't/yamlish-writer.t',
        ],
    },
    {   options        => [ 'failed', 'passed' ],
        get_tests_args => [],
        expect         => [
            't/compat/inc_taint.t',
            't/compat/version.t',
            't/compat/env.t',
            't/compat/failure.t',
            't/source_handler.t',
            't/yamlish-writer.t',
        ],
    },
    {   options        => 'slow',
        get_tests_args => [],
        expect         => [
            't/yamlish-writer.t',
            't/compat/env.t',
            't/compat/inc_taint.t',
            't/compat/version.t',
            't/compat/failure.t',
            't/source_handler.t',
        ],
    },
    {   options        => 'fast',
        get_tests_args => [],
        expect         => [
            't/source_handler.t',
            't/compat/failure.t',
            't/compat/version.t',
            't/compat/inc_taint.t',
            't/compat/env.t',
            't/yamlish-writer.t',
        ],
    },
    {   options        => 'old',
        get_tests_args => [],
        expect         => [
            't/source_handler.t',
            't/compat/inc_taint.t',
            't/compat/version.t',
            't/yamlish-writer.t',
            't/compat/failure.t',
            't/compat/env.t',
        ],
    },
    {   options        => 'new',
        get_tests_args => [],
        expect         => [
            't/compat/env.t',
            't/compat/failure.t',
            't/yamlish-writer.t',
            't/compat/version.t',
            't/compat/inc_taint.t',
            't/source_handler.t',
        ],
    },
    {   options        => 'fresh',
        get_tests_args => [],
        expect         => [
            't/compat/env.t',
            't/compat/failure.t',
        ],
    },
);

plan tests => @schedule * 2;

for my $test (@schedule) {
    my $state = App::Prove::State->new;
    isa_ok $state, 'App::Prove::State';

    my $desc = $test->{options};

    # Naughty
    $state->{_} = get_state();
    my $options = $test->{options};
    $options = [$options] unless 'ARRAY' eq ref $options;
    $state->apply_switch(@$options);

    my @got    = $state->get_tests( @{ $test->{get_tests_args} } );
    my @expect = mn( @{ $test->{expect} } );
    unless ( is_deeply \@got, \@expect, "$desc: order OK" ) {
        use Data::Dumper;
        diag( Dumper( { got => \@got, want => \@expect } ) );
    }
}

sub get_state {
    return App::Prove::State::Result->new(
        {   generation    => 51,
            last_run_time => 1196285439,
            tests         => {
                mn('t/compat/failure.t') => {
                    last_result    => 0,
                    last_run_time  => 1196371471.57738,
                    last_pass_time => 1196371471.57738,
                    total_passes   => 48,
                    seq            => 1549,
                    gen            => 51,
                    elapsed        => 0.1230,
                    last_todo      => 1,
                    mtime          => 1196285623,
                },
                mn('t/yamlish-writer.t') => {
                    last_result    => 0,
                    last_run_time  => 1196371480.5761,
                    last_pass_time => 1196371480.5761,
                    last_fail_time => 1196368609,
                    total_passes   => 41,
                    seq            => 1578,
                    gen            => 49,
                    elapsed        => 12.2983,
                    last_todo      => 0,
                    mtime          => 1196285400,
                },
                mn('t/compat/env.t') => {
                    last_result    => 0,
                    last_run_time  => 1196371471.42967,
                    last_pass_time => 1196371471.42967,
                    last_fail_time => 1196368608,
                    total_passes   => 48,
                    seq            => 1548,
                    gen            => 52,
                    elapsed        => 3.1290,
                    last_todo      => 0,
                    mtime          => 1196285739,
                },
                mn('t/compat/version.t') => {
                    last_result    => 2,
                    last_run_time  => 1196371472.96476,
                    last_pass_time => 1196371472.96476,
                    last_fail_time => 1196368609,
                    total_passes   => 47,
                    seq            => 1555,
                    gen            => 51,
                    elapsed        => 0.2363,
                    last_todo      => 4,
                    mtime          => 1196285239,
                },
                mn('t/compat/inc_taint.t') => {
                    last_result    => 3,
                    last_run_time  => 1196371471.89682,
                    last_pass_time => 1196371471.89682,
                    total_passes   => 47,
                    seq            => 1551,
                    gen            => 51,
                    elapsed        => 1.6938,
                    last_todo      => 0,
                    mtime          => 1196185639,
                },
                mn('t/source_handler.t') => {
                    last_result    => 0,
                    last_run_time  => 1196371479.72508,
                    last_pass_time => 1196371479.72508,
                    total_passes   => 41,
                    seq            => 1570,
                    gen            => 51,
                    elapsed        => 0.0143,
                    last_todo      => 0,
                    mtime          => 1186285639,
                },
            }
        }
    );
}