diff options
| author | Manuel Traut <manut@linutronix.de> | 2017-09-19 08:51:06 +0200 |
|---|---|---|
| committer | Manuel Traut <manut@linutronix.de> | 2017-09-19 08:51:06 +0200 |
| commit | 6741aee90db710ca4b8a45e2159ddf70c84b171c (patch) | |
| tree | 7b9279d30cfe72d8bfd7c9d50528bbf1de5490a6 /pjutest | |
initial import
Signed-off-by: Manuel Traut <manut@linutronix.de>
Diffstat (limited to 'pjutest')
| -rwxr-xr-x | pjutest | 35 |
1 files changed, 35 insertions, 0 deletions
@@ -0,0 +1,35 @@ +#!/usr/bin/env python3 +# +# pjutest - junit xml generator + +from junit_xml import TestSuite, TestCase +from pickle import dump, load +from subprocess import Popen, PIPE, STDOUT + +import os +import sys + +if len (sys.argv) != 2: + print("%s 'mycmd param1' # to record a test" % sys.argv[0]) + sys.exit(-1) + +if os.path.exists('pjutest.dat'): + with open('pjutest.dat', 'r') as dat: + tss = load(dat) +else: + tss = [TestSuite("suite", None)] + +p = Popen(sys.argv[1], shell=True, stdout=PIPE, stderr=PIPE) +out,err = p.communicate() + +tc = TestCase(sys.argv[1], 'sh', 2, out[:-1], err[:-1]) +if p.returncode: + tc.add_failure_info(err, "return: %d" % p.returncode) + +tss[0].test_cases.append(tc) + +with open('pjutest.dat', 'w') as dat: + dump(tss, dat) + +with open('pjutest.xml', 'w') as xml: + TestSuite.to_file(xml, tss, prettyprint=True) |
