我正在尝试将 plist 文件转换为 JUnit 样式的 XML。我有一个将 plist 转换为 JUnit/ANT XML 的 xsl 样式表。
这是我运行以将 plist 转换为 XML 的 perl 代码:
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\test\suite/Logs/Run\1/Automation\Results.plist:没有这样的文件或目录
该错误是由my $source = $parser->parse_file($path2plist);代码中引起的。我无法弄清楚为什么它无法找到/读取文件。
任何人都知道可能导致错误的原因是什么?