File size: 874 Bytes
2e658e7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env python3
"""Prove that the configured test runner returns non-zero on a failing test."""
from __future__ import annotations

import subprocess
import sys
import tempfile
from pathlib import Path


def main() -> int:
    with tempfile.TemporaryDirectory(prefix="hermes-ci-failure-") as tmp:
        test_file = Path(tmp) / "test_intentional_failure.py"
        test_file.write_text("def test_intentional_failure():\n    assert False\n", encoding="utf-8")
        result = subprocess.run(
            [sys.executable, "-m", "pytest", str(test_file), "-q"],
            capture_output=True,
            text=True,
        )
    if result.returncode == 0:
        print("ERROR: pytest returned success for an intentionally failing test")
        return 1
    print("ci_failure_contract=PASS")
    return 0


if __name__ == "__main__":
    raise SystemExit(main())