[ 
https://issues.jenkins-ci.org/browse/JENKINS-12898?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=159576#comment-159576
 ] 

Chris Withers commented on JENKINS-12898:
-----------------------------------------

If it helps, here's a chunk of python that does "the right thing" with 
valgrind's xml output to get it to pass happily into xUnit's JUnit plugin:


import xml.etree.ElementTree as ET

doc = ET.parse('/home/cwithers/Downloads/valgrind-59.xml')
errors = doc.findall('.//error')

suite = ET.Element('testsuite', name='cppunit')
suite.set('failures', '0')

for error in errors:
    what = error.find('what')
    kind = error.find('kind').text
    if  what == None: 
        what = error.find('xwhat/text')
    test = ET.SubElement(suite, 'testcase',
                         classname="valgrind")
    err = ET.SubElement(test, 'error',
                        type=kind,
                        message=what.text)
    stack = []
    test_name = None
    for frame in error.find('stack'):
        fn_node = frame.find('fn')
        file_node = frame.find('file')
        if file_node is None:
            file_node = frame.find('obj')
        else:
            test_name = file_node.text
        line_node = frame.find('line')
        stack.append(
            ' %s (%s:%s)' % (
                fn_node.text if fn_node is not None else '???',
                file_node.text if file_node is not None else '<unknown>',
                line_node.text if line_node is not None else '???',
                ))
    err.text = '\n'.join(stack)

    suffix = kind + ' ' + error.find('unique').text
    if test_name is None:
        test_name = suffix
    else:
        test_name = test_name + ' ' + suffix
    test.set('name', test_name)

if not errors:
    test = ET.SubElement(suite, 'testcase', classname="valgrind", 
name="memcheck", time="0")

suite.set('tests', str(len(suite.findall('.//testcase'))))
suite.set('errors', str(len(errors)))

with open("valgrind-junit.xml", 'w') as f:
    f.write(u'<?xml version="1.0" encoding="UTF-8"?>')
    f.write(ET.tostring(suite, encoding='utf-8'))

                
> Option for Valgrind report to include each problem as a test failure
> --------------------------------------------------------------------
>
>                 Key: JENKINS-12898
>                 URL: https://issues.jenkins-ci.org/browse/JENKINS-12898
>             Project: Jenkins
>          Issue Type: Improvement
>          Components: xunit
>            Reporter: Chris Withers
>            Assignee: gbois
>            Priority: Minor
>
> It would be great if Valgrind xml could be turned into 
> one-test-failure-per-error as an option.
> The current support turns the whole valgrind run into one test, which either 
> passes or fails.
> This is great if you're starting from a zero-problem situation, however, if 
> you're starting from a 1000s-of-problems situation, it would be great to be 
> able to see the trend graph going down over time.
> I believe the proposal I make will address this, and might only need an xslt, 
> but I don't have the xml skills to make that work...

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.jenkins-ci.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to