[gnome-bluetooth/wip/hadess/fix-tests: 2/2] ci: Fail CI when tests are skipped




commit 2808b627ade2bbf6170c89e8cff26e7b252b43f1
Author: Bastien Nocera <hadess hadess net>
Date:   Tue Nov 30 16:00:19 2021 +0100

    ci: Fail CI when tests are skipped

 .ci/fail_skipped_tests.py | 25 +++++++++++++++++++++++++
 .gitlab-ci.yml            |  1 +
 2 files changed, 26 insertions(+)
---
diff --git a/.ci/fail_skipped_tests.py b/.ci/fail_skipped_tests.py
new file mode 100755
index 00000000..63499214
--- /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 c11b469f..14f9a0b0 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -37,6 +37,7 @@ build_stable:
     - cd ..
     - dnf install -y $TEST_DEPS
     - ninja -C _build test
+    - .ci/fail_skipped_tests.py _build/meson-logs/testlog.junit.xml
     - ninja -C _build dist
     - curl https://gitlab.freedesktop.org/hadess/check-abi/-/raw/main/contrib/check-abi-fedora.sh | bash
     - dnf install -y $DEPENDENCIES_ABI_CHECK


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]