Improve XML documentation coverage across src modules and sync generated analysis artifacts.
This commit is contained in:
41
tools/tests/test_dtp_parser.py
Normal file
41
tools/tests/test_dtp_parser.py
Normal file
@@ -0,0 +1,41 @@
|
||||
import json
|
||||
import subprocess
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
SNAPSHOT = ROOT / "snapshots" / "js-ordered-consume.dtp"
|
||||
SCRIPT = ROOT / "tools" / "dtp_parse.py"
|
||||
|
||||
|
||||
def walk(node):
|
||||
yield node
|
||||
for child in node.get("children", []):
|
||||
yield from walk(child)
|
||||
|
||||
|
||||
class DtpParserTests(unittest.TestCase):
|
||||
def test_emits_machine_readable_call_tree(self):
|
||||
result = subprocess.run(
|
||||
["python3", str(SCRIPT), str(SNAPSHOT), "--stdout"],
|
||||
cwd=ROOT,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=False,
|
||||
)
|
||||
|
||||
self.assertEqual(result.returncode, 0, msg=result.stderr)
|
||||
payload = json.loads(result.stdout)
|
||||
|
||||
self.assertIn("callTree", payload)
|
||||
self.assertIn("hotspots", payload)
|
||||
self.assertTrue(payload["callTree"]["children"])
|
||||
self.assertTrue(payload["hotspots"]["inclusive"])
|
||||
|
||||
node_names = [node["name"] for node in walk(payload["callTree"])]
|
||||
self.assertTrue(any(not name.startswith("[special:") for name in node_names))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user