19 lines
934 B
Python
19 lines
934 B
Python
import pathlib
|
|
import re
|
|
import subprocess
|
|
import unittest
|
|
|
|
ROOT = pathlib.Path(__file__).resolve().parents[1]
|
|
FLOOR = re.compile(r"Python (3\.\d+) or newer")
|
|
|
|
|
|
class PythonFloor(unittest.TestCase):
|
|
def test_every_bin_file_compiles_on_the_python_the_readme_names_as_floor(self):
|
|
named = FLOOR.search((ROOT / "README.md").read_text(encoding="utf-8"))
|
|
self.assertIsNotNone(named, "README.md's Install names `Python 3.N or newer`")
|
|
tracked = subprocess.run(["git", "ls-files", "-z", "bin"], capture_output=True, check=True, cwd=ROOT, text=True).stdout.split("\0")
|
|
self.assertTrue(tracked[0])
|
|
check = "import sys\nfor path in sys.argv[1:]:\n\tcompile(open(path, 'rb').read(), path, 'exec')"
|
|
compiled = subprocess.run(["uv", "run", "--no-project", "--python", named.group(1), "python", "-c", check, *filter(None, tracked)], capture_output=True, cwd=ROOT, text=True)
|
|
self.assertEqual(compiled.returncode, 0, compiled.stderr)
|