[svn-upgrade] new version libtest-inter-perl (1.02)
Maximilian Gass
12 years ago
7 | 7 | 'IO::File' => '0', |
8 | 8 | ); |
9 | 9 | my %build_mods = ( |
10 | 'Test::Pod' => '0', | |
11 | 'Test::Pod::Coverage' => '0', | |
12 | 10 | ); |
13 | 11 | |
14 | 12 | |
15 | 13 | my $build = Module::Build->new( |
16 | 14 | license => 'perl', |
17 | dist_version => '1.01', | |
15 | dist_version => '1.02', | |
18 | 16 | dist_author => 'Sullivan Beck <sbeck@cpan.org>', |
19 | 17 | module_name => 'Test::Inter', |
20 | 18 | dist_abstract => 'framework for more readable interactive test scripts', |
21 | 19 | requires => \%requires, |
22 | build_requires => {}, | |
23 | build_recommends => \%build_mods, | |
20 | build_requires => \%build_mods, | |
24 | 21 | sign => 1, |
25 | 22 | ); |
26 | 23 |
4 | 4 | Version 1.01 2010-04-29 |
5 | 5 | Use File::Basename and IO::File to get rid of two unix dependencies. |
6 | 6 | |
7 | Version 1.02 2011-06-23 | |
8 | Added 'width' method. | |
9 | Updated some tests which did not run correctly with perl 5.015. Renee Baecker | |
10 | ||
11 | Version 1.03 |
12 | 12 | provides: |
13 | 13 | Test::Inter: |
14 | 14 | file: lib/Test/Inter.pm |
15 | version: 1.01 | |
15 | version: 1.02 | |
16 | 16 | requires: |
17 | 17 | File::Basename: 0 |
18 | 18 | IO::File: 0 |
19 | 19 | perl: 5.004 |
20 | 20 | resources: |
21 | 21 | license: http://dev.perl.org/licenses/ |
22 | version: 1.01 | |
22 | version: 1.02 |
5 | 5 | my %requires = ( |
6 | 6 | 'File::Basename' => '0', |
7 | 7 | 'IO::File' => '0', |
8 | 'Test::Pod' => '0', | |
9 | 'Test::Pod::Coverage' => '0', | |
10 | 8 | ); |
11 | 9 | |
12 | 10 | |
13 | 11 | WriteMakefile( |
14 | 12 | NAME => 'Test::Inter', |
15 | VERSION => '1.01', | |
13 | VERSION => '1.02', | |
16 | 14 | ($] >= 5.004 |
17 | 15 | ? (ABSTRACT=>'framework for more readable interactive test scripts', |
18 | 16 | AUTHOR =>'Sullivan Beck (sbeck@cpan.org)') |
233 | 233 | quiet |
234 | 234 | mode |
235 | 235 | skip_all |
236 | width | |
236 | 237 | |
237 | 238 | version |
238 | 239 | $o->version(); |
368 | 369 | When run in interactive mode, it prints out results in a more human |
369 | 370 | readable format. |
370 | 371 | |
372 | width | |
373 | $o = new Test::Inter 'width' => WIDTH; | |
374 | $o->width(WIDTH); | |
375 | ||
376 | The width option can be set using a ('width',WIDTH) option pair, or | |
377 | by setting the TI_WIDTH environment variable, or the $::TI_WIDTH | |
378 | global variable. | |
379 | ||
380 | WIDTH is the width of the terminal (for printing out failed test | |
381 | information). It defaults to 80, but it can be set to any width (and | |
382 | lines longer then this are truncated). If WIDTH is set to 0, no | |
383 | truncation is done. | |
384 | ||
371 | 385 | skip_all |
372 | 386 | $o = new Test::Inter 'skip_all' => REASON; |
373 | 387 | $o->skip_all(REASON); |
457 | 471 | |
458 | 472 | If $mode is passed in, it must be either the string 'forbid' or |
459 | 473 | 'feature'. |
474 | ||
475 | If $mode is 'feature', a feature named $module is set if the module | |
476 | was able to be loaded. | |
460 | 477 | |
461 | 478 | use_ok |
462 | 479 | $o->use_ok(@args [,$mode]); |
888 | 905 | tests => "(a b) c" |
889 | 906 | |
890 | 907 | Although parens are optional, they may make things more readable, and |
891 | allow you to use something other than whitespsace as the delimiter. | |
908 | allow you to use something other than whitespace as the delimiter. | |
892 | 909 | |
893 | 910 | If the character immediately following the opening paren, brace, or |
894 | 911 | bracket is a punctuation mark, then it is used as the delimiter instead |
974 | 991 | |
975 | 992 | I wrote a very basic version of my test framework which allowed me to |
976 | 993 | write all of the tests as a string, it would parse the string, count the |
977 | tests, ad then run them. | |
994 | tests, and then run them. | |
978 | 995 | |
979 | 996 | Over the years, the functionality I wanted grew, and periodically, I'd |
980 | 997 | go back and reexamine other Test frameworks (primarily Test::More) to |
19 | 19 | Test::Slow |
20 | 20 | to see if there's anything I want to add. |
21 | 21 | |
22 | Look at using Data::PrettyPrintObjects to print out the results. | |
23 | ||
24 | Add support for timing tests: | |
25 | ||
26 | ok 1 (12 ms) | |
27 | ok 2 (23 ms) | |
28 |
2 | 2 | use strict; |
3 | 3 | use warnings; |
4 | 4 | |
5 | use vars qw($o); | |
5 | our($o); | |
6 | 6 | |
7 | 7 | BEGIN { |
8 | 8 | print "The first test will fail, all others will be skipped.\n\n"; |
11 | 11 | use File::Basename; |
12 | 12 | use IO::File; |
13 | 13 | |
14 | use vars qw($VERSION); | |
15 | $VERSION = '1.01'; | |
14 | our($VERSION); | |
15 | $VERSION = '1.02'; | |
16 | 16 | |
17 | 17 | ############################################################################### |
18 | 18 | # BASE METHODS |
48 | 48 | # (this should only be done when |
49 | 49 | # running as an interactive script) |
50 | 50 | 'mode' => 'test', # mode to run script in |
51 | 'width' => 80, # width of terminal | |
51 | 52 | 'features' => {}, # a list of available features |
52 | 53 | |
53 | 54 | 'skipall' => '', # the reason for skipping all |
65 | 66 | |
66 | 67 | # Handle options, environment variables, global variables |
67 | 68 | |
68 | my @opts = qw(start end testnum plan abort quiet mode skip_all); | |
69 | my @opts = qw(start end testnum plan abort quiet mode width skip_all); | |
69 | 70 | my %o = map { $_,1 } @opts; |
70 | 71 | |
71 | 72 | no strict 'refs'; |
208 | 209 | my($self,$val) = @_; |
209 | 210 | $val = 'test' if (! $val); |
210 | 211 | $$self{'mode'} = $val; |
212 | } | |
213 | ||
214 | sub width { | |
215 | my($self,$val) = @_; | |
216 | $val = 0 if (! $val); | |
217 | $$self{'width'} = $val; | |
211 | 218 | } |
212 | 219 | |
213 | 220 | sub skip_all { |
713 | 720 | sub _stringify { |
714 | 721 | my($self,$s) = @_; |
715 | 722 | |
716 | my($str) = $self->__stringify($s); | |
717 | $str = substr($str,0,60) if (length($str)>60); | |
723 | my($str) = $self->__stringify($s); | |
724 | my($width) = $$self{'width'}; | |
725 | if ($width) { | |
726 | $width -= 21; # The leading string | |
727 | $width = 10 if ($width < 10); | |
728 | $str = substr($str,0,$width) if (length($str)>$width); | |
729 | } | |
718 | 730 | return $str; |
719 | 731 | } |
732 | ||
720 | 733 | sub __stringify { |
721 | 734 | my($self,$s) = @_; |
722 | 735 |
268 | 268 | quiet |
269 | 269 | mode |
270 | 270 | skip_all |
271 | width | |
271 | 272 | |
272 | 273 | =item B<version> |
273 | 274 | |
411 | 412 | When run in interactive mode, it prints out results in a more |
412 | 413 | human readable format. |
413 | 414 | |
415 | =item B<width> | |
416 | ||
417 | $o = new Test::Inter 'width' => WIDTH; | |
418 | $o->width(WIDTH); | |
419 | ||
420 | The width option can be set using a ('width',WIDTH) option pair, or | |
421 | by setting the TI_WIDTH environment variable, or the $::TI_WIDTH | |
422 | global variable. | |
423 | ||
424 | WIDTH is the width of the terminal (for printing out failed test | |
425 | information). It defaults to 80, but it can be set to any width (and | |
426 | lines longer then this are truncated). If WIDTH is set to 0, no | |
427 | truncation is done. | |
428 | ||
414 | 429 | =item B<skip_all> |
415 | 430 | |
416 | 431 | $o = new Test::Inter 'skip_all' => REASON; |
517 | 532 | |
518 | 533 | If $mode is passed in, it must be either the string 'forbid' or |
519 | 534 | 'feature'. |
535 | ||
536 | If $mode is 'feature', a feature named $module is set if the module | |
537 | was able to be loaded. | |
520 | 538 | |
521 | 539 | =item B<use_ok> |
522 | 540 | |
690 | 708 | |
691 | 709 | =over 4 |
692 | 710 | |
693 | =item name | |
711 | =item B<name> | |
694 | 712 | |
695 | 713 | name => NAME |
696 | 714 | |
697 | 715 | This sets the name of this set of tests. All tests will be given the |
698 | 716 | same name. |
699 | 717 | |
700 | =item tests | |
701 | ||
702 | =item func | |
703 | ||
704 | =item expected | |
718 | =item B<tests> | |
719 | ||
720 | =item B<func> | |
721 | ||
722 | =item B<expected> | |
705 | 723 | |
706 | 724 | In order to specify a series of tests, you have to specify either |
707 | 725 | a function and a list of arguments, or a list of results. |
725 | 743 | |
726 | 744 | The way to specify these are covered in the next section SPECIFYING THE TESTS. |
727 | 745 | |
728 | =item feature | |
729 | ||
730 | =item disable | |
746 | =item B<feature> | |
747 | ||
748 | =item B<disable> | |
731 | 749 | |
732 | 750 | feature => [FEATURE1, FEATURE2, ...] |
733 | 751 | |
745 | 763 | If the disable option is included, the tests will be run unless ANY of the features |
746 | 764 | listed are available. |
747 | 765 | |
748 | =item skip | |
766 | =item B<skip> | |
749 | 767 | |
750 | 768 | skip => REASON |
751 | 769 | |
752 | 770 | Skip these tests for the reason given. |
753 | 771 | |
754 | =item todo | |
772 | =item B<todo> | |
755 | 773 | |
756 | 774 | todo => 0/1 |
757 | 775 | |
974 | 992 | tests => "(a b) c" |
975 | 993 | |
976 | 994 | Although parens are optional, they may make things more readable, and allow |
977 | you to use something other than whitespsace as the delimiter. | |
995 | you to use something other than whitespace as the delimiter. | |
978 | 996 | |
979 | 997 | If the character immediately following the opening paren, brace, or |
980 | 998 | bracket is a punctuation mark, then it is used as the delimiter |
1061 | 1079 | |
1062 | 1080 | I wrote a very basic version of my test framework which allowed me to |
1063 | 1081 | write all of the tests as a string, it would parse the string, count |
1064 | the tests, ad then run them. | |
1082 | the tests, and then run them. | |
1065 | 1083 | |
1066 | 1084 | Over the years, the functionality I wanted grew, and periodically, I'd |
1067 | 1085 | go back and reexamine other Test frameworks (primarily Test::More) to |
6 | 6 | my $o = new Test::Inter; |
7 | 7 | |
8 | 8 | $o->require_ok('5.001'); |
9 | $o->require_ok('5.015','forbid'); | |
9 | $o->require_ok('7.001','forbid'); | |
10 | 10 | $o->require_ok('Config'); |
11 | 11 | $o->require_ok('Xxx::Yyy','forbid'); |
12 | 12 | $o->require_ok('Symbol','feature'); |
2 | 2 | use strict; |
3 | 3 | use warnings; |
4 | 4 | |
5 | use vars qw($o); | |
5 | our($o); | |
6 | 6 | |
7 | 7 | BEGIN { |
8 | 8 | use Test::Inter; |
9 | 9 | $o = new Test::Inter; |
10 | 10 | } |
11 | 11 | |
12 | BEGIN { $o->use_ok('5.015','forbid'); } | |
12 | BEGIN { $o->use_ok('7.001','forbid'); } | |
13 | 13 | BEGIN { $o->use_ok('Config','xxxx','forbid'); } |
14 | 14 | BEGIN { $o->use_ok('Storable',7.01,'dclone','forbid'); } |
15 | 15 |