comparison tests/run-tests.py @ 32702:d0b9c36851f5

run-tests: make time field optional for xunit report We're going to use XUnit to list tests, and we don't have a time field in that case.
author Siddharth Agarwal <sid0@fb.com>
date Tue, 06 Jun 2017 13:52:25 -0700
parents 60c921ff4104
children 9d1d3199382e
comparison
equal deleted inserted replaced
32701:60c921ff4104 32702:d0b9c36851f5
2014 len(result.ignored))) 2014 len(result.ignored)))
2015 doc.appendChild(s) 2015 doc.appendChild(s)
2016 for tc in result.successes: 2016 for tc in result.successes:
2017 t = doc.createElement('testcase') 2017 t = doc.createElement('testcase')
2018 t.setAttribute('name', tc.name) 2018 t.setAttribute('name', tc.name)
2019 t.setAttribute('time', '%.3f' % timesd[tc.name]) 2019 tctime = timesd.get(tc.name)
2020 if tctime is not None:
2021 t.setAttribute('time', '%.3f' % tctime)
2020 s.appendChild(t) 2022 s.appendChild(t)
2021 for tc, err in sorted(result.faildata.items()): 2023 for tc, err in sorted(result.faildata.items()):
2022 t = doc.createElement('testcase') 2024 t = doc.createElement('testcase')
2023 t.setAttribute('name', tc) 2025 t.setAttribute('name', tc)
2024 t.setAttribute('time', '%.3f' % timesd[tc]) 2026 tctime = timesd.get(tc)
2027 if tctime is not None:
2028 t.setAttribute('time', '%.3f' % tctime)
2025 # createCDATASection expects a unicode or it will 2029 # createCDATASection expects a unicode or it will
2026 # convert using default conversion rules, which will 2030 # convert using default conversion rules, which will
2027 # fail if string isn't ASCII. 2031 # fail if string isn't ASCII.
2028 err = cdatasafe(err).decode('utf-8', 'replace') 2032 err = cdatasafe(err).decode('utf-8', 'replace')
2029 cd = doc.createCDATASection(err) 2033 cd = doc.createCDATASection(err)