Files
quik/.gitea/tests/test_test_results.py
T
karol d27edde5e8
Build and Release APK / Build APK (push) Failing after 2m46s
Gate APK releases on worker factory and Matrix regression tests
2026-10-21 23:00:00 +02:00

55 lines
2.2 KiB
Python

import importlib.util
from pathlib import Path
import tempfile
import unittest
import xml.etree.ElementTree as ET
spec = importlib.util.spec_from_file_location(
'test_results_gate', Path(__file__).parents[1] / 'scripts/check_test_results.py')
gate = importlib.util.module_from_spec(spec)
spec.loader.exec_module(gate)
class ReleaseTestGateTest(unittest.TestCase):
def setUp(self):
self.temp = tempfile.TemporaryDirectory()
self.addCleanup(self.temp.cleanup)
self.directory = Path(self.temp.name)
for classname, names in gate.REQUIRED.items():
suite = ET.Element('testsuite', name=classname)
for name in names or {'regressionTest'}:
ET.SubElement(suite, 'testcase', classname=classname, name=name)
ET.ElementTree(suite).write(self.directory / f'TEST-{classname}.xml')
def change_worker_report(self, change):
path = self.directory / f'TEST-{gate.WORKERS}.xml'
tree = ET.parse(path)
change(tree.getroot())
tree.write(path)
def test_all_required_tests_pass(self):
self.assertEqual(gate.check([self.directory]), 10)
def test_empty_report_directory_blocks_release(self):
with self.assertRaisesRegex(ValueError, 'Missing critical test suite'):
gate.check([self.directory / 'missing'])
def test_failed_worker_test_blocks_release(self):
self.change_worker_report(lambda r: ET.SubElement(r[0], 'failure'))
with self.assertRaisesRegex(ValueError, 'Failed test'):
gate.check([self.directory])
def test_skipped_worker_test_blocks_release(self):
self.change_worker_report(lambda r: ET.SubElement(r[0], 'skipped'))
with self.assertRaisesRegex(ValueError, 'Skipped critical test'):
gate.check([self.directory])
def test_removed_coroutine_worker_test_blocks_release(self):
def remove(root):
for case in list(root):
if case.get('name') == 'matrixCoroutineWorkerIsCreatedByTheApplicationFactory':
root.remove(case)
self.change_worker_report(remove)
with self.assertRaisesRegex(ValueError, 'Missing critical tests'):
gate.check([self.directory])