summaryrefslogtreecommitdiff
path: root/pjutest
diff options
context:
space:
mode:
Diffstat (limited to 'pjutest')
-rwxr-xr-xpjutest35
1 files changed, 35 insertions, 0 deletions
diff --git a/pjutest b/pjutest
new file mode 100755
index 0000000..8edc4f2
--- /dev/null
+++ b/pjutest
@@ -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)