| 1 | # -*- Mode: cperl; cperl-indent-level: 4 -*- | ||
| 2 | |||
| 3 | package Test::Run::Core_GplArt; | ||
| 4 | |||
| 5 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | |||
| 8 | =head1 NAME | ||
| 9 | |||
| 10 | Test::Run::Core_GplArt - GPL/Artistic-licensed code of Test::Run::Core. | ||
| 11 | |||
| 12 | =head1 SYNOPSIS | ||
| 13 | |||
| 14 | use Test::Run::Obj; | ||
| 15 | |||
| 16 | my $tester = Test::Run::Obj->new({'test_files' => \@test_files}); | ||
| 17 | $tester->runtests(); | ||
| 18 | |||
| 19 | =head1 DESCRIPTION | ||
| 20 | |||
| 21 | B<STOP!> If all you want to do is write a test script, consider | ||
| 22 | using Test::Simple. Test::Run::Core is the module that reads the | ||
| 23 | output from Test::Simple, Test::More and other modules based on | ||
| 24 | Test::Builder. You don't need to know about Test::Run::Core to use | ||
| 25 | those modules. | ||
| 26 | |||
| 27 | Test::Run::Core runs tests and expects output from the test in a | ||
| 28 | certain format. That format is called TAP, the Test Anything | ||
| 29 | Protocol. It is defined in L<Test::Harness::TAP>. | ||
| 30 | |||
| 31 | C<$tester->runtests()> runs all the testscripts named | ||
| 32 | as arguments and checks standard output for the expected strings | ||
| 33 | in TAP format. | ||
| 34 | |||
| 35 | L<Test::Run::Obj> is an applicative derived class of Test::Run::Core | ||
| 36 | that provides a programmer API for running and analyzing the output of TAP | ||
| 37 | files. For calling from the command line, look at | ||
| 38 | L<Test::Run::CmdLine>. | ||
| 39 | |||
| 40 | =head2 Taint mode | ||
| 41 | |||
| 42 | Test::Run will honor the C<-T> or C<-t> in the #! line on your | ||
| 43 | test files. So if you begin a test with: | ||
| 44 | |||
| 45 | #!perl -T | ||
| 46 | |||
| 47 | the test will be run with taint mode on. | ||
| 48 | |||
| 49 | |||
| 50 | =head2 Failure | ||
| 51 | |||
| 52 | When tests fail, analyze the summary report: | ||
| 53 | |||
| 54 | t/base..............ok | ||
| 55 | t/nonumbers.........ok | ||
| 56 | t/ok................ok | ||
| 57 | t/test-harness......ok | ||
| 58 | t/waterloo..........dubious | ||
| 59 | Test returned status 3 (wstat 768, 0x300) | ||
| 60 | DIED. FAILED tests 1, 3, 5, 7, 9, 11, 13, 15, 17, 19 | ||
| 61 | Failed 10/20 tests, 50.00% okay | ||
| 62 | Failed Test Stat Wstat Total Fail Failed List of Failed | ||
| 63 | ----------------------------------------------------------------------- | ||
| 64 | t/waterloo.t 3 768 20 10 50.00% 1 3 5 7 9 11 13 15 17 19 | ||
| 65 | Failed 1/5 test scripts, 80.00% okay. 10/44 subtests failed, 77.27% okay. | ||
| 66 | |||
| 67 | Everything passed but F<t/waterloo.t>. It failed 10 of 20 tests and | ||
| 68 | exited with non-zero status indicating something dubious happened. | ||
| 69 | |||
| 70 | The columns in the summary report mean: | ||
| 71 | |||
| 72 | =over 4 | ||
| 73 | |||
| 74 | =item B<Failed Test> | ||
| 75 | |||
| 76 | The test file which failed. | ||
| 77 | |||
| 78 | =item B<Stat> | ||
| 79 | |||
| 80 | If the test exited with non-zero, this is its exit status. | ||
| 81 | |||
| 82 | =item B<Wstat> | ||
| 83 | |||
| 84 | The wait status of the test. | ||
| 85 | |||
| 86 | =item B<Total> | ||
| 87 | |||
| 88 | Total number of tests expected to run. | ||
| 89 | |||
| 90 | =item B<Fail> | ||
| 91 | |||
| 92 | Number which failed, either from "not ok" or because they never ran. | ||
| 93 | |||
| 94 | =item B<Failed> | ||
| 95 | |||
| 96 | Percentage of the total tests which failed. | ||
| 97 | |||
| 98 | =item B<List of Failed> | ||
| 99 | |||
| 100 | A list of the tests which failed. Successive failures may be | ||
| 101 | abbreviated (ie. 15-20 to indicate that tests 15, 16, 17, 18, 19 and | ||
| 102 | 20 failed). | ||
| 103 | |||
| 104 | =back | ||
| 105 | |||
| 106 | |||
| 107 | =head2 Functions | ||
| 108 | |||
| 109 | Test::Run currently only has one interface function, here it is. | ||
| 110 | |||
| 111 | =over 4 | ||
| 112 | |||
| 113 | =item B<runtests> | ||
| 114 | |||
| 115 | my $allok = $self->runtests(); | ||
| 116 | |||
| 117 | This runs all the given I<@test_files> and divines whether they passed | ||
| 118 | or failed based on their output to STDOUT (details above). It prints | ||
| 119 | out each individual test which failed along with a summary report and | ||
| 120 | a how long it all took. | ||
| 121 | |||
| 122 | It returns true if everything was ok. Otherwise it will C<die()> with | ||
| 123 | one of the messages in the DIAGNOSTICS section. | ||
| 124 | |||
| 125 | =cut | ||
| 126 | |||
| 127 | =begin _private | ||
| 128 | |||
| 129 | =item B<_run_all_tests> | ||
| 130 | |||
| 131 | my($total, $failed) = _run_all_tests(); | ||
| 132 | |||
| 133 | Runs all the test_files defined for the object but does it | ||
| 134 | quietly (no report). $total is a hash ref summary of all the tests | ||
| 135 | run. Its keys and values are this: | ||
| 136 | |||
| 137 | bonus Number of individual todo tests unexpectedly passed | ||
| 138 | max Number of individual tests ran | ||
| 139 | ok Number of individual tests passed | ||
| 140 | sub_skipped Number of individual tests skipped | ||
| 141 | todo Number of individual todo tests | ||
| 142 | |||
| 143 | files Number of test files ran | ||
| 144 | good Number of test files passed | ||
| 145 | bad Number of test files failed | ||
| 146 | tests Number of test files originally given | ||
| 147 | skipped Number of test files skipped | ||
| 148 | |||
| 149 | If C<< $total->{bad} == 0 >> and C<< $total->{max} > 0 >>, you've | ||
| 150 | got a successful test. | ||
| 151 | |||
| 152 | $failed is a hash ref of all the test scripts which failed. Each key | ||
| 153 | is the name of a test script, each value is another hash representing | ||
| 154 | how that script failed. Its keys are these: | ||
| 155 | |||
| 156 | name Name of the test which failed | ||
| 157 | estat Script's exit value | ||
| 158 | wstat Script's wait status | ||
| 159 | max Number of individual tests | ||
| 160 | failed Number which failed | ||
| 161 | percent Percentage of tests which failed | ||
| 162 | canon List of tests which failed (as string). | ||
| 163 | |||
| 164 | C<$failed> should be empty if everything passed. | ||
| 165 | |||
| 166 | B<NOTE> Currently this function is still noisy. I'm working on it. | ||
| 167 | |||
| 168 | =cut | ||
| 169 | |||
| 170 | =end _private | ||
| 171 | |||
| 172 | =back | ||
| 173 | |||
| 174 | =cut | ||
| 175 | |||
| 176 | |||
| 177 | 1 | 1; | |
| 178 | __END__ | ||