Skip to content

Commit 41db93d

Browse files
committed
test: Add test case for process cleanup on error
1 parent d046888 commit 41db93d

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/test_shell_executor.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,3 +600,24 @@ def test_preprocess_command_pipeline(executor):
600600
"grep",
601601
"pattern",
602602
]
603+
604+
605+
@pytest.mark.asyncio
606+
async def test_command_cleanup_on_error(executor, temp_test_dir, monkeypatch):
607+
"""Test cleanup of processes when error occurs"""
608+
clear_env(monkeypatch)
609+
monkeypatch.setenv("ALLOW_COMMANDS", "sleep")
610+
611+
async def execute_with_keyboard_interrupt():
612+
# Simulate keyboard interrupt during execution
613+
result = await executor.execute(
614+
["sleep", "5"],
615+
temp_test_dir,
616+
timeout=1
617+
)
618+
return result
619+
620+
result = await execute_with_keyboard_interrupt()
621+
assert result["error"] == "Command timed out after 1 seconds"
622+
assert result["status"] == -1
623+
assert "execution_time" in result

0 commit comments

Comments
 (0)