Implement WebAssembly runtime and kinematics coverage
This commit is contained in:
63
scripts/test_validate_task_pointer.py
Normal file
63
scripts/test_validate_task_pointer.py
Normal file
@@ -0,0 +1,63 @@
|
||||
#!/usr/bin/env python3
|
||||
import tempfile
|
||||
import unittest
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
from validate_task_pointer import PointerError, validate_pointer
|
||||
|
||||
|
||||
VALID = """# pointer
|
||||
## Current
|
||||
context_id: c1
|
||||
## Read
|
||||
read paths only; coverage/report.json
|
||||
## Task
|
||||
one result
|
||||
## Next
|
||||
one next
|
||||
## Verify
|
||||
one test
|
||||
## Stop
|
||||
stop on drift
|
||||
"""
|
||||
|
||||
|
||||
class TaskPointerTests(unittest.TestCase):
|
||||
def write(self, text: str) -> Path:
|
||||
directory = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(directory.cleanup)
|
||||
path = Path(directory.name) / "nextTask.md"
|
||||
path.write_text(text, encoding="utf-8")
|
||||
return path
|
||||
|
||||
def test_valid_pointer_reports_bounded_size(self):
|
||||
result = validate_pointer(self.write(VALID))
|
||||
self.assertLessEqual(result["bytes"], 8192)
|
||||
|
||||
def test_context_id_must_match_lock_when_supplied(self):
|
||||
directory = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(directory.cleanup)
|
||||
root = Path(directory.name)
|
||||
pointer = root / "nextTask.md"
|
||||
pointer.write_text(VALID, encoding="utf-8")
|
||||
lock = root / "context-lock.json"
|
||||
lock.write_text(json.dumps({"context_id": "other"}), encoding="utf-8")
|
||||
with self.assertRaisesRegex(PointerError, "does not match lock"):
|
||||
validate_pointer(pointer, lock_path=lock)
|
||||
|
||||
def test_history_heading_is_rejected(self):
|
||||
with self.assertRaisesRegex(PointerError, "history section"):
|
||||
validate_pointer(self.write(VALID + "\n## History\nold log\n"))
|
||||
|
||||
def test_evidence_heading_is_rejected(self):
|
||||
with self.assertRaisesRegex(PointerError, "history section"):
|
||||
validate_pointer(self.write(VALID + "\n## Evidence\nold evidence\n"))
|
||||
|
||||
def test_large_pointer_is_rejected(self):
|
||||
with self.assertRaisesRegex(PointerError, "byte budget"):
|
||||
validate_pointer(self.write(VALID + "x" * 9000))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user