if (defined($line) && $line =~ /✓ /) {
# print "using test id****************** $current_test_id";
my %test = %{$tests[$current_test_id]};
$test{'passed'}++;
$test_collection_info{'successful_tests'}++;
$tests[$current_test_id] = \%test;
if ($line =~ /v\ \[WARNING\]/) {
$test_collection_info{'unstable_tests'}++;
}
}
elsif (defined($line) && $line =~ /✗|AssertionFailure/) {
if (!defined($tests[$current_test_id])) {
$test_collection_info{'failed_tests'}++;
}
else {
my %test = %{$tests[$current_test_id]};
$test{'failed'}++;
$test_collection_info{'failed_tests'}++;
push(@{$test{'errors'}}, \$line);
$tests[$current_test_id] = \%test;
}
}
这是怀疑错误的行:
my %test = %{$tests[$current_test_id]};
**错误:**
不能在.pl第105行使用未定义的值作为HASH参考。
如果此脚本中有任何错误,有人可以提供帮助吗?
答案 0 :(得分:4)
我觉得这个代码很像:
my %test = %{$tests[$current_test_id]};
$test{'passed'}++;
$test_collection_info{'successful_tests'}++;
$tests[$current_test_id] = \%test;
可以简化为:
$test_collection_info{'successful_tests'}++;
$tests[$current_test_id]{'passed'}++;
甚至在给定测试通过的第一次工作。