The original of this test script was not cleaning up the /tmp directory and was using predicatble filenames there. This was what prompted me to patch it with File::Temp to the rescue. Besides, it was written with mixed line endings, Unix and Windows. This is the reason that the patch became so large. I did not try to understand why the original script used both a xxx.html and a xxx.html.html file. I suppose this just does not matter because now we clean up both. -- andk@cpan.org, 2007-10-30 Nur in HTML-Scrubber-0.08-VMleFs: blib. Nur in HTML-Scrubber-0.08-VMleFs: Makefile. Nur in HTML-Scrubber-0.08-VMleFs: pm_to_blib. diff -urp HTML-Scrubber-0.08-VMleFs.orig/t/06_scrub_file.t HTML-Scrubber-0.08-VMleFs/t/06_scrub_file.t --- HTML-Scrubber-0.08-VMleFs.orig/t/06_scrub_file.t 2003-11-02 12:07:44.000000000 +0100 +++ HTML-Scrubber-0.08-VMleFs/t/06_scrub_file.t 2007-10-30 08:46:03.000000000 +0100 @@ -1,57 +1,61 @@ -# perl Makefile.PL && nmake realclean && cls && perl Makefile.PL && nmake test +# perl Makefile.PL && nmake realclean && cls && perl Makefile.PL && nmake test -use strict; +use strict; use File::Spec; +use File::Temp; use Test::More tests => 10; BEGIN { $^W = 1 } - use_ok( 'HTML::Scrubber' ); +use_ok( 'HTML::Scrubber' ); -my $s = HTML::Scrubber->new; -my $html = q[

hi
start mid1 mid2 end]; +my $s = HTML::Scrubber->new; +my $html = q[

hi
start mid1 mid2 end]; - isa_ok($s, 'HTML::Scrubber'); - -my $tmpdir = File::Spec->tmpdir(); - -SKIP: { - skip "no writable temporary directory found", 6 - unless length $tmpdir - and -d $tmpdir; - - my $tmpfile = File::Spec->catfile($tmpdir,"html-scrubber.test.html"); - my $r = $s->scrub($html,$tmpfile); - $r = "Error: \$@=$@ \$!=$!" unless $r; - is($r, 1, "scrub(\$html,\$tmpfile=$tmpfile)"); - -# use Data::Dumper;die Dumper($s); - - local *FILIS; - open FILIS, "+>$tmpfile" or die "can't write to $tmpfile"; - - $r = $s->scrub($html,\*FILIS); - $r = "Error: \$@=$@ \$!=$!" unless $r; - - is($r, 1, q[scrub($html,\*FILIS)]); - - seek *FILIS,0,0; - $r = join '', readline *FILIS; - is($r,"histart mid1 mid2 end","FILIS has the right stuff"); - is(close(FILIS),1,q[close(FILIS)]); - - $r = $s->scrub_file($tmpfile,"$tmpfile.html"); - $r = "Error: \$@=$@ \$!=$!" unless $r; - - is($r, 1, qq[scrub_file(\$tmpfile,"\$tmpfile.html"=$tmpfile.html)]); - - open FILIS, "+>$tmpfile.html" or die "can't write to $tmpfile"; - $r = $s->scrub_file($tmpfile,\*FILIS); - $r = "Error: \$@=$@ \$!=$!" unless $r; - - is($r, 1, q[scrub_file($tmpfile,\*FILIS)]); - seek *FILIS,0,0; - $r = join '', readline *FILIS; - is($r,"histart mid1 mid2 end","FILIS has the right stuff"); - is(close(FILIS),1,q[close(FILIS)]); - -}; +isa_ok($s, 'HTML::Scrubber'); +my $tmpdir = File::Spec->tmpdir; + +SKIP: { + skip "no writable temporary directory found", 6 + unless length $tmpdir + and -d $tmpdir; + + my $ft = File::Temp->new(template => "html-scrubber-XXXX", + suffix => ".html", + dir => $tmpdir, + ); + my $tmpfile = $ft->filename; + my $r = $s->scrub($html,$tmpfile); + $r = "Error: \$@=$@ \$!=$!" unless $r; + is($r, 1, "scrub(\$html,\$tmpfile=$tmpfile)"); + +# use Data::Dumper;die Dumper($s); + + local *FILIS; + open FILIS, "+>$tmpfile" or die "can't write to $tmpfile"; + + $r = $s->scrub($html,\*FILIS); + $r = "Error: \$@=$@ \$!=$!" unless $r; + + is($r, 1, q[scrub($html,\*FILIS)]); + + seek *FILIS,0,0; + $r = join '', readline *FILIS; + is($r,"histart mid1 mid2 end","FILIS has the right stuff"); + is(close(FILIS),1,q[close(FILIS)]); + + $r = $s->scrub_file($tmpfile,"$tmpfile.html"); + $r = "Error: \$@=$@ \$!=$!" unless $r; + + is($r, 1, qq[scrub_file(\$tmpfile,"\$tmpfile.html"=$tmpfile.html)]); + + open FILIS, "+>$tmpfile.html" or die "can't write to $tmpfile"; + $r = $s->scrub_file($tmpfile,\*FILIS); + $r = "Error: \$@=$@ \$!=$!" unless $r; + + is($r, 1, q[scrub_file($tmpfile,\*FILIS)]); + seek *FILIS,0,0; + $r = join '', readline *FILIS; + is($r,"histart mid1 mid2 end","FILIS has the right stuff"); + is(close(FILIS),1,q[close(FILIS)]); + 1 while unlink "$tmpfile.html"; # = .html.html +}; Nur in HTML-Scrubber-0.08-VMleFs/t: 06_scrub_file.t~.