Skip to content

Commit b68e375

Browse files
committed
Fix delete command pattern printing and improve test framework
- Add pattern_deleted flag to ProcessingContext to prevent automatic pattern printing after 'd', 'D', and 'c' commands - Fix test framework to properly interpret escape sequences with echo -e - Correct test expectations for print_line and word_class tests - Add comprehensive unit tests for delete command behavior
1 parent ddd9c88 commit b68e375

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

util/run-gnu-testsuite.sh

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -225,31 +225,33 @@ run_sed_test() {
225225
cd "$test_dir"
226226

227227
# Write input to file
228-
echo -n "$input_text" > input.txt
229-
echo -n "$expected_output" > expected.txt
228+
echo -e "$input_text" > input.txt
229+
echo -e "$expected_output" > expected.txt
230230

231231
# Run Rust sed
232232
local rust_exit_code=0
233233
local rust_output=""
234234
if [[ -n "$flags" ]]; then
235235
rust_output=$("$RUST_SED_BIN" "$flags" "$sed_script" input.txt 2>/dev/null) || rust_exit_code=$?
236236
else
237-
rust_output=$(echo -n "$input_text" | "$RUST_SED_BIN" "$sed_script" 2>/dev/null) || rust_exit_code=$?
237+
rust_output=$(echo -e "$input_text" | "$RUST_SED_BIN" "$sed_script" 2>/dev/null) || rust_exit_code=$?
238238
fi
239239

240240
local test_result=""
241241
local test_status=""
242242
local error_message=""
243243

244-
# Compare with expected output
245-
if [[ "$rust_output" == "$expected_output" && $rust_exit_code -eq 0 ]]; then
244+
# Compare with expected output (interpret escape sequences in expected output too)
245+
local expected_interpreted
246+
expected_interpreted=$(echo -e "$expected_output")
247+
if [[ "$rust_output" == "$expected_interpreted" && $rust_exit_code -eq 0 ]]; then
246248
log_success "$test_name"
247249
PASSED_TESTS=$((PASSED_TESTS + 1))
248250
test_status="PASS"
249251
else
250252
log_error "$test_name"
251253
if [[ "$VERBOSE" == "true" ]]; then
252-
echo " | Expected: '$expected_output'"
254+
echo " | Expected: '$expected_interpreted'"
253255
echo " | Got: '$rust_output' (exit: $rust_exit_code)"
254256
fi
255257
FAILED_TESTS=$((FAILED_TESTS + 1))
@@ -294,15 +296,15 @@ run_basic_tests() {
294296
run_sed_test "delete_range" "2,3d" "line1\nline2\nline3\nline4" "line1\nline4"
295297

296298
# Print command
297-
run_sed_test "print_line" "-n 2p" "line1\nline2\nline3" "line2" "-n"
299+
run_sed_test "print_line" "2p" "line1\nline2\nline3" "line2" "-n"
298300

299301
# Append and insert
300302
run_sed_test "append" "2a\\inserted" "line1\nline2\nline3" "line1\nline2\ninserted\nline3"
301303
run_sed_test "insert" "2i\\inserted" "line1\nline2\nline3" "line1\ninserted\nline2\nline3"
302304

303305
# Character classes
304306
run_sed_test "digit_class" "s/[0-9]/X/g" "abc123def" "abcXXXdef"
305-
run_sed_test "word_class" "s/[a-z]/X/g" "Hello123" "XXXXX123"
307+
run_sed_test "word_class" "s/[a-z]/X/g" "Hello123" "HXXXX123"
306308
}
307309

308310
# Run tests from specific GNU testsuite files that have .inp/.good/.sed triplets

0 commit comments

Comments
 (0)