Add LinuxCNC cutter compensation coverage

This commit is contained in:
cnc
2026-05-22 15:21:34 +08:00
parent 0ff0058417
commit 3dae570f88
5 changed files with 131 additions and 1 deletions

View File

@@ -46,6 +46,7 @@ CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs274_dump" tests/gcode/linux
CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs274_dump" tests/gcode/linuxcnc_tool_length.ngc >/tmp/cnc_sim_linuxcnc_tool_length.json
CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs274_dump" tests/gcode/linuxcnc_canned_cycle.ngc >/tmp/cnc_sim_linuxcnc_canned_cycle.json
CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs274_dump" tests/gcode/linuxcnc_canned_cycles_extended.ngc >/tmp/cnc_sim_linuxcnc_canned_cycles_extended.json
CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs274_dump" tests/gcode/linuxcnc_cutter_comp.ngc >/tmp/cnc_sim_linuxcnc_cutter_comp.json
CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs274_dump" tests/gcode/linuxcnc_comments.ngc >/tmp/cnc_sim_linuxcnc_comments.json
CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs274_dump" tests/gcode/linuxcnc_probe_no_error.ngc >/tmp/cnc_sim_linuxcnc_probe_no_error.json
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs274_dump" tests/gcode/smoke_oword_subprogram.ngc >/tmp/cnc_sim_linuxcnc_oword_subprogram.json
@@ -213,6 +214,28 @@ if not any(
):
raise SystemExit("missing G83 final retract to R plane")
cutter_comp = json.loads(Path("/tmp/cnc_sim_linuxcnc_cutter_comp.json").read_text())
cutter_comp_motions = [
event
for event in cutter_comp
if event["type"] in {"rapid", "linear-feed", "arc-feed"}
]
expected_cutter_comp = [
("rapid", 2, 0, 0),
("linear-feed", 6, 17, 3),
("linear-feed", 7, 17, 20),
("linear-feed", 8, 0, 0),
("linear-feed", 11, 17, -3),
("linear-feed", 12, 17, -20),
("linear-feed", 13, 0, 0),
]
actual_cutter_comp = [
(event["type"], event["line"], event["end"]["x"], event["end"]["y"])
for event in cutter_comp_motions
]
if actual_cutter_comp != expected_cutter_comp:
raise SystemExit(f"unexpected cutter compensation path: {actual_cutter_comp!r}")
comments = json.loads(Path("/tmp/cnc_sim_linuxcnc_comments.json").read_text())
if not any(event["type"] == "comment" and event["line"] == 2 for event in comments):
raise SystemExit("missing LinuxCNC comment line event")
@@ -309,6 +332,7 @@ echo "dumped /tmp/cnc_sim_linuxcnc_motion_modes.json"
echo "dumped /tmp/cnc_sim_linuxcnc_tool_length.json"
echo "dumped /tmp/cnc_sim_linuxcnc_canned_cycle.json"
echo "dumped /tmp/cnc_sim_linuxcnc_canned_cycles_extended.json"
echo "dumped /tmp/cnc_sim_linuxcnc_cutter_comp.json"
echo "dumped /tmp/cnc_sim_linuxcnc_comments.json"
echo "dumped /tmp/cnc_sim_linuxcnc_probe_no_error.json"
echo "dumped /tmp/cnc_sim_linuxcnc_oword_subprogram.json"