补齐 LinuxCNC 注释 source-linked 覆盖

This commit is contained in:
cnc
2026-06-05 22:31:09 +08:00
parent 8394042d18
commit 695186ddfc
2 changed files with 29 additions and 2 deletions

View File

@@ -2889,8 +2889,32 @@ if actual_cutter_comp != expected_cutter_comp:
raise SystemExit(f"unexpected source-linked cutter compensation path: {actual_cutter_comp!r}")
comments = load("cnc_sim_linuxcnc_source_comments.json")
if not any(event["type"] == "comment" and event["line"] == 2 for event in comments):
raise SystemExit("missing source-linked LinuxCNC comment line event")
# Source basis: LinuxCNC src/emc/rs274ngc/interp_read.cc read_comment()
# stores parenthesized comments for convert_comment(), while read_semicolon()
# skips ordinary semicolon comments to end-of-line unless the line starts
# with ;py,. src/emc/rs274ngc/interp_convert.cc convert_comment() emits
# ordinary parenthesized comments through enqueue_COMMENT().
comment_events = [
(index, event["line"])
for index, event in enumerate(comments)
if event["type"] == "comment" and event["reserved"] == 0
]
comment_lines = [line for _, line in comment_events]
for expected_line in (2, 4):
if expected_line not in comment_lines:
raise SystemExit(f"missing source-linked LinuxCNC comment line event {expected_line}")
for unexpected_line in (5, 6):
if unexpected_line in comment_lines:
raise SystemExit(f"unexpected source-linked ordinary semicolon comment event {unexpected_line}")
motion_line4_index = next(
index for index, event in enumerate(comments)
if event["type"] == "rapid" and event["line"] == 4 and event["end"]["x"] == 1
)
comment_line4_index = next(index for index, line in comment_events if line == 4)
if comment_line4_index >= motion_line4_index:
raise SystemExit("source-linked parenthesized inline comment was not emitted before same-line motion")
if not any(event["type"] == "rapid" and event["line"] == 5 and event["end"]["x"] == 2 for event in comments):
raise SystemExit("source-linked semicolon-commented motion line did not execute before line-end comment")
probe = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_probe_no_error.json").read_text())
probe_events = [