代码之家  ›  专栏  ›  技术社区  ›  Kurt W. Leucht

为什么Module::Build的testcover给出“使用未初始化值”警告?

  •  1
  • Kurt W. Leucht  · 技术社区  · 16 年前

    我对Module::Build有点陌生,所以可能我做错了什么。当我从“test”更改为“testcover”时,是不是只有我收到警告?Devel::Cover中有错误吗?Module::Build中有错误吗?我可能只是做错了什么。

    更新:我升级到Module::Build 0.34,警告仍然输出。

    更新:看起来像是B::Deparse中的一个bug。希望有一天能修好。

    以下是我的单元测试构建文件:

    use strict;
    use warnings;
    use Module::Build;
    
    my $build = Module::Build->resume (
      properties => {
        config_dir => '_build',
      },
    );
    
    $build->dispatch('test');
    

    当我运行这个单元测试构建文件时,我得到以下输出:

    t\MyLib1.......ok 
    t\MyLib2.......ok 
    t\MyLib3.......ok 
    All tests successful. 
    Files=3, Tests=24,  0 wallclock secs ( 0.00 cusr +  0.00 csys =  0.00 CPU)
    

    但是,当我将调度行更改为“testcover”时,我得到以下输出,其中总是包含一堆“按位和使用未初始化值”警告消息:

    Deleting database D:/Documents and Settings/<username>/My Documents/<SNIP>/cover_db
    t\MyLib1.......ok
    Use of uninitialized value in bitwise and (&) at D:/Perl/lib/B/Deparse.pm line 4252.
    Use of uninitialized value in bitwise and (&) at D:/Perl/lib/B/Deparse.pm line 4252.
    t\MyLib2.......ok
    Use of uninitialized value in bitwise and (&) at D:/Perl/lib/B/Deparse.pm line 4252.
    Use of uninitialized value in bitwise and (&) at D:/Perl/lib/B/Deparse.pm line 4252.
    t\MyLib3.......ok
    Use of uninitialized value in bitwise and (&) at D:/Perl/lib/B/Deparse.pm line 4252.
    Use of uninitialized value in bitwise and (&) at D:/Perl/lib/B/Deparse.pm line 4252.
    All tests successful.
    Files=3, Tests=24,  0 wallclock secs ( 0.00 cusr +  0.00 csys =  0.00 CPU)
    Reading database from D:/Documents and Settings/<username>/My Documents/<SNIP>/cover_db
    
    ---------------------------- ------ ------ ------ ------ ------ ------ ------
    File                           stmt   bran   cond    sub    pod   time  total
    ---------------------------- ------ ------ ------ ------ ------ ------ ------
    .../lib/ActivePerl/Config.pm    0.0    0.0    0.0    0.0    0.0    n/a    0.0
    ...l/lib/ActiveState/Path.pm    0.0    0.0    0.0    0.0  100.0    n/a    4.8
    <SNIP>
    blib/lib/<SNIP>/MyLib2.pm     100.0   90.0    n/a  100.0  100.0    0.0   98.5
    blib/lib/<SNIP>/MyLib3.pm     100.0   90.9  100.0  100.0  100.0    0.6   98.0
    Total                          14.4    6.7    3.8   18.3   20.0  100.0   11.6
    ---------------------------- ------ ------ ------ ------ ------ ------ ------
    
    Writing HTML output to D:/Documents and Settings/<username>/My Documents/<SNIP>/cover_db/coverage.html ...
    done.
    
    2 回复  |  直到 15 年前
        1
  •  2
  •   Sinan Ünür    16 年前

    第4252行是:

    $kid = $op->first;
    if ( $kid->flags & OPf_SPECIAL # Line 4252
     and ( $] < 5.009 ? $kid->pmflags & PMf_SKIPWHITE()
          : $kid->reflags & RXf_SKIPWHITE() ) ) {
    $exprs[0] = "' '";
    }
    

    所以这似乎与 $kid->flags 因为某种原因没有被定义。

    如果你这样做,你会得到什么

    perl -MO=Deparse,-d -e my_test_script
    

    注: 我刚查了一下 repository version of B::Deparse 它的版本是0.89,而与my AS Perl 5.10一起安装的版本是0.83。

    作为临时措施,你能备份吗 Deparse.pm 它是作为Perl提供的,并用当前版本替换它,看看这是否有区别?

        2
  •  0
  •   Kurt W. Leucht    15 年前

    B::Deparse的作者在电子邮件中告诉我,他能够用以下一行代码重现错误:

    % perl -MO=Deparse -we '$r = qr/foo/; my @a = split($r, $_)' 
    BEGIN { $^W = 1; }
    $r = qr/foo/;
    Use of uninitialized value in bitwise and (&) at /usr/lib/perl/5.10/B/Deparse.pm line 4250.
    my(@a) = split(/$r/, $_, 0);
    -e syntax OK
    

    然后他让我把窃听器转发给珀尔巴克。我不知道他在说什么。我希望这个不会掉下来。你们中有谁在读这篇文章的Perl大师想要拿着这个球跑吗?