develooper Front page | perl.perl5.porters | Postings from August 2008

Re: Test::Harness differences - ./lib/Test/Harness/t/compat/test-harness-compat.t

Thread Previous | Thread Next
From:
Richard Foley
Date:
August 2, 2008 03:46
Subject:
Re: Test::Harness differences - ./lib/Test/Harness/t/compat/test-harness-compat.t
Message ID:
200808021252.44910.Richard.Foley@rfi.net
> More troubling, it seems that t/compat/test-harness-compat.t is currently
> skipped, and slowly diverging from the master.
>
It seems to me that the reason it is skipped is that it dies when you run it:

	$> perl ./lib/Test/Harness/t/compat/test-harness-compat.t	
	1..120
	# Looks like your test died before it could output anything.

For no apparent reason, other than this remark under FIXME.

> +    if ($ENV{PERL_CORE}) {
> +	# FIXME
> +	print "1..0 # Skip until we figure out why it exists with no output just 
> 	after the plan\n"; 
> +	exit 0;

I made it into TAP::Parser, where $source is checked whether it is a 
reference, or an existing file, and if neither it croaks.  The $source when I 
ran it was an existing directory, yet both checks failed, and it bailed with 
a croak.  The croak is silent, (for some other reason - perhaps it's been 
helpfully redefined or somesuch), and this is where we die with no error 
message above.  Here's the code in question:

# TAP::Parser - lines 459->474

            if ( ref $source ) {
                $stream = $self->_iterator_for_source($source);
            }
            elsif ( -e $source ) {
                my $perl = $self->make_perl_source;

                $perl->switches($switches)
                  if $switches;

                $perl->merge($merge);    # XXX args to new()?
                $perl->source( [ $source, @test_args ] );
                $stream = $perl->get_stream($self);
            }
            else {
                $self->_croak("Cannot determine source for $source");
            }

Taking a look with the debugger shows that $source is an existing directory, 
which should return true via '-e $source', but it returns false instead...

  DB<9> .
TAP::Parser::_initialize(/usr/lib/perl5/5.8.8/TAP/Parser.pm:474):
474:                    $self->_croak("Cannot determine source for $source");
  DB<9> p $source
t/sample-tests/descriptive
  DB<10> !! ls -ld $source
drwxr-xr-x 31 perlsource users 6784 2008-07-31 23:28 .
  DB<11> p "exists\n" if -e $source

  DB<12> s
TAP::Object::_croak(/usr/lib/perl5/5.8.8/TAP/Object.pm:90):
90:         my $proto = shift;
  DB<12> n
TAP::Object::_croak(/usr/lib/perl5/5.8.8/TAP/Object.pm:91):
91:         require Carp;
  DB<12> n
TAP::Object::_croak(/usr/lib/perl5/5.8.8/TAP/Object.pm:92):
92:         Carp::croak(@_);
  DB<12> p @_
Cannot determine source for t/sample-tests/descriptive
  DB<13> n
# Looks like your test died before it could output anything.
Debugged program terminated.  Use q to quit or R to restart,
  use o inhibit_exit to avoid stopping after program termination,
  h q, h R or h o to get additional info.

Looks to me as though the masked Carp::croak is masking the croaked message, 
as well as the '-e $source' returning false when it should return true.  I 
don't know if this helps someone to actually find, and fix, the actual 
problem...?

-- 
Richard Foley
Ciao - shorter than aufwiedersehen

http://www.rfi.net/

On Thursday 31 July 2008 23:32:17 Nicholas Clark wrote:
> I've just done this:
> 
> Change 34169 by nicholas@mouse-mill on 2008/07/31 21:27:36
> 
> 	Upgrade to Test::Harness 3.13
> 
> 
> ...
> 
> I note the following difference in the modules:
> 
> diff -rpu ../Test-Harness-3.13/lib/TAP/Parser/Grammar.pm 
lib/TAP/Parser/Grammar.pm
> --- ../Test-Harness-3.13/lib/TAP/Parser/Grammar.pm	2008-06-23 
02:50:21.000000000 +0100
> +++ lib/TAP/Parser/Grammar.pm	2008-07-31 20:58:17.000000000 +0100
> @@ -149,7 +149,7 @@ my %language_for;
>                  }
>                  return $self->_make_test_token(
>                      $line,   $ok, $num, $desc,
> -                    uc $dir, $explanation
> +                    $dir, $explanation
>                  );
>              },
>          },
> 
> 
> which appears to be half of change 33092:
> 
> 
> Change 33092 by rgs@stcosmo on 2008/01/28 14:06:59
> 
> 	Warning cleanup, and avoid a double call to uc
> 
> Affected files ...
> 
> ... //depot/perl/lib/TAP/Parser/Grammar.pm#4 edit
> 
> Differences ...
> 
> ==== //depot/perl/lib/TAP/Parser/Grammar.pm#4 (text) ====
> 
> @@ -133,7 +133,7 @@
>                  }
>                  return $self->_make_test_token(
>                      $line,   $ok, $num, $desc,
> -                    uc $dir, $explanation
> +                    $dir, $explanation
>                  );
>              },
>          },
> @@ -372,7 +372,7 @@
>          ok          => $ok,
>          test_num    => $num,
>          description => _trim($desc),
> -        directive   => uc($dir),
> +        directive   => uc($dir || ""),
>          explanation => _trim($explanation),
>          raw         => $line,
>          type        => 'test',
> 
> 
> 
> I'm not sure how half of that got in, and half did not.
> 
> There are 2 differences in the tests. I had to make this change to get tests
> passing:
> 
> diff -rpu ../Test-Harness-3.13/t/grammar.t lib/Test/Harness/t/grammar.t
> --- ../Test-Harness-3.13/t/grammar.t	2008-06-10 02:21:11.000000000 +0100
> +++ lib/Test/Harness/t/grammar.t	2008-07-31 21:47:32.000000000 +0100
> @@ -1,7 +1,16 @@
>  #!/usr/bin/perl -w
>  
>  use strict;
> -use lib 't/lib';
> +
> +BEGIN {
> +    if ( $ENV{PERL_CORE} ) {
> +        chdir 't';
> +        @INC = ( '../lib', 'lib' );
> +    }
> +    else {
> +        unshift @INC, 't/lib';
> +    }
> +}
>  
>  use Test::More tests => 94;
>  
> 
> 
> 
> More troubling, it seems that t/compat/test-harness-compat.t is currently
> skipped, and slowly diverging from the master. diff follows.
> 
> What should we do about this? Does anyone have time in the near future to 
look
> at this and resolve the problem?
> 
> Nicholas Clark
> 
> 
> diff -rpu ../Test-Harness-3.13/t/compat/test-harness-compat.t 
lib/Test/Harness/t/compat/test-harness-compat.t
> --- ../Test-Harness-3.13/t/compat/test-harness-compat.t	2008-06-22 
03:02:57.000000000 +0100
> +++ lib/Test/Harness/t/compat/test-harness-compat.t	2008-07-31 
21:04:45.000000000 +0100
> @@ -1,34 +1,33 @@
>  #!/usr/bin/perl -w
>  
>  BEGIN {
> -    if ( $ENV{PERL_CORE} ) {
> -        chdir 't';
> -        @INC = '../lib';
> -    }
> -    else {
> -        unshift @INC, 't/lib';
> +    if ($ENV{PERL_CORE}) {
> +	# FIXME
> +	print "1..0 # Skip until we figure out why it exists with no output just 
after the plan\n";
> +	exit 0;
>      }
>  }
>  
>  use strict;
>  
> -# use lib 't/lib';
> +use lib 't/lib';
>  
>  use Test::More;
> +
>  use File::Spec;
> +
>  use Test::Harness qw(execute_tests);
>  
>  # unset this global when self-testing ('testcover' and etc issue)
>  local $ENV{HARNESS_PERL_SWITCHES};
>  
> -my $TEST_DIR = $ENV{PERL_CORE} ? 'lib/sample-tests' : 't/sample-tests';
> -
>  {
>  
>      # if the harness wants to save the resulting TAP we shouldn't
>      # do it for our internal calls
>      local $ENV{PERL_TEST_HARNESS_DUMP_TAP} = 0;
>  
> +    my $TEST_DIR = 't/sample-tests';
>      my $PER_LOOP = 4;
>  
>      my $results = {
> @@ -59,110 +58,110 @@ my $TEST_DIR = $ENV{PERL_CORE} ? 'lib/sa
>                )
>            ) => {
>              'failed' => {
> -                "$TEST_DIR/die" => {
> +                't/sample-tests/die' => {
>                      'canon'  => '??',
>                      'estat'  => 1,
>                      'failed' => '??',
>                      'max'    => '??',
> -                    'name'   => "$TEST_DIR/die",
> +                    'name'   => 't/sample-tests/die',
>                      'wstat'  => '256'
>                  },
> -                "$TEST_DIR/die_head_end" => {
> +                't/sample-tests/die_head_end' => {
>                      'canon'  => '??',
>                      'estat'  => 1,
>                      'failed' => '??',
>                      'max'    => '??',
> -                    'name'   => "$TEST_DIR/die_head_end",
> +                    'name'   => 't/sample-tests/die_head_end',
>                      'wstat'  => '256'
>                  },
> -                "$TEST_DIR/die_last_minute" => {
> +                't/sample-tests/die_last_minute' => {
>                      'canon'  => '??',
>                      'estat'  => 1,
>                      'failed' => 0,
>                      'max'    => 4,
> -                    'name'   => "$TEST_DIR/die_last_minute",
> +                    'name'   => 't/sample-tests/die_last_minute',
>                      'wstat'  => '256'
>                  },
> -                "$TEST_DIR/duplicates" => {
> +                't/sample-tests/duplicates' => {
>                      'canon'  => '??',
>                      'estat'  => '',
>                      'failed' => '??',
>                      'max'    => 10,
> -                    'name'   => "$TEST_DIR/duplicates",
> +                    'name'   => 't/sample-tests/duplicates',
>                      'wstat'  => ''
>                  },
> -                "$TEST_DIR/head_fail" => {
> +                't/sample-tests/head_fail' => {
>                      'canon'  => 2,
>                      'estat'  => '',
>                      'failed' => 1,
>                      'max'    => 4,
> -                    'name'   => "$TEST_DIR/head_fail",
> +                    'name'   => 't/sample-tests/head_fail',
>                      'wstat'  => ''
>                  },
> -                "$TEST_DIR/inc_taint" => {
> +                't/sample-tests/inc_taint' => {
>                      'canon'  => 1,
>                      'estat'  => 1,
>                      'failed' => 1,
>                      'max'    => 1,
> -                    'name'   => "$TEST_DIR/inc_taint",
> +                    'name'   => 't/sample-tests/inc_taint',
>                      'wstat'  => '256'
>                  },
> -                "$TEST_DIR/no_nums" => {
> +                't/sample-tests/no_nums' => {
>                      'canon'  => 3,
>                      'estat'  => '',
>                      'failed' => 1,
>                      'max'    => 5,
> -                    'name'   => "$TEST_DIR/no_nums",
> +                    'name'   => 't/sample-tests/no_nums',
>                      'wstat'  => ''
>                  },
> -                "$TEST_DIR/no_output" => {
> +                't/sample-tests/no_output' => {
>                      'canon'  => '??',
>                      'estat'  => '',
>                      'failed' => '??',
>                      'max'    => '??',
> -                    'name'   => "$TEST_DIR/no_output",
> +                    'name'   => 't/sample-tests/no_output',
>                      'wstat'  => ''
>                  },
> -                "$TEST_DIR/simple_fail" => {
> +                't/sample-tests/simple_fail' => {
>                      'canon'  => '2 5',
>                      'estat'  => '',
>                      'failed' => 2,
>                      'max'    => 5,
> -                    'name'   => "$TEST_DIR/simple_fail",
> +                    'name'   => 't/sample-tests/simple_fail',
>                      'wstat'  => ''
>                  },
> -                "$TEST_DIR/todo_misparse" => {
> +                't/sample-tests/todo_misparse' => {
>                      'canon'  => 1,
>                      'estat'  => '',
>                      'failed' => 1,
>                      'max'    => 1,
> -                    'name'   => "$TEST_DIR/todo_misparse",
> +                    'name'   => 't/sample-tests/todo_misparse',
>                      'wstat'  => ''
>                  },
> -                "$TEST_DIR/too_many" => {
> +                't/sample-tests/too_many' => {
>                      'canon'  => '4-7',
>                      'estat'  => 4,
>                      'failed' => 4,
>                      'max'    => 3,
> -                    'name'   => "$TEST_DIR/too_many",
> +                    'name'   => 't/sample-tests/too_many',
>                      'wstat'  => '1024'
>                  },
> -                "$TEST_DIR/vms_nit" => {
> +                't/sample-tests/vms_nit' => {
>                      'canon'  => 1,
>                      'estat'  => '',
>                      'failed' => 1,
>                      'max'    => 2,
> -                    'name'   => "$TEST_DIR/vms_nit",
> +                    'name'   => 't/sample-tests/vms_nit',
>                      'wstat'  => ''
>                  }
>              },
>              'todo' => {
> -                "$TEST_DIR/todo_inline" => {
> +                't/sample-tests/todo_inline' => {
>                      'canon'  => 2,
>                      'estat'  => '',
>                      'failed' => 1,
>                      'max'    => 2,
> -                    'name'   => "$TEST_DIR/todo_inline",
> +                    'name'   => 't/sample-tests/todo_inline',
>                      'wstat'  => ''
>                  }
>              },
> @@ -181,12 +180,12 @@ my $TEST_DIR = $ENV{PERL_CORE} ? 'lib/sa
>            },
>          'die' => {
>              'failed' => {
> -                "$TEST_DIR/die" => {
> +                't/sample-tests/die' => {
>                      'canon'  => '??',
>                      'estat'  => 1,
>                      'failed' => '??',
>                      'max'    => '??',
> -                    'name'   => "$TEST_DIR/die",
> +                    'name'   => 't/sample-tests/die',
>                      'wstat'  => '256'
>                  }
>              },
> @@ -206,12 +205,12 @@ my $TEST_DIR = $ENV{PERL_CORE} ? 'lib/sa
>          },
>          'die_head_end' => {
>              'failed' => {
> -                "$TEST_DIR/die_head_end" => {
> +                't/sample-tests/die_head_end' => {
>                      'canon'  => '??',
>                      'estat'  => 1,
>                      'failed' => '??',
>                      'max'    => '??',
> -                    'name'   => "$TEST_DIR/die_head_end",
> +                    'name'   => 't/sample-tests/die_head_end',
>                      'wstat'  => '256'
>                  }
>              },
> @@ -231,12 +230,12 @@ my $TEST_DIR = $ENV{PERL_CORE} ? 'lib/sa
>          },
>          'die_last_minute' => {
>              'failed' => {
> -                "$TEST_DIR/die_last_minute" => {
> +                't/sample-tests/die_last_minute' => {
>                      'canon'  => '??',
>                      'estat'  => 1,
>                      'failed' => 0,
>                      'max'    => 4,
> -                    'name'   => "$TEST_DIR/die_last_minute",
> +                    'name'   => 't/sample-tests/die_last_minute',
>                      'wstat'  => '256'
>                  }
>              },
> @@ -256,12 +255,12 @@ my $TEST_DIR = $ENV{PERL_CORE} ? 'lib/sa
>          },
>          'duplicates' => {
>              'failed' => {
> -                "$TEST_DIR/duplicates" => {
> +                't/sample-tests/duplicates' => {
>                      'canon'  => '??',
>                      'estat'  => '',
>                      'failed' => '??',
>                      'max'    => 10,
> -                    'name'   => "$TEST_DIR/duplicates",
> +                    'name'   => 't/sample-tests/duplicates',
>                      'wstat'  => ''
>                  }
>              },
> @@ -297,12 +296,12 @@ my $TEST_DIR = $ENV{PERL_CORE} ? 'lib/sa
>          },
>          'head_fail' => {
>              'failed' => {
> -                "$TEST_DIR/head_fail" => {
> +                't/sample-tests/head_fail' => {
>                      'canon'  => 2,
>                      'estat'  => '',
>                      'failed' => 1,
>                      'max'    => 4,
> -                    'name'   => "$TEST_DIR/head_fail",
> +                    'name'   => 't/sample-tests/head_fail',
>                      'wstat'  => ''
>                  }
>              },
> @@ -322,12 +321,12 @@ my $TEST_DIR = $ENV{PERL_CORE} ? 'lib/sa
>          },
>          'inc_taint' => {
>              'failed' => {
> -                "$TEST_DIR/inc_taint" => {
> +                't/sample-tests/inc_taint' => {
>                      'canon'  => 1,
>                      'estat'  => 1,
>                      'failed' => 1,
>                      'max'    => 1,
> -                    'name'   => "$TEST_DIR/inc_taint",
> +                    'name'   => 't/sample-tests/inc_taint',
>                      'wstat'  => '256'
>                  }
>              },
> @@ -379,12 +378,12 @@ my $TEST_DIR = $ENV{PERL_CORE} ? 'lib/sa
>          },
>          'no_nums' => {
>              'failed' => {
> -                "$TEST_DIR/no_nums" => {
> +                't/sample-tests/no_nums' => {
>                      'canon'  => 3,
>                      'estat'  => '',
>                      'failed' => 1,
>                      'max'    => 5,
> -                    'name'   => "$TEST_DIR/no_nums",
> +                    'name'   => 't/sample-tests/no_nums',
>                      'wstat'  => ''
>                  }
>              },
> @@ -404,12 +403,12 @@ my $TEST_DIR = $ENV{PERL_CORE} ? 'lib/sa
>          },
>          'no_output' => {
>              'failed' => {
> -                "$TEST_DIR/no_output" => {
> +                't/sample-tests/no_output' => {
>                      'canon'  => '??',
>                      'estat'  => '',
>                      'failed' => '??',
>                      'max'    => '??',
> -                    'name'   => "$TEST_DIR/no_output",
> +                    'name'   => 't/sample-tests/no_output',
>                      'wstat'  => ''
>                  }
>              },
> @@ -493,12 +492,12 @@ my $TEST_DIR = $ENV{PERL_CORE} ? 'lib/sa
>          },
>          'simple_fail' => {
>              'failed' => {
> -                "$TEST_DIR/simple_fail" => {
> +                't/sample-tests/simple_fail' => {
>                      'canon'  => '2 5',
>                      'estat'  => '',
>                      'failed' => 2,
>                      'max'    => 5,
> -                    'name'   => "$TEST_DIR/simple_fail",
> +                    'name'   => 't/sample-tests/simple_fail',
>                      'wstat'  => ''
>                  }
>              },
> @@ -601,12 +600,12 @@ my $TEST_DIR = $ENV{PERL_CORE} ? 'lib/sa
>                  ( $ENV{PERL5OPT} || '' ) =~ m{(?:^|\s)-[dM]};
>              },
>              'failed' => {
> -                "$TEST_DIR/switches" => {
> +                't/sample-tests/switches' => {
>                      'canon'  => 1,
>                      'estat'  => '',
>                      'failed' => 1,
>                      'max'    => 1,
> -                    'name'   => "$TEST_DIR/switches",
> +                    'name'   => 't/sample-tests/switches',
>                      'wstat'  => ''
>                  }
>              },
> @@ -660,12 +659,12 @@ my $TEST_DIR = $ENV{PERL_CORE} ? 'lib/sa
>          'todo_inline' => {
>              'failed' => {},
>              'todo'   => {
> -                "$TEST_DIR/todo_inline" => {
> +                't/sample-tests/todo_inline' => {
>                      'canon'  => 2,
>                      'estat'  => '',
>                      'failed' => 1,
>                      'max'    => 2,
> -                    'name'   => "$TEST_DIR/todo_inline",
> +                    'name'   => 't/sample-tests/todo_inline',
>                      'wstat'  => ''
>                  }
>              },
> @@ -684,12 +683,12 @@ my $TEST_DIR = $ENV{PERL_CORE} ? 'lib/sa
>          },
>          'todo_misparse' => {
>              'failed' => {
> -                "$TEST_DIR/todo_misparse" => {
> +                't/sample-tests/todo_misparse' => {
>                      'canon'  => 1,
>                      'estat'  => '',
>                      'failed' => 1,
>                      'max'    => 1,
> -                    'name'   => "$TEST_DIR/todo_misparse",
> +                    'name'   => 't/sample-tests/todo_misparse',
>                      'wstat'  => ''
>                  }
>              },
> @@ -709,12 +708,12 @@ my $TEST_DIR = $ENV{PERL_CORE} ? 'lib/sa
>          },
>          'too_many' => {
>              'failed' => {
> -                "$TEST_DIR/too_many" => {
> +                't/sample-tests/too_many' => {
>                      'canon'  => '4-7',
>                      'estat'  => 4,
>                      'failed' => 4,
>                      'max'    => 3,
> -                    'name'   => "$TEST_DIR/too_many",
> +                    'name'   => 't/sample-tests/too_many',
>                      'wstat'  => '1024'
>                  }
>              },
> @@ -734,12 +733,12 @@ my $TEST_DIR = $ENV{PERL_CORE} ? 'lib/sa
>          },
>          'vms_nit' => {
>              'failed' => {
> -                "$TEST_DIR/vms_nit" => {
> +                't/sample-tests/vms_nit' => {
>                      'canon'  => 1,
>                      'estat'  => '',
>                      'failed' => 1,
>                      'max'    => 2,
> -                    'name'   => "$TEST_DIR/vms_nit",
> +                    'name'   => 't/sample-tests/vms_nit',
>                      'wstat'  => ''
>                  }
>              },
> @@ -786,13 +785,13 @@ my $TEST_DIR = $ENV{PERL_CORE} ? 'lib/sa
>          return $hash unless $^O eq 'VMS';
>  
>          while ( my ( $file, $want ) = each %$hash ) {
> -            for (qw( estat wstat )) {
> +            for ( qw( estat wstat ) ) {
>                  if ( exists $want->{$_} ) {
>                      $want->{$_} = $want->{$_} ? 1 : 0;
>                  }
>              }
>          }
> -        return $hash;
> +        return $hash
>      }
>  
>      {
> 

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About