On Thu, 17 Jun 2004, Sam Tregar wrote: > I don't think so. It's not that I mind a Test::More dependency - lots > of my modules use Test::More - but that I'm not interested in > investing the time it would take a to be sure that the new test suite > was as good as the old one. Since the tests don't have tests > themselves it's very expensive (in terms of time) to refactor them.
I mean, keep the old test suit and add a new one covering both the old things and additional things. I am suggesting the following: copy the test.pl file in t/99-old.t or some similar name and change the minimum necessary to cleanly run. Then add further tests in t/01-blabla.t etc. This way you will keep the old test suit in test.pl, add an equal test suit in t/99-old.t and add even more tests in t/01.... Later, once an if you are confident with the new test suit you can remove the test.pl file but this is not necessary. I have already made this addition based on test.pl in the CVS and am I attaching the diff and the new test file for your convenience. There are only a few minor changes 1) the SKIP: label added and the block had to be turned around 2) in several places I got the following warning: "my" variable $template masks earlier declaration in same scope so I removed the my variables here. 3) replacing the plan from 57 to 68 4) replacing use Test by use Test::More After that I ran the whole thing through Devel::Cover and got the following reports: Default: ---------------------------- ------ ------ ------ ------ ------ ------ ------ File stmt branch cond sub pod time total ---------------------------- ------ ------ ------ ------ ------ ------ ------ blib/lib/HTML/Template.pm 84.9 62.8 49.4 84.3 72.2 100.0 73.4 Total 84.9 62.8 49.4 84.3 72.2 100.0 73.4 ---------------------------- ------ ------ ------ ------ ------ ------ ------ With TEST_SHARED_MEMORY=1 ---------------------------- ------ ------ ------ ------ ------ ------ ------ File stmt branch cond sub pod time total ---------------------------- ------ ------ ------ ------ ------ ------ ------ blib/lib/HTML/Template.pm 89.6 66.3 53.7 90.2 72.2 100.0 77.6 Total 89.6 66.3 53.7 90.2 72.2 100.0 77.6 ---------------------------- ------ ------ ------ ------ ------ ------ ------ If you accept this *addition* to the test, I'll be able to add eve more test to increase the coverage of the test suit. (among other things testing the error messages). regards Gabor ps. I know I am pushy. I was told so already.
99-old.t
Description: Troff document
--- test.pl Thu Jun 17 23:20:37 2004 +++ t/99-old.t Fri Jun 18 10:51:08 2004 @@ -2,8 +2,8 @@ # `make test'. After `make install' it should work as `perl test.pl' use strict; -use Test; -BEGIN { plan tests => 57 }; +use Test::More; +BEGIN { plan tests => 68 }; use HTML::Template; ok(1); @@ -306,11 +306,11 @@ # test shared memory - enable by setting the environment variable # TEST_SHARED_MEMORY to 1. -if (!exists($ENV{TEST_SHARED_MEMORY}) or !$ENV{TEST_SHARED_MEMORY}) { - print "Skipping shared memory cache test. See README to enable\n"; - skip(1, 0); - skip(1, 0); -} else { +SKIP: { + skip "Skipping shared memory cache test. See README to enable\n", 2 + if (!exists($ENV{TEST_SHARED_MEMORY}) or !$ENV{TEST_SHARED_MEMORY}); + + require 'IPC/SharedCache.pm'; my $template_prime = HTML::Template->new( filename => 'simple-loop.tmpl', @@ -355,10 +355,10 @@ # test CGI associate bug eval { require 'CGI.pm'; }; -if ($@) { - print "Skipping associate tests, need CGI.pm to test associate\n"; - skip(1, 0); -} else { +SKIP: { + skip "Skipping associate tests, need CGI.pm to test associate\n", 1 + if ($@); + my $query = CGI->new(''); $query->param('AdJecTivE' => 'very'); $template = HTML::Template->new( @@ -541,7 +541,7 @@ $template->output(print_to => *OUT); close(OUT); open(OUT, "blib/test.out") or die $!; -my $output = join('',<OUT>); +$output = join('',<OUT>); close(OUT); ok($output =~ /Bar/); @@ -608,7 +608,7 @@ $output = $template->output; ok($output =~ /Zanzabar!!!/); -my $x; + $template = HTML::Template->new(filename => './templates/include_path/a.tmpl', filter => { sub => sub { @@ -708,7 +708,7 @@ # test nested include path handling -my $template = HTML::Template->new(path => ['templates'], +$template = HTML::Template->new(path => ['templates'], filename => 'include_path/one.tmpl'); $output = $template->output; ok($output =~ /ONE/ and $output =~ /TWO/ and $output =~ /THREE/); @@ -725,7 +725,7 @@ } # test __counter__ -my $template = HTML::Template->new(path => ['templates'], +$template = HTML::Template->new(path => ['templates'], filename => 'counter.tmpl', loop_context_vars => 1); $template->param(foo => [ {a => 'a'}, {a => 'b'}, {a => 'c'} ]); @@ -736,7 +736,7 @@ ok($output =~ /^11a2b3c21x2y3z$/m); # test default -my $template = HTML::Template->new(path => ['templates'], +$template = HTML::Template->new(path => ['templates'], filename => 'default.tmpl'); $template->param(cl => 'clothes'); $template->param(start => 'start'); @@ -752,7 +752,7 @@ # test a case where a different path should stimulate a cache miss # even though the main template is the same -my $template = HTML::Template->new(path => ['templates', +$template = HTML::Template->new(path => ['templates', 'templates/include_path'], filename => 'outer.tmpl', search_path_on_include => 1, @@ -763,7 +763,7 @@ ok($output =~ /I AM OUTER/); ok($output =~ /I AM INNER 1/); -my $template = HTML::Template->new(path => ['templates', +$template = HTML::Template->new(path => ['templates', 'templates/include_path2'], filename => 'outer.tmpl', search_path_on_include => 1, @@ -775,7 +775,7 @@ ok($output =~ /I AM INNER 2/); # try the same thing with the file cache -my $template = HTML::Template->new(path => ['templates', +$template = HTML::Template->new(path => ['templates', 'templates/include_path'], filename => 'outer.tmpl', search_path_on_include => 1, @@ -787,7 +787,7 @@ ok($output =~ /I AM OUTER/); ok($output =~ /I AM INNER 1/); -my $template = HTML::Template->new(path => ['templates', +$template = HTML::Template->new(path => ['templates', 'templates/include_path2'], filename => 'outer.tmpl', search_path_on_include => 1,