Option C oc_diagnostics
Loading...
Searching...
No Matches
test_shim.py
Go to the documentation of this file.
1#!/usr/bin/env python3
2# -*- coding: utf-8 -*-
3# tests/test_shim.py
4
5"""
6pytest Compatibility Shim — oc_diagnostics
7==========================================
8
9Purpose
10-------
11Allow CI systems and contributors that use ``pytest`` as their standard
12test-runner entry point to invoke the full ``oc_diagnostics`` test suite
13without knowledge of the custom ``tests/run_tests.py`` runner (OI-20 / FS-11).
14
15How it works
16------------
17A single pytest test function runs ``tests/run_tests.py`` as a subprocess and
18asserts exit code 0. The custom Option C runner is unchanged; this file is a
19thin adapter only.
20
21Usage
22-----
23 pytest tests/test_shim.py # run via pytest
24 python tests/run_tests.py # run directly (preferred for development)
25"""
26
27import os
28import subprocess
29import sys
30
31import pytest
32
33_REPO_ROOT = os.path.normpath(os.path.join(os.path.dirname(__file__), ".."))
34_RUN_TESTS = os.path.join(_REPO_ROOT, "tests", "run_tests.py")
35
36
38 """Run the full oc_diagnostics suite via the custom tests/run_tests.py runner.
39
40 Passes when run_tests.py exits 0 (all non-skipped tests pass).
41 Fails with the captured output when run_tests.py exits non-zero.
42 """
43 result = subprocess.run(
44 [sys.executable, _RUN_TESTS],
45 cwd=_REPO_ROOT,
46 capture_output=True,
47 text=True,
48 timeout=120,
49 )
50
51 if result.returncode != 0:
52 output = (result.stdout + result.stderr).strip()
53 pytest.fail(
54 f"run_tests.py exited with code {result.returncode}:\n{output}"
55 )
test_oc_diagnostics_suite()
Definition test_shim.py:37