I am trying to convert a plist files into a JUnit style XMLs. I have a xsl stylesheet which converts the plist to JUnit/ANT XML.

Here is the perl code which I run to convert the plist to 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++;
}

After running the perl script on Hudson/Jenkins, it outputs this error message:

Couldn't open ~/Hudson/build/workspace/ui-automation/automation\ test\ suite/Logs/Run\ 1/Automation\ Results.plist: No such file or directory

The error is caused by my $source = $parser->parse_file($path2plist); in the code. I am unable to figure out why it cannot find/read the file.

Anyone know what might be causing the error?

有帮助吗?

解决方案

There are three obvious error in the path mentioned in the error message.

~/Hudson/build/workspace/ui-automation/automation\ test\ suite/Logs/Run\ 1/Automation\ Results.plist

Those are:

  1. There's no directory named ~ in the current directory. Perhaps you meant to use the value of $ENV{HOME} there?
  2. There's no directory named automation\ test\ suite anywhere on your disk, but there is probably one named automation test suite.
  3. Similarly, there's no directory named Run\ 1 anywhere on your disk, but there is probably one named Run 1.
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top