diff options
author | Bastien Nocera <hadess@hadess.net> | 2021-09-07 14:34:51 +0200 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2021-09-07 14:49:25 +0200 |
commit | 69a7cc39db984c8404cbd3530450c7a3f995e959 (patch) | |
tree | fbfc0a2c6fc6b2265994c32d19bcce8a2c3cb65e | |
parent | 9e9e7dc857e368c038606a6c267e377ec0d1c365 (diff) | |
download | upower-69a7cc39db984c8404cbd3530450c7a3f995e959.tar.gz |
ci: Fail CI on skipped tests
Parse the junit results and check whether there are any skipped tests.
-rwxr-xr-x | .ci/fail_skipped_tests.py | 25 | ||||
-rw-r--r-- | .gitlab-ci.yml | 1 |
2 files changed, 26 insertions, 0 deletions
diff --git a/.ci/fail_skipped_tests.py b/.ci/fail_skipped_tests.py new file mode 100755 index 0000000..6349921 --- /dev/null +++ b/.ci/fail_skipped_tests.py @@ -0,0 +1,25 @@ +#!/usr/bin/python3 + +from lxml import etree +import sys + +def format_title(title): + """Put title in a box""" + box = { + 'tl': '╔', 'tr': '╗', 'bl': '╚', 'br': '╝', 'h': '═', 'v': '║', + } + hline = box['h'] * (len(title) + 2) + + return '\n'.join([ + f"{box['tl']}{hline}{box['tr']}", + f"{box['v']} {title} {box['v']}", + f"{box['bl']}{hline}{box['br']}", + ]) + +tree = etree.parse(sys.argv[1]) +for suite in tree.xpath('/testsuites/testsuite'): + skipped = suite.get('skipped') + if int(skipped) != 0: + print(format_title('Tests were skipped when they should not have been. All the tests must be run in the CI'), + end='\n\n', flush=True) + sys.exit(1) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fc6fab5..4ce0c1a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -40,6 +40,7 @@ build_stable: script: - meson _build - meson test -C _build --print-errorlogs --no-stdsplit + - .ci/fail_skipped_tests.py _build/meson-logs/testlog.junit.xml artifacts: when: on_success name: "upower-${CI_COMMIT_REF_NAME}" |