Split test_rebase_apply.sh into individual test files (issue 131)

- test_rebase_apply_pick_preserves.sh
- test_rebase_apply_drop_removes.sh
- test_rebase_apply_edit_updates_role.sh
- test_rebase_apply_edit_preserves_fields.sh
- test_rebase_apply_implicit_pick.sh
- test_rebase_apply_mixed_commands.sh
- test_rebase_apply_empty_lines_preserves.sh
- test_rebase_apply_lenient_orphaned_results.sh
- test_rebase_apply_edit_preserves_tool_calls.sh
- test_rebase_apply_deleting_lines_drops.sh
- test_rebase_apply_all_lines_deleted_keeps.sh

Removed the combined test_rebase_apply.sh file and updated CMakeLists.txt
to include the 11 new individual test files.
This commit is contained in:
2026-06-03 07:02:15 -05:00
parent e65616bfea
commit 949682a176
12 changed files with 264 additions and 2 deletions
+12 -2
View File
@@ -57,8 +57,18 @@ add_dr_test(test_rebase_parser)
# Add rebase content formatting tests
add_dr_test(test_rebase_content)
# Add rebase apply tests
add_dr_test(test_rebase_apply)
# Add rebase apply tests (split into individual tests)
add_dr_test(test_rebase_apply_pick_preserves)
add_dr_test(test_rebase_apply_drop_removes)
add_dr_test(test_rebase_apply_edit_updates_role)
add_dr_test(test_rebase_apply_edit_preserves_fields)
add_dr_test(test_rebase_apply_implicit_pick)
add_dr_test(test_rebase_apply_mixed_commands)
add_dr_test(test_rebase_apply_empty_lines_preserves)
add_dr_test(test_rebase_apply_lenient_orphaned_results)
add_dr_test(test_rebase_apply_edit_preserves_tool_calls)
add_dr_test(test_rebase_apply_deleting_lines_drops)
add_dr_test(test_rebase_apply_all_lines_deleted_keeps)
# Add edit prompt tests (split from test_edit_prompt.sh)
add_dr_test(test_edit_prompt_with_context)
+19
View File
@@ -0,0 +1,19 @@
#!/bin/bash
# test_rebase_apply_all_lines_deleted_keeps.sh - All lines deleted (only header) keeps all messages
# Empty commands - simulates deleting all message lines
lines='[]'
history=$(create_messages_json user "item 0" assistant "item 1")
OUTPUT=$("${DRHARNESS}" -A "$lines" "$history")
# Should have 2 messages (all kept because no commands specified)
msg_count=$(echo "$OUTPUT" | grep -o '"role"' | wc -l)
if [ "$msg_count" -ne 2 ]; then
echo "FAIL: all_lines_deleted_keeps_all - expected 2 messages, got $msg_count"
echo "Got: $OUTPUT"
exit 1
fi
echo "PASS: all_lines_deleted_keeps_all"
+35
View File
@@ -0,0 +1,35 @@
#!/bin/bash
# test_rebase_apply_deleting_lines_drops.sh - Deleting lines from rebase editor drops those messages (issue 120)
# Simulate editing a 6-item history where items 4 and 5 are deleted
# Only items 0-3 are mentioned in the commands
lines=$(create_rebase_lines pick 0 user pick 1 assistant pick 2 tool pick 3 assistant)
history=$(create_messages_json \
user "item 0" assistant "item 1" tool "item 2" assistant "item 3" \
user "item 4" assistant "item 5")
OUTPUT=$("${DRHARNESS}" -A "$lines" "$history")
# Should have 4 messages (items 4 and 5 dropped)
msg_count=$(echo "$OUTPUT" | grep -o '"role"' | wc -l)
if [ "$msg_count" -ne 4 ]; then
echo "FAIL: deleting_lines_drops_messages - expected 4 messages, got $msg_count"
echo "Got: $OUTPUT"
exit 1
fi
# Should not contain item 4 or item 5
if echo "$OUTPUT" | grep -q '"item 4"'; then
echo "FAIL: deleting_lines_drops_messages - item 4 should be dropped"
echo "Got: $OUTPUT"
exit 1
fi
if echo "$OUTPUT" | grep -q '"item 5"'; then
echo "FAIL: deleting_lines_drops_messages - item 5 should be dropped"
echo "Got: $OUTPUT"
exit 1
fi
echo "PASS: deleting_lines_drops_messages"
+25
View File
@@ -0,0 +1,25 @@
#!/bin/bash
# test_rebase_apply_drop_removes.sh - Drop commands remove messages from result
lines=$(create_rebase_lines drop 0 user pick 1 assistant)
history=$(create_messages_json user "hello" assistant "hi there")
OUTPUT=$("${DRHARNESS}" -A "$lines" "$history")
# Should only have one message (the assistant response)
msg_count=$(echo "$OUTPUT" | grep -o '"role"' | wc -l)
if [ "$msg_count" -ne 1 ]; then
echo "FAIL: drop_removes_message - expected 1 message, got $msg_count"
echo "Got: $OUTPUT"
exit 1
fi
# Should not contain the dropped message content
if echo "$OUTPUT" | grep -q '"hello"'; then
echo "FAIL: drop_removes_message - dropped message should not be in output"
echo "Got: $OUTPUT"
exit 1
fi
echo "PASS: drop_removes_message"
+23
View File
@@ -0,0 +1,23 @@
#!/bin/bash
# test_rebase_apply_edit_preserves_fields.sh - Non-edited fields are preserved during edits
lines=$(create_rebase_lines edit 0 assistant)
history=$(create_messages_json user "hello" reasoning "thought process" tool_call_id "call_123")
OUTPUT=$("${DRHARNESS}" -A "$lines" "$history")
# Check reasoning is preserved
if ! echo "$OUTPUT" | grep -q '"thought process"'; then
echo "FAIL: edit_preserves_fields - reasoning should be preserved"
echo "Got: $OUTPUT"
exit 1
fi
# Check tool_call_id is preserved
if ! echo "$OUTPUT" | grep -q '"call_123"'; then
echo "FAIL: edit_preserves_fields - tool_call_id should be preserved"
echo "Got: $OUTPUT"
exit 1
fi
echo "PASS: edit_preserves_fields"
+16
View File
@@ -0,0 +1,16 @@
#!/bin/bash
# test_rebase_apply_edit_preserves_tool_calls.sh - tool_calls field preserved during edit
lines=$(create_rebase_lines edit 0 assistant)
history=$(create_messages_json assistant "calling tool" tool_calls '[{"id":"call_1","type":"function","function":{"name":"test","arguments":"{}"}}]')
OUTPUT=$("${DRHARNESS}" -A "$lines" "$history")
# tool_calls should be preserved
if ! echo "$OUTPUT" | grep -q '"tool_calls"'; then
echo "FAIL: edit_preserves_tool_calls - tool_calls should be preserved during edit"
echo "Got: $OUTPUT"
exit 1
fi
echo "PASS: edit_preserves_tool_calls"
+23
View File
@@ -0,0 +1,23 @@
#!/bin/bash
# test_rebase_apply_edit_updates_role.sh - Edit commands update role
lines=$(create_rebase_lines edit 0 assistant)
history=$(create_messages_json user "hello world")
OUTPUT=$("${DRHARNESS}" -A "$lines" "$history")
# Check role was changed to assistant
if ! echo "$OUTPUT" | grep -q '"role".*"assistant"'; then
echo "FAIL: edit_updates_role - role should be changed to assistant"
echo "Got: $OUTPUT"
exit 1
fi
# Content should still be preserved
if ! echo "$OUTPUT" | grep -q '"hello world"'; then
echo "FAIL: edit_updates_role - content should be preserved during edit"
echo "Got: $OUTPUT"
exit 1
fi
echo "PASS: edit_updates_role"
+18
View File
@@ -0,0 +1,18 @@
#!/bin/bash
# test_rebase_apply_empty_lines_preserves.sh - Empty lines array preserves all messages
lines='[]'
history=$(create_messages_json user "hello" assistant "hi")
OUTPUT=$("${DRHARNESS}" -A "$lines" "$history")
# Should have 2 messages (all implicitly picked)
msg_count=$(echo "$OUTPUT" | grep -o '"role"' | wc -l)
if [ "$msg_count" -ne 2 ]; then
echo "FAIL: empty_lines_preserves_all - expected 2 messages, got $msg_count"
echo "Got: $OUTPUT"
exit 1
fi
echo "PASS: empty_lines_preserves_all"
+19
View File
@@ -0,0 +1,19 @@
#!/bin/bash
# test_rebase_apply_implicit_pick.sh - Messages not referenced by any command are dropped (implicit drop)
# Only specify command for index 0, index 1 should be implicitly dropped
lines=$(create_rebase_lines pick 0 user)
history=$(create_messages_json user "hello" assistant "hi there")
OUTPUT=$("${DRHARNESS}" -A "$lines" "$history")
# Should have 1 message (index 1 dropped)
msg_count=$(echo "$OUTPUT" | grep -o '"role"' | wc -l)
if [ "$msg_count" -ne 1 ]; then
echo "FAIL: implicit_pick - expected 1 message, got $msg_count"
echo "Got: $OUTPUT"
exit 1
fi
echo "PASS: implicit_pick"
+28
View File
@@ -0,0 +1,28 @@
#!/bin/bash
# test_rebase_apply_lenient_orphaned_results.sh - Lenient mode - orphaned tool results are allowed
# Drop the tool call message but keep the result (orphaned)
lines=$(create_rebase_lines drop 0 assistant pick 1 tool)
history=$(create_messages_json \
assistant "" tool_calls '[{"id":"call_1","type":"function","function":{"name":"test","arguments":""}}]' \
tool "result" tool_call_id "call_1")
OUTPUT=$("${DRHARNESS}" -A "$lines" "$history")
# Should have 1 message (the orphaned tool result)
msg_count=$(echo "$OUTPUT" | grep -o '"role"' | wc -l)
if [ "$msg_count" -ne 1 ]; then
echo "FAIL: lenient_orphaned_results - expected 1 message (orphaned result), got $msg_count"
echo "Got: $OUTPUT"
exit 1
fi
# The orphaned tool result should be present
if ! echo "$OUTPUT" | grep -q '"tool"'; then
echo "FAIL: lenient_orphaned_results - orphaned tool result should be present"
echo "Got: $OUTPUT"
exit 1
fi
echo "PASS: lenient_orphaned_results"
+18
View File
@@ -0,0 +1,18 @@
#!/bin/bash
# test_rebase_apply_mixed_commands.sh - Mixed commands (pick, drop, edit)
lines=$(create_rebase_lines pick 0 user drop 1 assistant edit 2 tool)
history=$(create_messages_json user "hello" assistant "hi" tool "result")
OUTPUT=$("${DRHARNESS}" -A "$lines" "$history")
# Should have 2 messages (index 1 dropped)
msg_count=$(echo "$OUTPUT" | grep -o '"role"' | wc -l)
if [ "$msg_count" -ne 2 ]; then
echo "FAIL: mixed_commands - expected 2 messages, got $msg_count"
echo "Got: $OUTPUT"
exit 1
fi
echo "PASS: mixed_commands"
+28
View File
@@ -0,0 +1,28 @@
#!/bin/bash
# test_rebase_apply_pick_preserves.sh - Pick commands preserve messages unchanged
lines=$(create_rebase_lines pick 0 user)
history=$(create_messages_json user "hello world")
OUTPUT=$("${DRHARNESS}" -A "$lines" "$history")
if ! echo "$OUTPUT" | grep -q '"hello world"'; then
echo "FAIL: pick_preserves_message - content should be preserved"
echo "Got: $OUTPUT"
exit 1
fi
if ! echo "$OUTPUT" | grep -q '"role".*"user"'; then
echo "FAIL: pick_preserves_message - role should be preserved"
echo "Got: $OUTPUT"
exit 1
fi
# Check we got 1 message back
if ! echo "$OUTPUT" | grep -q '"role"'; then
echo "FAIL: pick_preserves_message - expected output"
echo "Got: $OUTPUT"
exit 1
fi
echo "PASS: pick_preserves_message"