1b39c5158Smillert#!/usr/bin/perl -w
2b39c5158Smillert
3b39c5158SmillertBEGIN {
4b39c5158Smillert    unshift @INC, 't/lib';
5b39c5158Smillert}
6b39c5158Smillert
7b39c5158Smillertuse strict;
86fb12b70Safresh1use warnings;
9*256a93a4Safresh1use Config;
10b39c5158Smillert
11b39c5158Smillert# use lib 't/lib';
12b39c5158Smillert
13b39c5158Smillertuse Test::More;
14b39c5158Smillertuse File::Spec;
15b39c5158Smillertuse Test::Harness qw(execute_tests);
16b39c5158Smillert
17b39c5158Smillert# unset this global when self-testing ('testcover' and etc issue)
18b39c5158Smillertlocal $ENV{HARNESS_PERL_SWITCHES};
19b39c5158Smillert
20b39c5158Smillertmy $TEST_DIR       = 't/sample-tests';
21*256a93a4Safresh1my $NoTaintSupport = exists($Config{taint_support}) && !$Config{taint_support};
22*256a93a4Safresh1
23*256a93a4Safresh1my @test_list      = qw(descriptive die die_head_end die_last_minute duplicates
24*256a93a4Safresh1                        head_end head_fail inc_taint junk_before_plan lone_not_bug
25*256a93a4Safresh1                        no_nums no_output schwern sequence_misparse shbang_misparse
26*256a93a4Safresh1                        simple simple_fail skip skip_nomsg skipall skipall_nomsg
27*256a93a4Safresh1                        stdout_stderr taint todo_inline
28*256a93a4Safresh1                        todo_misparse too_many vms_nit
29*256a93a4Safresh1                        );
30*256a93a4Safresh1
31*256a93a4Safresh1if ($NoTaintSupport) {
32*256a93a4Safresh1    @test_list = grep { $_ !~ /taint/ && $_ ne 'shbang_misparse' } @test_list;
33*256a93a4Safresh1}
34b39c5158Smillert
35b39c5158Smillert{
36b39c5158Smillert
37b39c5158Smillert    # if the harness wants to save the resulting TAP we shouldn't
38b39c5158Smillert    # do it for our internal calls
39b39c5158Smillert    local $ENV{PERL_TEST_HARNESS_DUMP_TAP} = 0;
40b39c5158Smillert
41b39c5158Smillert    my $PER_LOOP = 4;
42b39c5158Smillert
43b39c5158Smillert    my $results = {
44b39c5158Smillert        'descriptive' => {
45b39c5158Smillert            'failed' => {},
46b39c5158Smillert            'todo'   => {},
47b39c5158Smillert            'totals' => {
48b39c5158Smillert                'bad'         => 0,
49b39c5158Smillert                'bonus'       => 0,
50b39c5158Smillert                'files'       => 1,
51b39c5158Smillert                'good'        => 1,
52b39c5158Smillert                'max'         => 5,
53b39c5158Smillert                'ok'          => 5,
54b39c5158Smillert                'skipped'     => 0,
55b39c5158Smillert                'sub_skipped' => 0,
56b39c5158Smillert                'tests'       => 1,
57b39c5158Smillert                'todo'        => 0
58b39c5158Smillert            }
59b39c5158Smillert        },
60b39c5158Smillert        join(
61*256a93a4Safresh1            ',', @test_list
62b39c5158Smillert          ) => {
63b39c5158Smillert            'failed' => {
64b39c5158Smillert                "$TEST_DIR/die" => {
65b39c5158Smillert                    'canon'  => '??',
66b39c5158Smillert                    'estat'  => 1,
67b39c5158Smillert                    'failed' => '??',
68b39c5158Smillert                    'max'    => '??',
69b39c5158Smillert                    'name'   => "$TEST_DIR/die",
70b39c5158Smillert                    'wstat'  => '256'
71b39c5158Smillert                },
72b39c5158Smillert                "$TEST_DIR/die_head_end" => {
73b39c5158Smillert                    'canon'  => '??',
74b39c5158Smillert                    'estat'  => 1,
75b39c5158Smillert                    'failed' => '??',
76b39c5158Smillert                    'max'    => '??',
77b39c5158Smillert                    'name'   => "$TEST_DIR/die_head_end",
78b39c5158Smillert                    'wstat'  => '256'
79b39c5158Smillert                },
80b39c5158Smillert                "$TEST_DIR/die_last_minute" => {
81b39c5158Smillert                    'canon'  => '??',
82b39c5158Smillert                    'estat'  => 1,
83b39c5158Smillert                    'failed' => 0,
84b39c5158Smillert                    'max'    => 4,
85b39c5158Smillert                    'name'   => "$TEST_DIR/die_last_minute",
86b39c5158Smillert                    'wstat'  => '256'
87b39c5158Smillert                },
88b39c5158Smillert                "$TEST_DIR/duplicates" => {
89b39c5158Smillert                    'canon'  => '??',
90b39c5158Smillert                    'estat'  => '',
91b39c5158Smillert                    'failed' => '??',
92b39c5158Smillert                    'max'    => 10,
93b39c5158Smillert                    'name'   => "$TEST_DIR/duplicates",
94b39c5158Smillert                    'wstat'  => ''
95b39c5158Smillert                },
96b39c5158Smillert                "$TEST_DIR/head_fail" => {
97b39c5158Smillert                    'canon'  => 2,
98b39c5158Smillert                    'estat'  => '',
99b39c5158Smillert                    'failed' => 1,
100b39c5158Smillert                    'max'    => 4,
101b39c5158Smillert                    'name'   => "$TEST_DIR/head_fail",
102b39c5158Smillert                    'wstat'  => ''
103b39c5158Smillert                },
104*256a93a4Safresh1                $NoTaintSupport ? () : (
105b39c5158Smillert                "$TEST_DIR/inc_taint" => {
106b39c5158Smillert                    'canon'  => 1,
107b39c5158Smillert                    'estat'  => 1,
108b39c5158Smillert                    'failed' => 1,
109b39c5158Smillert                    'max'    => 1,
110b39c5158Smillert                    'name'   => "$TEST_DIR/inc_taint",
111b39c5158Smillert                    'wstat'  => '256'
112*256a93a4Safresh1                }),
113b39c5158Smillert                "$TEST_DIR/no_nums" => {
114b39c5158Smillert                    'canon'  => 3,
115b39c5158Smillert                    'estat'  => '',
116b39c5158Smillert                    'failed' => 1,
117b39c5158Smillert                    'max'    => 5,
118b39c5158Smillert                    'name'   => "$TEST_DIR/no_nums",
119b39c5158Smillert                    'wstat'  => ''
120b39c5158Smillert                },
121b39c5158Smillert                "$TEST_DIR/no_output" => {
122b39c5158Smillert                    'canon'  => '??',
123b39c5158Smillert                    'estat'  => '',
124b39c5158Smillert                    'failed' => '??',
125b39c5158Smillert                    'max'    => '??',
126b39c5158Smillert                    'name'   => "$TEST_DIR/no_output",
127b39c5158Smillert                    'wstat'  => ''
128b39c5158Smillert                },
129b39c5158Smillert                "$TEST_DIR/simple_fail" => {
130b39c5158Smillert                    'canon'  => '2 5',
131b39c5158Smillert                    'estat'  => '',
132b39c5158Smillert                    'failed' => 2,
133b39c5158Smillert                    'max'    => 5,
134b39c5158Smillert                    'name'   => "$TEST_DIR/simple_fail",
135b39c5158Smillert                    'wstat'  => ''
136b39c5158Smillert                },
137b39c5158Smillert                "$TEST_DIR/todo_misparse" => {
138b39c5158Smillert                    'canon'  => 1,
139b39c5158Smillert                    'estat'  => '',
140b39c5158Smillert                    'failed' => 1,
141b39c5158Smillert                    'max'    => 1,
142b39c5158Smillert                    'name'   => "$TEST_DIR/todo_misparse",
143b39c5158Smillert                    'wstat'  => ''
144b39c5158Smillert                },
145b39c5158Smillert                "$TEST_DIR/too_many" => {
146b39c5158Smillert                    'canon'  => '4-7',
147b39c5158Smillert                    'estat'  => 4,
148b39c5158Smillert                    'failed' => 4,
149b39c5158Smillert                    'max'    => 3,
150b39c5158Smillert                    'name'   => "$TEST_DIR/too_many",
151b39c5158Smillert                    'wstat'  => '1024'
152b39c5158Smillert                },
153b39c5158Smillert                "$TEST_DIR/vms_nit" => {
154b39c5158Smillert                    'canon'  => 1,
155b39c5158Smillert                    'estat'  => '',
156b39c5158Smillert                    'failed' => 1,
157b39c5158Smillert                    'max'    => 2,
158b39c5158Smillert                    'name'   => "$TEST_DIR/vms_nit",
159b39c5158Smillert                    'wstat'  => ''
160b39c5158Smillert                }
161b39c5158Smillert            },
162b39c5158Smillert            'todo' => {
163b39c5158Smillert                "$TEST_DIR/todo_inline" => {
164b39c5158Smillert                    'canon'  => 2,
165b39c5158Smillert                    'estat'  => '',
166b39c5158Smillert                    'failed' => 1,
167b39c5158Smillert                    'max'    => 2,
168b39c5158Smillert                    'name'   => "$TEST_DIR/todo_inline",
169b39c5158Smillert                    'wstat'  => ''
170b39c5158Smillert                }
171b39c5158Smillert            },
172b39c5158Smillert            'totals' => {
173*256a93a4Safresh1                'bad'         => ($NoTaintSupport ? 11 : 12),
174b39c5158Smillert                'bonus'       => 1,
175*256a93a4Safresh1                'files'       => ($NoTaintSupport ? 24 : 27),
176*256a93a4Safresh1                'good'        => ($NoTaintSupport ? 13 : 15),
177*256a93a4Safresh1                'max'         => ($NoTaintSupport ? 72 : 76),
178*256a93a4Safresh1                'ok'          => ($NoTaintSupport ? 75 : 78),
179b39c5158Smillert                'skipped'     => 2,
180b39c5158Smillert                'sub_skipped' => 2,
181*256a93a4Safresh1                'tests'       => ($NoTaintSupport ? 24 : 27),
182b39c5158Smillert                'todo'        => 2
183b39c5158Smillert            }
184b39c5158Smillert          },
185b39c5158Smillert        'die' => {
186b39c5158Smillert            'failed' => {
187b39c5158Smillert                "$TEST_DIR/die" => {
188b39c5158Smillert                    'canon'  => '??',
189b39c5158Smillert                    'estat'  => 1,
190b39c5158Smillert                    'failed' => '??',
191b39c5158Smillert                    'max'    => '??',
192b39c5158Smillert                    'name'   => "$TEST_DIR/die",
193b39c5158Smillert                    'wstat'  => '256'
194b39c5158Smillert                }
195b39c5158Smillert            },
196b39c5158Smillert            'todo'   => {},
197b39c5158Smillert            'totals' => {
198b39c5158Smillert                'bad'         => 1,
199b39c5158Smillert                'bonus'       => 0,
200b39c5158Smillert                'files'       => 1,
201b39c5158Smillert                'good'        => 0,
202b39c5158Smillert                'max'         => 0,
203b39c5158Smillert                'ok'          => 0,
204b39c5158Smillert                'skipped'     => 0,
205b39c5158Smillert                'sub_skipped' => 0,
206b39c5158Smillert                'tests'       => 1,
207b39c5158Smillert                'todo'        => 0
208b39c5158Smillert            }
209b39c5158Smillert        },
210b39c5158Smillert        'die_head_end' => {
211b39c5158Smillert            'failed' => {
212b39c5158Smillert                "$TEST_DIR/die_head_end" => {
213b39c5158Smillert                    'canon'  => '??',
214b39c5158Smillert                    'estat'  => 1,
215b39c5158Smillert                    'failed' => '??',
216b39c5158Smillert                    'max'    => '??',
217b39c5158Smillert                    'name'   => "$TEST_DIR/die_head_end",
218b39c5158Smillert                    'wstat'  => '256'
219b39c5158Smillert                }
220b39c5158Smillert            },
221b39c5158Smillert            'todo'   => {},
222b39c5158Smillert            'totals' => {
223b39c5158Smillert                'bad'         => 1,
224b39c5158Smillert                'bonus'       => 0,
225b39c5158Smillert                'files'       => 1,
226b39c5158Smillert                'good'        => 0,
227b39c5158Smillert                'max'         => 0,
228b39c5158Smillert                'ok'          => 4,
229b39c5158Smillert                'skipped'     => 0,
230b39c5158Smillert                'sub_skipped' => 0,
231b39c5158Smillert                'tests'       => 1,
232b39c5158Smillert                'todo'        => 0
233b39c5158Smillert            }
234b39c5158Smillert        },
235b39c5158Smillert        'die_last_minute' => {
236b39c5158Smillert            'failed' => {
237b39c5158Smillert                "$TEST_DIR/die_last_minute" => {
238b39c5158Smillert                    'canon'  => '??',
239b39c5158Smillert                    'estat'  => 1,
240b39c5158Smillert                    'failed' => 0,
241b39c5158Smillert                    'max'    => 4,
242b39c5158Smillert                    'name'   => "$TEST_DIR/die_last_minute",
243b39c5158Smillert                    'wstat'  => '256'
244b39c5158Smillert                }
245b39c5158Smillert            },
246b39c5158Smillert            'todo'   => {},
247b39c5158Smillert            'totals' => {
248b39c5158Smillert                'bad'         => 1,
249b39c5158Smillert                'bonus'       => 0,
250b39c5158Smillert                'files'       => 1,
251b39c5158Smillert                'good'        => 0,
252b39c5158Smillert                'max'         => 4,
253b39c5158Smillert                'ok'          => 4,
254b39c5158Smillert                'skipped'     => 0,
255b39c5158Smillert                'sub_skipped' => 0,
256b39c5158Smillert                'tests'       => 1,
257b39c5158Smillert                'todo'        => 0
258b39c5158Smillert            }
259b39c5158Smillert        },
260b39c5158Smillert        'duplicates' => {
261b39c5158Smillert            'failed' => {
262b39c5158Smillert                "$TEST_DIR/duplicates" => {
263b39c5158Smillert                    'canon'  => '??',
264b39c5158Smillert                    'estat'  => '',
265b39c5158Smillert                    'failed' => '??',
266b39c5158Smillert                    'max'    => 10,
267b39c5158Smillert                    'name'   => "$TEST_DIR/duplicates",
268b39c5158Smillert                    'wstat'  => ''
269b39c5158Smillert                }
270b39c5158Smillert            },
271b39c5158Smillert            'todo'   => {},
272b39c5158Smillert            'totals' => {
273b39c5158Smillert                'bad'         => 1,
274b39c5158Smillert                'bonus'       => 0,
275b39c5158Smillert                'files'       => 1,
276b39c5158Smillert                'good'        => 0,
277b39c5158Smillert                'max'         => 10,
278b39c5158Smillert                'ok'          => 11,
279b39c5158Smillert                'skipped'     => 0,
280b39c5158Smillert                'sub_skipped' => 0,
281b39c5158Smillert                'tests'       => 1,
282b39c5158Smillert                'todo'        => 0
283b39c5158Smillert            }
284b39c5158Smillert        },
285b39c5158Smillert        'head_end' => {
286b39c5158Smillert            'failed' => {},
287b39c5158Smillert            'todo'   => {},
288b39c5158Smillert            'totals' => {
289b39c5158Smillert                'bad'         => 0,
290b39c5158Smillert                'bonus'       => 0,
291b39c5158Smillert                'files'       => 1,
292b39c5158Smillert                'good'        => 1,
293b39c5158Smillert                'max'         => 4,
294b39c5158Smillert                'ok'          => 4,
295b39c5158Smillert                'skipped'     => 0,
296b39c5158Smillert                'sub_skipped' => 0,
297b39c5158Smillert                'tests'       => 1,
298b39c5158Smillert                'todo'        => 0
299b39c5158Smillert            }
300b39c5158Smillert        },
301b39c5158Smillert        'head_fail' => {
302b39c5158Smillert            'failed' => {
303b39c5158Smillert                "$TEST_DIR/head_fail" => {
304b39c5158Smillert                    'canon'  => 2,
305b39c5158Smillert                    'estat'  => '',
306b39c5158Smillert                    'failed' => 1,
307b39c5158Smillert                    'max'    => 4,
308b39c5158Smillert                    'name'   => "$TEST_DIR/head_fail",
309b39c5158Smillert                    'wstat'  => ''
310b39c5158Smillert                }
311b39c5158Smillert            },
312b39c5158Smillert            'todo'   => {},
313b39c5158Smillert            'totals' => {
314b39c5158Smillert                'bad'         => 1,
315b39c5158Smillert                'bonus'       => 0,
316b39c5158Smillert                'files'       => 1,
317b39c5158Smillert                'good'        => 0,
318b39c5158Smillert                'max'         => 4,
319b39c5158Smillert                'ok'          => 3,
320b39c5158Smillert                'skipped'     => 0,
321b39c5158Smillert                'sub_skipped' => 0,
322b39c5158Smillert                'tests'       => 1,
323b39c5158Smillert                'todo'        => 0
324b39c5158Smillert            }
325b39c5158Smillert        },
326b39c5158Smillert        'inc_taint' => {
327*256a93a4Safresh1            'skip_if' => sub { $NoTaintSupport },
328b39c5158Smillert            'failed' => {
329b39c5158Smillert                "$TEST_DIR/inc_taint" => {
330b39c5158Smillert                    'canon'  => 1,
331b39c5158Smillert                    'estat'  => 1,
332b39c5158Smillert                    'failed' => 1,
333b39c5158Smillert                    'max'    => 1,
334b39c5158Smillert                    'name'   => "$TEST_DIR/inc_taint",
335b39c5158Smillert                    'wstat'  => '256'
336b39c5158Smillert                }
337b39c5158Smillert            },
338b39c5158Smillert            'todo'   => {},
339b39c5158Smillert            'totals' => {
340b39c5158Smillert                'bad'         => 1,
341b39c5158Smillert                'bonus'       => 0,
342b39c5158Smillert                'files'       => 1,
343b39c5158Smillert                'good'        => 0,
344b39c5158Smillert                'max'         => 1,
345b39c5158Smillert                'ok'          => 0,
346b39c5158Smillert                'skipped'     => 0,
347b39c5158Smillert                'sub_skipped' => 0,
348b39c5158Smillert                'tests'       => 1,
349b39c5158Smillert                'todo'        => 0
350b39c5158Smillert            }
351b39c5158Smillert        },
352b39c5158Smillert        'junk_before_plan' => {
353b39c5158Smillert            'failed' => {},
354b39c5158Smillert            'todo'   => {},
355b39c5158Smillert            'totals' => {
356b39c5158Smillert                'bad'         => 0,
357b39c5158Smillert                'bonus'       => 0,
358b39c5158Smillert                'files'       => 1,
359b39c5158Smillert                'good'        => 1,
360b39c5158Smillert                'max'         => 1,
361b39c5158Smillert                'ok'          => 1,
362b39c5158Smillert                'skipped'     => 0,
363b39c5158Smillert                'sub_skipped' => 0,
364b39c5158Smillert                'tests'       => 1,
365b39c5158Smillert                'todo'        => 0
366b39c5158Smillert            }
367b39c5158Smillert        },
368b39c5158Smillert        'lone_not_bug' => {
369b39c5158Smillert            'failed' => {},
370b39c5158Smillert            'todo'   => {},
371b39c5158Smillert            'totals' => {
372b39c5158Smillert                'bad'         => 0,
373b39c5158Smillert                'bonus'       => 0,
374b39c5158Smillert                'files'       => 1,
375b39c5158Smillert                'good'        => 1,
376b39c5158Smillert                'max'         => 4,
377b39c5158Smillert                'ok'          => 4,
378b39c5158Smillert                'skipped'     => 0,
379b39c5158Smillert                'sub_skipped' => 0,
380b39c5158Smillert                'tests'       => 1,
381b39c5158Smillert                'todo'        => 0
382b39c5158Smillert            }
383b39c5158Smillert        },
384b39c5158Smillert        'no_nums' => {
385b39c5158Smillert            'failed' => {
386b39c5158Smillert                "$TEST_DIR/no_nums" => {
387b39c5158Smillert                    'canon'  => 3,
388b39c5158Smillert                    'estat'  => '',
389b39c5158Smillert                    'failed' => 1,
390b39c5158Smillert                    'max'    => 5,
391b39c5158Smillert                    'name'   => "$TEST_DIR/no_nums",
392b39c5158Smillert                    'wstat'  => ''
393b39c5158Smillert                }
394b39c5158Smillert            },
395b39c5158Smillert            'todo'   => {},
396b39c5158Smillert            'totals' => {
397b39c5158Smillert                'bad'         => 1,
398b39c5158Smillert                'bonus'       => 0,
399b39c5158Smillert                'files'       => 1,
400b39c5158Smillert                'good'        => 0,
401b39c5158Smillert                'max'         => 5,
402b39c5158Smillert                'ok'          => 4,
403b39c5158Smillert                'skipped'     => 0,
404b39c5158Smillert                'sub_skipped' => 0,
405b39c5158Smillert                'tests'       => 1,
406b39c5158Smillert                'todo'        => 0
407b39c5158Smillert            }
408b39c5158Smillert        },
409b39c5158Smillert        'no_output' => {
410b39c5158Smillert            'failed' => {
411b39c5158Smillert                "$TEST_DIR/no_output" => {
412b39c5158Smillert                    'canon'  => '??',
413b39c5158Smillert                    'estat'  => '',
414b39c5158Smillert                    'failed' => '??',
415b39c5158Smillert                    'max'    => '??',
416b39c5158Smillert                    'name'   => "$TEST_DIR/no_output",
417b39c5158Smillert                    'wstat'  => ''
418b39c5158Smillert                }
419b39c5158Smillert            },
420b39c5158Smillert            'todo'   => {},
421b39c5158Smillert            'totals' => {
422b39c5158Smillert                'bad'         => 1,
423b39c5158Smillert                'bonus'       => 0,
424b39c5158Smillert                'files'       => 1,
425b39c5158Smillert                'good'        => 0,
426b39c5158Smillert                'max'         => 0,
427b39c5158Smillert                'ok'          => 0,
428b39c5158Smillert                'skipped'     => 0,
429b39c5158Smillert                'sub_skipped' => 0,
430b39c5158Smillert                'tests'       => 1,
431b39c5158Smillert                'todo'        => 0
432b39c5158Smillert            }
433b39c5158Smillert        },
434b39c5158Smillert        'schwern' => {
435b39c5158Smillert            'failed' => {},
436b39c5158Smillert            'todo'   => {},
437b39c5158Smillert            'totals' => {
438b39c5158Smillert                'bad'         => 0,
439b39c5158Smillert                'bonus'       => 0,
440b39c5158Smillert                'files'       => 1,
441b39c5158Smillert                'good'        => 1,
442b39c5158Smillert                'max'         => 1,
443b39c5158Smillert                'ok'          => 1,
444b39c5158Smillert                'skipped'     => 0,
445b39c5158Smillert                'sub_skipped' => 0,
446b39c5158Smillert                'tests'       => 1,
447b39c5158Smillert                'todo'        => 0
448b39c5158Smillert            }
449b39c5158Smillert        },
450b39c5158Smillert        'sequence_misparse' => {
451b39c5158Smillert            'failed' => {},
452b39c5158Smillert            'todo'   => {},
453b39c5158Smillert            'totals' => {
454b39c5158Smillert                'bad'         => 0,
455b39c5158Smillert                'bonus'       => 0,
456b39c5158Smillert                'files'       => 1,
457b39c5158Smillert                'good'        => 1,
458b39c5158Smillert                'max'         => 5,
459b39c5158Smillert                'ok'          => 5,
460b39c5158Smillert                'skipped'     => 0,
461b39c5158Smillert                'sub_skipped' => 0,
462b39c5158Smillert                'tests'       => 1,
463b39c5158Smillert                'todo'        => 0
464b39c5158Smillert            }
465b39c5158Smillert        },
466b39c5158Smillert        'shbang_misparse' => {
467*256a93a4Safresh1            'skip_if' => sub { $NoTaintSupport },
468b39c5158Smillert            'failed' => {},
469b39c5158Smillert            'todo'   => {},
470b39c5158Smillert            'totals' => {
471b39c5158Smillert                'bad'         => 0,
472b39c5158Smillert                'bonus'       => 0,
473b39c5158Smillert                'files'       => 1,
474b39c5158Smillert                'good'        => 1,
475b39c5158Smillert                'max'         => 2,
476b39c5158Smillert                'ok'          => 2,
477b39c5158Smillert                'skipped'     => 0,
478b39c5158Smillert                'sub_skipped' => 0,
479b39c5158Smillert                'tests'       => 1,
480b39c5158Smillert                'todo'        => 0
481b39c5158Smillert            }
482b39c5158Smillert        },
483b39c5158Smillert        'simple' => {
484b39c5158Smillert            'failed' => {},
485b39c5158Smillert            'todo'   => {},
486b39c5158Smillert            'totals' => {
487b39c5158Smillert                'bad'         => 0,
488b39c5158Smillert                'bonus'       => 0,
489b39c5158Smillert                'files'       => 1,
490b39c5158Smillert                'good'        => 1,
491b39c5158Smillert                'max'         => 5,
492b39c5158Smillert                'ok'          => 5,
493b39c5158Smillert                'skipped'     => 0,
494b39c5158Smillert                'sub_skipped' => 0,
495b39c5158Smillert                'tests'       => 1,
496b39c5158Smillert                'todo'        => 0
497b39c5158Smillert            }
498b39c5158Smillert        },
499b39c5158Smillert        'simple_fail' => {
500b39c5158Smillert            'failed' => {
501b39c5158Smillert                "$TEST_DIR/simple_fail" => {
502b39c5158Smillert                    'canon'  => '2 5',
503b39c5158Smillert                    'estat'  => '',
504b39c5158Smillert                    'failed' => 2,
505b39c5158Smillert                    'max'    => 5,
506b39c5158Smillert                    'name'   => "$TEST_DIR/simple_fail",
507b39c5158Smillert                    'wstat'  => ''
508b39c5158Smillert                }
509b39c5158Smillert            },
510b39c5158Smillert            'todo'   => {},
511b39c5158Smillert            'totals' => {
512b39c5158Smillert                'bad'         => 1,
513b39c5158Smillert                'bonus'       => 0,
514b39c5158Smillert                'files'       => 1,
515b39c5158Smillert                'good'        => 0,
516b39c5158Smillert                'max'         => 5,
517b39c5158Smillert                'ok'          => 3,
518b39c5158Smillert                'skipped'     => 0,
519b39c5158Smillert                'sub_skipped' => 0,
520b39c5158Smillert                'tests'       => 1,
521b39c5158Smillert                'todo'        => 0
522b39c5158Smillert            }
523b39c5158Smillert        },
524b39c5158Smillert        'skip' => {
525b39c5158Smillert            'failed' => {},
526b39c5158Smillert            'todo'   => {},
527b39c5158Smillert            'totals' => {
528b39c5158Smillert                'bad'         => 0,
529b39c5158Smillert                'bonus'       => 0,
530b39c5158Smillert                'files'       => 1,
531b39c5158Smillert                'good'        => 1,
532b39c5158Smillert                'max'         => 5,
533b39c5158Smillert                'ok'          => 5,
534b39c5158Smillert                'skipped'     => 0,
535b39c5158Smillert                'sub_skipped' => 1,
536b39c5158Smillert                'tests'       => 1,
537b39c5158Smillert                'todo'        => 0
538b39c5158Smillert            }
539b39c5158Smillert        },
540b39c5158Smillert        'skip_nomsg' => {
541b39c5158Smillert            'failed' => {},
542b39c5158Smillert            'todo'   => {},
543b39c5158Smillert            'totals' => {
544b39c5158Smillert                'bad'         => 0,
545b39c5158Smillert                'bonus'       => 0,
546b39c5158Smillert                'files'       => 1,
547b39c5158Smillert                'good'        => 1,
548b39c5158Smillert                'max'         => 1,
549b39c5158Smillert                'ok'          => 1,
550b39c5158Smillert                'skipped'     => 0,
551b39c5158Smillert                'sub_skipped' => 1,
552b39c5158Smillert                'tests'       => 1,
553b39c5158Smillert                'todo'        => 0
554b39c5158Smillert            }
555b39c5158Smillert        },
556b39c5158Smillert        'skipall' => {
557b39c5158Smillert            'failed' => {},
558b39c5158Smillert            'todo'   => {},
559b39c5158Smillert            'totals' => {
560b39c5158Smillert                'bad'         => 0,
561b39c5158Smillert                'bonus'       => 0,
562b39c5158Smillert                'files'       => 1,
563b39c5158Smillert                'good'        => 1,
564b39c5158Smillert                'max'         => 0,
565b39c5158Smillert                'ok'          => 0,
566b39c5158Smillert                'skipped'     => 1,
567b39c5158Smillert                'sub_skipped' => 0,
568b39c5158Smillert                'tests'       => 1,
569b39c5158Smillert                'todo'        => 0
570b39c5158Smillert            }
571b39c5158Smillert        },
572b39c5158Smillert        'skipall_nomsg' => {
573b39c5158Smillert            'failed' => {},
574b39c5158Smillert            'todo'   => {},
575b39c5158Smillert            'totals' => {
576b39c5158Smillert                'bad'         => 0,
577b39c5158Smillert                'bonus'       => 0,
578b39c5158Smillert                'files'       => 1,
579b39c5158Smillert                'good'        => 1,
580b39c5158Smillert                'max'         => 0,
581b39c5158Smillert                'ok'          => 0,
582b39c5158Smillert                'skipped'     => 1,
583b39c5158Smillert                'sub_skipped' => 0,
584b39c5158Smillert                'tests'       => 1,
585b39c5158Smillert                'todo'        => 0
586b39c5158Smillert            }
587b39c5158Smillert        },
588b39c5158Smillert        'stdout_stderr' => {
589b39c5158Smillert            'failed' => {},
590b39c5158Smillert            'todo'   => {},
591b39c5158Smillert            'totals' => {
592b39c5158Smillert                'bad'         => 0,
593b39c5158Smillert                'bonus'       => 0,
594b39c5158Smillert                'files'       => 1,
595b39c5158Smillert                'good'        => 1,
596b39c5158Smillert                'max'         => 4,
597b39c5158Smillert                'ok'          => 4,
598b39c5158Smillert                'skipped'     => 0,
599b39c5158Smillert                'sub_skipped' => 0,
600b39c5158Smillert                'tests'       => 1,
601b39c5158Smillert                'todo'        => 0
602b39c5158Smillert            }
603b39c5158Smillert        },
604b39c5158Smillert        'switches' => {
605b39c5158Smillert            'skip_if' => sub {
606b39c5158Smillert                ( $ENV{PERL5OPT} || '' ) =~ m{(?:^|\s)-[dM]};
607b39c5158Smillert            },
608b39c5158Smillert            'failed' => {
609b39c5158Smillert                "$TEST_DIR/switches" => {
610b39c5158Smillert                    'canon'  => 1,
611b39c5158Smillert                    'estat'  => '',
612b39c5158Smillert                    'failed' => 1,
613b39c5158Smillert                    'max'    => 1,
614b39c5158Smillert                    'name'   => "$TEST_DIR/switches",
615b39c5158Smillert                    'wstat'  => ''
616b39c5158Smillert                }
617b39c5158Smillert            },
618b39c5158Smillert            'todo'   => {},
619b39c5158Smillert            'totals' => {
620b39c5158Smillert                'bad'         => 1,
621b39c5158Smillert                'bonus'       => 0,
622b39c5158Smillert                'files'       => 1,
623b39c5158Smillert                'good'        => 0,
624b39c5158Smillert                'max'         => 1,
625b39c5158Smillert                'ok'          => 0,
626b39c5158Smillert                'skipped'     => 0,
627b39c5158Smillert                'sub_skipped' => 0,
628b39c5158Smillert                'tests'       => 1,
629b39c5158Smillert                'todo'        => 0
630b39c5158Smillert            }
631b39c5158Smillert        },
632b39c5158Smillert        'taint' => {
633*256a93a4Safresh1            'skip_if' => sub { $NoTaintSupport },
634b39c5158Smillert            'failed'  => {},
635b39c5158Smillert            'todo'    => {},
636b39c5158Smillert            'totals'  => {
637b39c5158Smillert                'bad'         => 0,
638b39c5158Smillert                'bonus'       => 0,
639b39c5158Smillert                'files'       => 1,
640b39c5158Smillert                'good'        => 1,
641b39c5158Smillert                'max'         => 1,
642b39c5158Smillert                'ok'          => 1,
643b39c5158Smillert                'skipped'     => 0,
644b39c5158Smillert                'sub_skipped' => 0,
645b39c5158Smillert                'tests'       => 1,
646b39c5158Smillert                'todo'        => 0
647b39c5158Smillert            }
648b39c5158Smillert        },
649b39c5158Smillert        'taint_warn' => {
650*256a93a4Safresh1            'skip_if' => sub { $NoTaintSupport },
651b39c5158Smillert            'failed'  => {},
652b39c5158Smillert            'todo'    => {},
653b39c5158Smillert            'totals'  => {
654b39c5158Smillert                'bad'         => 0,
655b39c5158Smillert                'bonus'       => 0,
656b39c5158Smillert                'files'       => 1,
657b39c5158Smillert                'good'        => 1,
658b39c5158Smillert                'max'         => 1,
659b39c5158Smillert                'ok'          => 1,
660b39c5158Smillert                'skipped'     => 0,
661b39c5158Smillert                'sub_skipped' => 0,
662b39c5158Smillert                'tests'       => 1,
663b39c5158Smillert                'todo'        => 0
664b39c5158Smillert            },
665b39c5158Smillert            'require' => 5.008001,
666b39c5158Smillert        },
667b39c5158Smillert        'todo_inline' => {
668b39c5158Smillert            'failed' => {},
669b39c5158Smillert            'todo'   => {
670b39c5158Smillert                "$TEST_DIR/todo_inline" => {
671b39c5158Smillert                    'canon'  => 2,
672b39c5158Smillert                    'estat'  => '',
673b39c5158Smillert                    'failed' => 1,
674b39c5158Smillert                    'max'    => 2,
675b39c5158Smillert                    'name'   => "$TEST_DIR/todo_inline",
676b39c5158Smillert                    'wstat'  => ''
677b39c5158Smillert                }
678b39c5158Smillert            },
679b39c5158Smillert            'totals' => {
680b39c5158Smillert                'bad'         => 0,
681b39c5158Smillert                'bonus'       => 1,
682b39c5158Smillert                'files'       => 1,
683b39c5158Smillert                'good'        => 1,
684b39c5158Smillert                'max'         => 3,
685b39c5158Smillert                'ok'          => 3,
686b39c5158Smillert                'skipped'     => 0,
687b39c5158Smillert                'sub_skipped' => 0,
688b39c5158Smillert                'tests'       => 1,
689b39c5158Smillert                'todo'        => 2
690b39c5158Smillert            }
691b39c5158Smillert        },
692b39c5158Smillert        'todo_misparse' => {
693b39c5158Smillert            'failed' => {
694b39c5158Smillert                "$TEST_DIR/todo_misparse" => {
695b39c5158Smillert                    'canon'  => 1,
696b39c5158Smillert                    'estat'  => '',
697b39c5158Smillert                    'failed' => 1,
698b39c5158Smillert                    'max'    => 1,
699b39c5158Smillert                    'name'   => "$TEST_DIR/todo_misparse",
700b39c5158Smillert                    'wstat'  => ''
701b39c5158Smillert                }
702b39c5158Smillert            },
703b39c5158Smillert            'todo'   => {},
704b39c5158Smillert            'totals' => {
705b39c5158Smillert                'bad'         => 1,
706b39c5158Smillert                'bonus'       => 0,
707b39c5158Smillert                'files'       => 1,
708b39c5158Smillert                'good'        => 0,
709b39c5158Smillert                'max'         => 1,
710b39c5158Smillert                'ok'          => 0,
711b39c5158Smillert                'skipped'     => 0,
712b39c5158Smillert                'sub_skipped' => 0,
713b39c5158Smillert                'tests'       => 1,
714b39c5158Smillert                'todo'        => 0
715b39c5158Smillert            }
716b39c5158Smillert        },
717b39c5158Smillert        'too_many' => {
718b39c5158Smillert            'failed' => {
719b39c5158Smillert                "$TEST_DIR/too_many" => {
720b39c5158Smillert                    'canon'  => '4-7',
721b39c5158Smillert                    'estat'  => 4,
722b39c5158Smillert                    'failed' => 4,
723b39c5158Smillert                    'max'    => 3,
724b39c5158Smillert                    'name'   => "$TEST_DIR/too_many",
725b39c5158Smillert                    'wstat'  => '1024'
726b39c5158Smillert                }
727b39c5158Smillert            },
728b39c5158Smillert            'todo'   => {},
729b39c5158Smillert            'totals' => {
730b39c5158Smillert                'bad'         => 1,
731b39c5158Smillert                'bonus'       => 0,
732b39c5158Smillert                'files'       => 1,
733b39c5158Smillert                'good'        => 0,
734b39c5158Smillert                'max'         => 3,
735b39c5158Smillert                'ok'          => 7,
736b39c5158Smillert                'skipped'     => 0,
737b39c5158Smillert                'sub_skipped' => 0,
738b39c5158Smillert                'tests'       => 1,
739b39c5158Smillert                'todo'        => 0
740b39c5158Smillert            }
741b39c5158Smillert        },
742b39c5158Smillert        'vms_nit' => {
743b39c5158Smillert            'failed' => {
744b39c5158Smillert                "$TEST_DIR/vms_nit" => {
745b39c5158Smillert                    'canon'  => 1,
746b39c5158Smillert                    'estat'  => '',
747b39c5158Smillert                    'failed' => 1,
748b39c5158Smillert                    'max'    => 2,
749b39c5158Smillert                    'name'   => "$TEST_DIR/vms_nit",
750b39c5158Smillert                    'wstat'  => ''
751b39c5158Smillert                }
752b39c5158Smillert            },
753b39c5158Smillert            'todo'   => {},
754b39c5158Smillert            'totals' => {
755b39c5158Smillert                'bad'         => 1,
756b39c5158Smillert                'bonus'       => 0,
757b39c5158Smillert                'files'       => 1,
758b39c5158Smillert                'good'        => 0,
759b39c5158Smillert                'max'         => 2,
760b39c5158Smillert                'ok'          => 1,
761b39c5158Smillert                'skipped'     => 0,
762b39c5158Smillert                'sub_skipped' => 0,
763b39c5158Smillert                'tests'       => 1,
764b39c5158Smillert                'todo'        => 0
765b39c5158Smillert            }
766b39c5158Smillert        }
767b39c5158Smillert    };
768b39c5158Smillert
769b39c5158Smillert    my $num_tests = ( keys %$results ) * $PER_LOOP;
770b39c5158Smillert
771b39c5158Smillert    plan tests => $num_tests;
772b39c5158Smillert
773b39c5158Smillert    sub local_name {
774b39c5158Smillert        my $name = shift;
775b39c5158Smillert        return File::Spec->catfile( split /\//, $name );
776b39c5158Smillert    }
777b39c5158Smillert
778b39c5158Smillert    sub local_result {
779b39c5158Smillert        my $hash = shift;
780b39c5158Smillert        my $new  = {};
781b39c5158Smillert
782b39c5158Smillert        while ( my ( $file, $want ) = each %$hash ) {
783b39c5158Smillert            if ( exists $want->{name} ) {
784b39c5158Smillert                $want->{name} = local_name( $want->{name} );
785b39c5158Smillert            }
786b39c5158Smillert            $new->{ local_name($file) } = $want;
787b39c5158Smillert        }
788b39c5158Smillert        return $new;
789b39c5158Smillert    }
790b39c5158Smillert
791b39c5158Smillert    sub vague_status {
792b39c5158Smillert        my $hash = shift;
793b39c5158Smillert        return $hash unless $^O eq 'VMS';
794b39c5158Smillert
795b39c5158Smillert        while ( my ( $file, $want ) = each %$hash ) {
796b39c5158Smillert            for (qw( estat wstat )) {
797b39c5158Smillert                if ( exists $want->{$_} ) {
798b39c5158Smillert                    $want->{$_} = $want->{$_} ? 1 : 0;
799b39c5158Smillert                }
800b39c5158Smillert            }
801b39c5158Smillert        }
802b39c5158Smillert        return $hash;
803b39c5158Smillert    }
804b39c5158Smillert
805b39c5158Smillert    {
806b39c5158Smillert        local $^W = 0;
807b39c5158Smillert
808b39c5158Smillert        # Silence harness output
809b39c5158Smillert        *TAP::Formatter::Console::_output = sub {
810b39c5158Smillert
811b39c5158Smillert            # do nothing
812b39c5158Smillert        };
813b39c5158Smillert    }
814b39c5158Smillert
815b39c5158Smillert    for my $test_key ( sort keys %$results ) {
816b39c5158Smillert        my $result = $results->{$test_key};
817b39c5158Smillert        SKIP: {
818b39c5158Smillert            if ( $result->{require} && $] < $result->{require} ) {
819b39c5158Smillert                skip "Test requires Perl $result->{require}, we have $]", 4;
820b39c5158Smillert            }
821b39c5158Smillert
822b39c5158Smillert            if ( my $skip_if = $result->{skip_if} ) {
823b39c5158Smillert                skip
824b39c5158Smillert                  "Test '$test_key' can't run properly in this environment", 4
825b39c5158Smillert                  if $skip_if->();
826b39c5158Smillert            }
827b39c5158Smillert
828*256a93a4Safresh1            if (($test_key eq 'inc_taint' || $test_key eq 'shbang_misparse') && $NoTaintSupport) {
829*256a93a4Safresh1                skip "your perl was built without taint support", 4;
830*256a93a4Safresh1            }
831*256a93a4Safresh1
832b39c5158Smillert            my @test_names = split( /,/, $test_key );
833b39c5158Smillert            my @test_files
834b39c5158Smillert              = map { File::Spec->catfile( $TEST_DIR, $_ ) } @test_names;
835b39c5158Smillert
836b39c5158Smillert            # For now we supress STDERR because it crufts up /our/ test
837b39c5158Smillert            # results. Should probably capture and analyse it.
838b39c5158Smillert            local ( *OLDERR, *OLDOUT );
839b39c5158Smillert            open OLDERR, '>&STDERR' or die $!;
840b39c5158Smillert            open OLDOUT, '>&STDOUT' or die $!;
841b39c5158Smillert            my $devnull = File::Spec->devnull;
842b39c5158Smillert            open STDERR, ">$devnull" or die $!;
843b39c5158Smillert            open STDOUT, ">$devnull" or die $!;
844b39c5158Smillert
845b39c5158Smillert            my ( $tot, $fail, $todo, $harness, $aggregate )
846b39c5158Smillert              = execute_tests( tests => \@test_files );
847b39c5158Smillert
848b39c5158Smillert            open STDERR, '>&OLDERR' or die $!;
849b39c5158Smillert            open STDOUT, '>&OLDOUT' or die $!;
850b39c5158Smillert
851b39c5158Smillert            my $bench = delete $tot->{bench};
852b39c5158Smillert            isa_ok $bench, 'Benchmark';
853b39c5158Smillert
854b39c5158Smillert            # Localise filenames in failed, todo
855b39c5158Smillert            my $lfailed = vague_status( local_result( $result->{failed} ) );
856b39c5158Smillert            my $ltodo   = vague_status( local_result( $result->{todo} ) );
857b39c5158Smillert
858b39c5158Smillert            # use Data::Dumper;
859b39c5158Smillert            # diag Dumper( [ $lfailed, $ltodo ] );
860b39c5158Smillert
861b39c5158Smillert            is_deeply $tot, $result->{totals}, "totals match for $test_key";
862b39c5158Smillert            is_deeply vague_status($fail), $lfailed,
863b39c5158Smillert              "failure summary matches for $test_key";
864b39c5158Smillert            is_deeply vague_status($todo), $ltodo,
865b39c5158Smillert              "todo summary matches for $test_key";
866b39c5158Smillert        }
867b39c5158Smillert    }
868b39c5158Smillert}
869