diff options
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) |
