Commit | Line | Data |
---|---|---|
27fc0087 NC |
1 | #!/usr/bin/perl -w |
2 | ||
3 | BEGIN { | |
686add28 | 4 | unshift @INC, 't/lib'; |
27fc0087 NC |
5 | } |
6 | ||
7 | use strict; | |
8 | use Test::More tests => 25; | |
9 | use App::Prove::State; | |
10 | ||
11 | my $test_suite_data = test_suite_data(); | |
12 | ||
13 | # | |
14 | # Test test suite results | |
15 | # | |
16 | ||
17 | can_ok 'App::Prove::State::Result', 'new'; | |
18 | isa_ok my $result = App::Prove::State::Result->new($test_suite_data), | |
19 | 'App::Prove::State::Result', '... and the object it returns'; | |
20 | ||
21 | ok $result, 'state_version'; | |
22 | ok defined $result->state_version, '... and it should be defined'; | |
23 | ||
24 | can_ok $result, 'generation'; | |
25 | is $result->generation, $test_suite_data->{generation}, | |
26 | '... and it should return the correct generation'; | |
27 | ||
28 | can_ok $result, 'num_tests'; | |
29 | is $result->num_tests, scalar keys %{ $test_suite_data->{tests} }, | |
30 | '... and it should return the number of tests run'; | |
31 | ||
32 | can_ok $result, 'raw'; | |
33 | is_deeply $result->raw, $test_suite_data, | |
34 | '... and it should return the raw, unblessed data'; | |
35 | ||
36 | # | |
37 | # Check individual tests. | |
38 | # | |
39 | ||
40 | can_ok $result, 'tests'; | |
41 | ||
42 | can_ok $result, 'test'; | |
43 | eval { $result->test }; | |
44 | my $error = $@; | |
45 | like $error, qr/^\Qtest() requires a test name/, | |
46 | '... and it should croak() if a test name is not supplied'; | |
47 | ||
48 | my $name = 't/compat/failure.t'; | |
49 | ok my $test = $result->test('t/compat/failure.t'), | |
50 | 'result() should succeed if the test name is found'; | |
51 | isa_ok $test, 'App::Prove::State::Result::Test', | |
52 | '... and the object it returns'; | |
53 | ||
54 | can_ok $test, 'name'; | |
55 | is $test->name, $name, '... and it should return the test name'; | |
56 | ||
57 | can_ok $test, 'last_pass_time'; | |
58 | like $test->last_pass_time, qr/^\d+\.\d+$/, | |
59 | '... and it should return a numeric value'; | |
60 | ||
61 | can_ok $test, 'last_fail_time'; | |
62 | ok !defined $test->last_fail_time, | |
63 | '... and it should return undef if the test has never failed'; | |
64 | ||
65 | can_ok $result, 'remove'; | |
66 | ok $result->remove($name), '... and calling it should succeed'; | |
67 | ||
68 | ok $test = $result->test($name), | |
69 | '... and fetching the removed test should suceed'; | |
70 | ok !defined $test->last_pass_time, '... and it should have clean values'; | |
71 | ||
72 | sub test_suite_data { | |
73 | return { | |
74 | 'version' => App::Prove::State::Result->state_version, | |
75 | 'generation' => '51', | |
76 | 'tests' => { | |
77 | 't/compat/failure.t' => { | |
78 | 'last_result' => '0', | |
79 | 'last_run_time' => '1196371471.57738', | |
80 | 'last_pass_time' => '1196371471.57738', | |
81 | 'total_passes' => '48', | |
82 | 'seq' => '1549', | |
83 | 'gen' => '51', | |
84 | 'elapsed' => 0.1230, | |
85 | 'last_todo' => '1', | |
86 | 'mtime' => 1196285623, | |
87 | }, | |
88 | 't/yamlish-writer.t' => { | |
89 | 'last_result' => '0', | |
90 | 'last_run_time' => '1196371480.5761', | |
91 | 'last_pass_time' => '1196371480.5761', | |
92 | 'last_fail_time' => '1196368609', | |
93 | 'total_passes' => '41', | |
94 | 'seq' => '1578', | |
95 | 'gen' => '49', | |
96 | 'elapsed' => 12.2983, | |
97 | 'last_todo' => '0', | |
98 | 'mtime' => 1196285400, | |
99 | }, | |
100 | 't/compat/env.t' => { | |
101 | 'last_result' => '0', | |
102 | 'last_run_time' => '1196371471.42967', | |
103 | 'last_pass_time' => '1196371471.42967', | |
104 | 'last_fail_time' => '1196368608', | |
105 | 'total_passes' => '48', | |
106 | 'seq' => '1548', | |
107 | 'gen' => '52', | |
108 | 'elapsed' => 3.1290, | |
109 | 'last_todo' => '0', | |
110 | 'mtime' => 1196285739, | |
111 | }, | |
112 | 't/compat/version.t' => { | |
113 | 'last_result' => '2', | |
114 | 'last_run_time' => '1196371472.96476', | |
115 | 'last_pass_time' => '1196371472.96476', | |
116 | 'last_fail_time' => '1196368609', | |
117 | 'total_passes' => '47', | |
118 | 'seq' => '1555', | |
119 | 'gen' => '51', | |
120 | 'elapsed' => 0.2363, | |
121 | 'last_todo' => '4', | |
122 | 'mtime' => 1196285239, | |
123 | }, | |
124 | 't/compat/inc_taint.t' => { | |
125 | 'last_result' => '3', | |
126 | 'last_run_time' => '1196371471.89682', | |
127 | 'last_pass_time' => '1196371471.89682', | |
128 | 'total_passes' => '47', | |
129 | 'seq' => '1551', | |
130 | 'gen' => '51', | |
131 | 'elapsed' => 1.6938, | |
132 | 'last_todo' => '0', | |
133 | 'mtime' => 1196185639, | |
134 | }, | |
135 | 't/source.t' => { | |
136 | 'last_result' => '0', | |
137 | 'last_run_time' => '1196371479.72508', | |
138 | 'last_pass_time' => '1196371479.72508', | |
139 | 'total_passes' => '41', | |
140 | 'seq' => '1570', | |
141 | 'gen' => '51', | |
142 | 'elapsed' => 0.0143, | |
143 | 'last_todo' => '0', | |
144 | 'mtime' => 1186285639, | |
145 | }, | |
146 | } | |
147 | }; | |
148 | } |