From 695186ddfc9e36a95fcb8d751e4e1d2901fe5b20 Mon Sep 17 00:00:00 2001 From: cnc Date: Fri, 5 Jun 2026 22:31:09 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E9=BD=90=20LinuxCNC=20=E6=B3=A8?= =?UTF-8?q?=E9=87=8A=20source-linked=20=E8=A6=86=E7=9B=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test-linuxcnc-source-link.sh | 28 ++++++++++++++++++++++++++-- tests/gcode/linuxcnc_comments.ngc | 3 +++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/test-linuxcnc-source-link.sh b/test-linuxcnc-source-link.sh index 9a6d6ee..ff2471a 100755 --- a/test-linuxcnc-source-link.sh +++ b/test-linuxcnc-source-link.sh @@ -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 = [ diff --git a/tests/gcode/linuxcnc_comments.ngc b/tests/gcode/linuxcnc_comments.ngc index d62fd2d..f15ad72 100644 --- a/tests/gcode/linuxcnc_comments.ngc +++ b/tests/gcode/linuxcnc_comments.ngc @@ -1,4 +1,7 @@ G21 G90 G17 (operator note) G0 X0 Y0 Z1 +G0 X1 (inline motion note) +G0 X2 ;semicolon motion note +;standalone semicolon note M30