perl – CppUnit输出到TAP格式转换器

我寻求一个perl模块将CppUnit输出转换为TAP格式。我想使用prove命令后来运行和检查测试。

解决方法

最近我做一些转换从junit xml(不是到TAP格式)。
这是很容易做到使用XML :: Twig模块。
你的代码应该看起来像这样:
use XML::Twig;

my %hash;

my $twig = XML::Twig->new(
   twig_handlers => {
       testcase => sub { # this gets called per each testcase in XML
           my ($t,$e) = @_;
           my $testcase = $e->att("name");
           my $error = $e->field("error") || $e->field("failure");
           my $ok = defined $error ? "not ok" : "ok";
           # you may want to collect
           #   testcase name,result,error message,etc into hash
           $hash{$testcase}{result} = $ok;
           $hash{$testcase}{error}  = $error;
           # ...
       }
   }
);
$twig->parsefile("test.xml");
$twig->purge();

# Now XML processing is done,print hash out in TAP format:
print "1..",scalar(keys(%hash)),"\n";
foreach my $testcase (keys %hash) {
     # print out testcase result using info from hash
     # don't forget to add leading space for errors
     # ...
}

这应该比较容易抛光成工作状态

相关文章

1. 如何去重 #!/usr/bin/perl use strict; my %hash; while(...
最近写了一个perl脚本,实现的功能是将表格中其中两列的数据...
表的数据字典格式如下:如果手动写MySQL建表语句,确认麻烦,...
巡检类工作经常会出具日报,最近在原有日报的基础上又新增了...
在实际生产环境中,常常需要从后台日志中截取报文,报文的形...
最近写的一个perl程序,通过关键词匹配统计其出现的频率,让...