aboutsummaryrefslogtreecommitdiff
path: root/run_tests.py
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2015-03-25 17:32:58 +0200
committerJussi Pakkanen <jpakkane@gmail.com>2015-03-25 17:32:58 +0200
commitfd30a81fa96d613953d22553a38da9abbe015f25 (patch)
tree811937af30024861e099d268259d76f3b39fe7aa /run_tests.py
parentbb28b6b51c2b39ef061214e06b58193e6c88c2ba (diff)
downloadmeson-fd30a81fa96d613953d22553a38da9abbe015f25.zip
meson-fd30a81fa96d613953d22553a38da9abbe015f25.tar.gz
meson-fd30a81fa96d613953d22553a38da9abbe015f25.tar.bz2
Made run_tests.py output test results in junit xml to allow better integration with CI tools.
Diffstat (limited to 'run_tests.py')
-rwxr-xr-xrun_tests.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/run_tests.py b/run_tests.py
index 60278cf..801b20a 100755
--- a/run_tests.py
+++ b/run_tests.py
@@ -19,6 +19,7 @@ import os, subprocess, shutil, sys, platform, signal
import environment
import mesonlib
import argparse
+import xml.etree.ElementTree as ET
from meson import backendlist
@@ -237,6 +238,7 @@ def detect_tests_to_run():
def run_tests():
all_tests = detect_tests_to_run()
logfile = open('meson-test-run.txt', 'w')
+ junit_root = ET.Element('testsuites')
try:
os.mkdir(test_build_dir)
except OSError:
@@ -250,10 +252,20 @@ def run_tests():
if len(test_cases) == 0:
print('\nNot running %s tests.\n' % name)
else:
+ current_suite = ET.SubElement(junit_root, 'testsuite', {'name' : name})
print('\nRunning %s tests.\n' % name)
for t in test_cases:
(msg, stdo, stde) = run_test(t, name != 'failing')
log_text_file(logfile, t, msg, stdo, stde)
+ current_test = ET.SubElement(current_suite, 'testcase', {'name' : os.path.split(t)[-1]})
+ if msg != '':
+ failure = ET.SubElement(current_test, 'failure')
+ failure.text = msg
+ stdoel = ET.SubElement(current_test, 'system-out')
+ stdoel.text = stdo
+ stdeel = ET.SubElement(current_test, 'system-err')
+ stdeel.text = stde
+ ET.ElementTree(element=junit_root).write('meson-test-run.xml', xml_declaration=True, encoding='UTF-8')
def check_file(fname):
linenum = 1