Test that every bin/ file compiles on the Python the decision log names as the floor
This commit is contained in:
@@ -6,6 +6,7 @@ import io
|
||||
import json
|
||||
import os
|
||||
import pathlib
|
||||
import re
|
||||
import stat
|
||||
import subprocess
|
||||
import sys
|
||||
@@ -30,6 +31,18 @@ def human(content):
|
||||
return {"type": "user", "message": {"content": content}}
|
||||
|
||||
|
||||
class PythonFloor(unittest.TestCase):
|
||||
def test_every_bin_file_compiles_on_the_python_the_decision_log_names(self):
|
||||
root = pathlib.Path(__file__).resolve().parents[1]
|
||||
named = re.search(r"^## bin/: parses on Python (3\.\d+)$", (root / "docs" / "decisions.md").read_text(), re.MULTILINE)
|
||||
self.assertIsNotNone(named, "docs/decisions.md heads the floor `bin/: parses on Python 3.N`")
|
||||
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).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)
|
||||
|
||||
|
||||
class Sections(unittest.TestCase):
|
||||
def test_keeps_every_headed_section_with_its_bodies(self):
|
||||
text = "# Title\n\nintro\n\n## Goals\n\n1. one\n```sh\n# not a heading\n```\n### Later\n2. two\n#1 priority\n\n## Empty\n\n## Audience\nme\n## Audience\nagain\n# Appendix\nnot audience\n"
|
||||
|
||||
Reference in New Issue
Block a user