In article <[EMAIL PROTECTED]>, "Nicholas Clark"
<[EMAIL PROTECTED]> wrote:

> 2: Term/Cap.t
>       # this is ugly, but -f $0 really *ought* to work
> 
> There seems to be some reliance later on in the test on $0 being reliable, but
> I've not quite figured out where in Term/Cap.pm this is. The test failure is:
> 
> not ok 22 - Tgetent() should dies with bad termcap #     Failed test
> (lib/Term/Cap.t at line 107) #                   'Insecure $ENV{PATH} while
> running with -T switch at ../lib/Term/Cap.pm line 176, <DATA> line 6. ' #    
> doesn't match '(?-xism:failed termcap lookup)'
 
Alright, I tracked down a Debian 2.2 box and verified this failure with taint
mode enabled (and another failure on the same test with taint mode disabled).
This patch fixes both failures, and passes fine on another Linux box.  It
assumes Nick's patch has been checked in, though it shouldn't make a big
difference.

Given my inspectacular track record on this test, this is worth testing before
anyone pokes poor Jarkko with the "check it in" stick.  Copying to perl-qa.

-- c

--- lib/Term/~Cap.t     Sun Oct  7 16:37:06 2001
+++ lib/Term/Cap.t      Mon Oct  8 13:56:09 2001
@@ -1,6 +1,8 @@
 #!./perl
 
+my $file;
 BEGIN {
+       $file = $0;
        chdir 't' if -d 't';
        @INC = '../lib';
 }
@@ -34,14 +36,14 @@
 
 SKIP: {
        # this is ugly, but -f $0 really *ought* to work
-       skip("-f $0 fails, some tests difficult now", 2) unless -f $0;
+       skip("-f $file fails, some tests difficult now", 2) unless -f $file;
 
-       $ENV{TERMCAP} = $ENV{TERMPATH} = $0;
-       ok( grep($0, Term::Cap::termcap_path()), 
+       $ENV{TERMCAP} = $ENV{TERMPATH} = $file;
+       ok( grep($file, Term::Cap::termcap_path()), 
                'termcap_path() should find file from $ENV{TERMCAP}' );
 
        $ENV{TERMCAP} = (grep { $^O eq $_ } qw( os2 MSWin32 dos )) ? 'a:/' : '/';
-       ok( grep($0, Term::Cap::termcap_path()), 
+       ok( grep($file, Term::Cap::termcap_path()), 
                'termcap_path() should find file from $ENV{TERMPATH}' );
 }
 
@@ -100,18 +102,17 @@
 eval { $t = Term::Cap->Tgetent($vals) };
 isn't( $@, '', 'Tgetent() should catch bad termcap file' );
 
-# if there's no valid termcap file found, it should croak
-$vals->{TERM} = '';
-$ENV{TERMPATH} = $0;
-eval { $t = Term::Cap->Tgetent($vals) };
-like( $@, qr/failed termcap lookup/, 'Tgetent() should dies with bad termcap' );
-
 SKIP: {
-       skip( "Can't write 'tcout' file for tests", 8 ) unless $writable;
+       skip( "Can't write 'tcout' file for tests", 9 ) unless $writable;
+
+       # it won't find the termtype in this fake file, so it should croak
+       $vals->{TERM} = 'quux';
+       $ENV{TERMPATH} = 'tcout';
+       eval { $t = Term::Cap->Tgetent($vals) };
+       like( $@, qr/failed termcap/, 'Tgetent() should die with bad termcap' );
 
        # it shouldn't try to read one file more than 32(!) times
        # see __END__ for a really awful termcap example
-
        $ENV{TERMPATH} = join(' ', ('tcout') x 33);
        $vals->{TERM} = 'bar';
        eval { $t = Term::Cap->Tgetent($vals) };

Reply via email to