diff --git a/test-all-native.sh b/test-all-native.sh index 17d1a5d..bb88c59 100755 --- a/test-all-native.sh +++ b/test-all-native.sh @@ -564,6 +564,7 @@ grep -F 'read_n_number()' test-linuxcnc-source-link.sh >/dev/null grep -F 'tests/gcode/linuxcnc_fractional_linenumbers.ngc' test-linuxcnc-source-link.sh >/dev/null grep -F 'tests/gcode/linuxcnc_extended_linenumbers.ngc' test-linuxcnc-source-link.sh >/dev/null grep -F 'tests/gcode/linuxcnc_close_and_downcase_words.ngc' test-linuxcnc-source-link.sh >/dev/null +grep -F 'tests/gcode/linuxcnc_percent_file_ignores_trailing.ngc' test-linuxcnc-source-link.sh >/dev/null for script in \ test-native.sh \ diff --git a/test-linuxcnc-source-link.sh b/test-linuxcnc-source-link.sh index a7c0108..2823f9c 100755 --- a/test-linuxcnc-source-link.sh +++ b/test-linuxcnc-source-link.sh @@ -1501,6 +1501,13 @@ CNC_SIM_RS274_VAR="$var_file" \ CNC_SIM_RS274_VAR="$var_file" \ "$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_close_and_downcase_words.ngc \ >"$output_dir/cnc_sim_linuxcnc_source_close_and_downcase_words.json" +# Source basis: LinuxCNC src/emc/rs274ngc/rs274ngc_pre.cc open() enables +# percent-file mode when the first nonblank line is '%'; read_text() in +# src/emc/rs274ngc/interp_read.cc returns INTERP_ENDFILE at the matching '%', +# so later lines are ignored. +CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \ + "$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_percent_file_ignores_trailing.ngc \ + >"$output_dir/cnc_sim_linuxcnc_source_percent_file_ignores_trailing.json" CNC_SIM_RS274_SOURCE_OUTPUT_DIR="$output_dir" python3 - <<'PY' import json @@ -1572,6 +1579,18 @@ if not any( ): raise SystemExit("missing source-linked close_and_downcase mixed-case spaced-word move") +percent_file = load("cnc_sim_linuxcnc_source_percent_file_ignores_trailing.json") +percent_file_feeds = [ + (event["line"], event["end"]["x"]) + for event in percent_file + if event["type"] == "linear-feed" +] +if percent_file_feeds != [(4, 1)]: + raise SystemExit( + "unexpected source-linked percent-file feed sequence: " + f"{percent_file_feeds!r}" + ) + block_delete_off = load("cnc_sim_linuxcnc_source_block_delete_off.json") if not any( event["type"] == "linear-feed" and event["line"] == 2 and event["end"]["x"] == 5 @@ -3461,3 +3480,4 @@ echo "dumped $output_dir/cnc_sim_linuxcnc_source_g62_xz_nurbs.json" echo "dumped $output_dir/cnc_sim_linuxcnc_source_fractional_linenumbers.json" echo "dumped $output_dir/cnc_sim_linuxcnc_source_extended_linenumbers.json" echo "dumped $output_dir/cnc_sim_linuxcnc_source_close_and_downcase_words.json" +echo "dumped $output_dir/cnc_sim_linuxcnc_source_percent_file_ignores_trailing.json" diff --git a/tests/gcode/linuxcnc_percent_file_ignores_trailing.ngc b/tests/gcode/linuxcnc_percent_file_ignores_trailing.ngc new file mode 100644 index 0000000..aadece0 --- /dev/null +++ b/tests/gcode/linuxcnc_percent_file_ignores_trailing.ngc @@ -0,0 +1,6 @@ +% +G21 G90 +F100 +G1 X1 +% +G1 X99