okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221merge f-split into f-split-s6326e39118

main
1.3 KiB36 linesraw
1"""Closing always ends the engine: the close-path matrix (tests/terminal/lifecycle_matrix.py) with the fake engine.
2
3Each case starts `strata serve` or `strata runtime start` with an engine package whose entry point is a script,
4ends it one way, and asserts that no process of the tree is left, the port is free and the runtime lease can be taken.
5The cases that need a real console window on Windows run when STRATA_MATRIX_CONSOLE=1 (they open a minimised
6console); everything else runs everywhere the platform has the mechanism.
7"""
8import os
9import unittest
10
11from tests.terminal import lifecycle_matrix as matrix
12
13CONSOLE = {"serve-ctrl-c", "serve-console-close"}
14
15
16@unittest.skipUnless(os.name in ("posix", "nt"), "no qualified owner transport on this platform")
17class LifecycleMatrix(unittest.TestCase):
18    pass
19
20
21def make(name):
22    def test(self):
23        if matrix.WINDOWS and name in CONSOLE and not os.environ.get("STRATA_MATRIX_CONSOLE"):
24            self.skipTest("needs a console window; set STRATA_MATRIX_CONSOLE=1")
25        result = matrix.run([name])[0]
26        self.assertTrue(result["ok"], result.get("problems"))
27    return test
28
29
30for _name in matrix.SCENARIOS:
31    if matrix.applicable(_name):
32        setattr(LifecycleMatrix, "test_" + _name.replace("-", "_"), make(_name))
33
34
35if __name__ == "__main__":
36    unittest.main()