1#!/usr/bin/perl -w 2 3BEGIN { 4 unshift @INC, 't/lib'; 5} 6 7use strict; 8use Test::More tests => 25; 9use App::Prove::State; 10 11my $test_suite_data = test_suite_data(); 12 13# 14# Test test suite results 15# 16 17can_ok 'App::Prove::State::Result', 'new'; 18isa_ok my $result = App::Prove::State::Result->new($test_suite_data), 19 'App::Prove::State::Result', '... and the object it returns'; 20 21ok $result, 'state_version'; 22ok defined $result->state_version, '... and it should be defined'; 23 24can_ok $result, 'generation'; 25is $result->generation, $test_suite_data->{generation}, 26 '... and it should return the correct generation'; 27 28can_ok $result, 'num_tests'; 29is $result->num_tests, scalar keys %{ $test_suite_data->{tests} }, 30 '... and it should return the number of tests run'; 31 32can_ok $result, 'raw'; 33is_deeply $result->raw, $test_suite_data, 34 '... and it should return the raw, unblessed data'; 35 36# 37# Check individual tests. 38# 39 40can_ok $result, 'tests'; 41 42can_ok $result, 'test'; 43eval { $result->test }; 44my $error = $@; 45like $error, qr/^\Qtest() requires a test name/, 46 '... and it should croak() if a test name is not supplied'; 47 48my $name = 't/compat/failure.t'; 49ok my $test = $result->test('t/compat/failure.t'), 50 'result() should succeed if the test name is found'; 51isa_ok $test, 'App::Prove::State::Result::Test', 52 '... and the object it returns'; 53 54can_ok $test, 'name'; 55is $test->name, $name, '... and it should return the test name'; 56 57can_ok $test, 'last_pass_time'; 58like $test->last_pass_time, qr/^\d+\.\d+$/, 59 '... and it should return a numeric value'; 60 61can_ok $test, 'last_fail_time'; 62ok !defined $test->last_fail_time, 63 '... and it should return undef if the test has never failed'; 64 65can_ok $result, 'remove'; 66ok $result->remove($name), '... and calling it should succeed'; 67 68ok $test = $result->test($name), 69 '... and fetching the removed test should suceed'; 70ok !defined $test->last_pass_time, '... and it should have clean values'; 71 72sub 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} 149