Changeset c02459e in rtems-tools


Ignore:
Timestamp:
Nov 20, 2019, 3:00:46 PM (2 weeks ago)
Author:
Hesham Almatary <Hesham.Almatary@…>
Branches:
master
Children:
83b8f1f
Parents:
d1486f2
git-author:
Hesham Almatary <Hesham.Almatary@…> (11/20/19 15:00:46)
git-committer:
Hesham Almatary <Hesham.Almatary@…> (11/22/19 09:05:23)
Message:

tester: Add basic support to generate JUnit test reports

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tester/rt/test.py

    rd1486f2 rc02459e  
    286286
    287287
     288def generate_junit_report(args, reports, start_time, end_time,
     289                         total, junit_file):
     290
     291    from junit_xml import TestSuite, TestCase
     292    import sys
     293    junit_log = []
     294
     295    junit_prop = {}
     296    junit_prop['Command Line'] = ' '.join(args)
     297    junit_prop['Python'] = sys.version.replace('\n', '')
     298    junit_prop['test_groups'] = []
     299    junit_prop['Host'] = host.label(mode = 'all')
     300    junit_prop['passed_count'] = reports.passed
     301    junit_prop['failed_count'] = reports.failed
     302    junit_prop['user-input_count'] = reports.user_input
     303    junit_prop['expected-fail_count'] = reports.expected_fail
     304    junit_prop['indeterminate_count'] = reports.indeterminate
     305    junit_prop['benchmark_count'] = reports.benchmark
     306    junit_prop['timeout_count'] = reports.timeouts
     307    junit_prop['invalid_count'] = reports.invalids
     308    junit_prop['wrong-version_count'] = reports.wrong_version
     309    junit_prop['wrong-build_count'] = reports.wrong_build
     310    junit_prop['wrong-tools_count'] = reports.wrong_tools
     311    junit_prop['total_count'] = reports.total
     312    time_delta = end_time - start_time
     313    junit_prop['average_test_time'] = str(time_delta / total)
     314    junit_prop['testing_time'] = str(time_delta)
     315
     316    for name in reports.results:
     317        result_type = reports.results[name]['result']
     318        test_parts = name.split('/')
     319        test_category = test_parts[-2]
     320        test_name = test_parts[-1]
     321
     322        junit_result = TestCase(test_name.split('.')[0])
     323        junit_result.category = test_category
     324        if result_type == 'failed' or result_type == 'timeout':
     325            junit_result.add_failure_info(None, reports.results[name]['output'], result_type)
     326
     327        junit_log.append(junit_result)
     328
     329    ts = TestSuite('RTEMS Test Suite', junit_log)
     330    ts.properties = junit_prop
     331    ts.hostname = host.label(mode = 'all')
     332
     333    # write out junit log
     334    with open(junit_file, 'w') as f:
     335        TestSuite.to_file(f, [ts], prettyprint = True)
     336
    288337report_formatters = {
    289         'json': generate_json_report
     338        'json': generate_json_report,
     339        'junit': generate_junit_report
    290340}
    291341
Note: See TracChangeset for help on using the changeset viewer.