我正在尝试将plist文件转换为JUnit样式的XML。我有一个xsl样式表,它将plist转换为JUnit/ANT。
下面是我运行的perl代码,用于将plist转换为XML:
my $parser = XML::LibXML->new();
my $xslt = XML::LibXSLT->new();
my $stylesheet = $xslt->parse_stylesheet_file("\\\~/Hudson/build/workspace/ui-automation/automation\\\ test\\\ suite/plist2junit.xsl");
my $counter = 1;
my @plistFiles = glob('Logs/*/*.plist');
foreach (@plistFiles){
#Escape the file path and specify abosulte path
my $plistFile = $_;
$plistFile =~ s/([ ()])/\\$1/g;
$path2plist = "\\\~/Hudson/build/workspace/ui-automation/automation\\\ test\\\ suite/$plistFile";
#transform the plist file to xml
my $source = $parser->parse_file($path2plist);
my $results = $stylesheet->transform($source);
my $resultsFile = "\\\~/Hudson/build/workspace/ui-automation/automation\\\ test\\\ suite/JUnit/results$counter.xml";
#create the output file
unless(open FILE, '>'.$resultsFile) {
# Die with error message
die "\nUnable to create $file\n";
}
# Write results to the file.
$stylesheet->output_file($results, FILE);
close FILE;
$counter++;
}在Hudson/Jenkins上运行perl脚本后,它将输出以下错误消息:
无法打开~/Hudson/build/workspace/ui-automation/automation\测试\套件/日志/Run\1/自动化\ Results.plist:没有这样的文件或目录
错误是由代码中的my $source = $parser->parse_file($path2plist);引起的。我不明白为什么它找不到/读不到这个文件。
有人知道是什么导致了这个错误吗?
发布于 2012-10-29 05:06:40
在错误消息中提到的路径中有三个明显的错误。
~/Hudson/build/workspace/ui-automation/automation\ test\ suite/Logs/Run\ 1/Automation\ Results.plist这些措施是:
~的目录。也许您打算在那里使用$ENV{HOME}的值?automation\ test\ suite的目录,但可能有一个名为automation test suite的目录。Run\ 1的目录,但可能有一个名为Run 1的目录。https://stackoverflow.com/questions/13115952
复制相似问题