Test terminating a background command.
()
| 162 | |
| 163 | @pytest.mark.asyncio |
| 164 | async def test_bash_kill(): |
| 165 | """Test terminating a background command.""" |
| 166 | print("\n=== Testing Bash Kill ===") |
| 167 | |
| 168 | bash_tool = BashTool() |
| 169 | |
| 170 | # Start a long-running background command |
| 171 | result = await bash_tool.execute(command="sleep 100", run_in_background=True) |
| 172 | |
| 173 | assert result.success |
| 174 | bash_id = result.bash_id |
| 175 | print(f"Started long-running command: {bash_id}") |
| 176 | |
| 177 | # Verify it's running |
| 178 | await asyncio.sleep(0.5) |
| 179 | bg_shell = BackgroundShellManager.get(bash_id) |
| 180 | assert bg_shell is not None |
| 181 | assert bg_shell.status == "running" |
| 182 | |
| 183 | # Kill it |
| 184 | bash_kill_tool = BashKillTool() |
| 185 | kill_result = await bash_kill_tool.execute(bash_id=bash_id) |
| 186 | |
| 187 | assert kill_result.success |
| 188 | # exit_code -15 means terminated by SIGTERM |
| 189 | assert kill_result.exit_code == -15 or kill_result.bash_id == bash_id |
| 190 | print(f"Kill result:\n{kill_result.content}") |
| 191 | |
| 192 | # Verify it's removed from manager |
| 193 | bg_shell = BackgroundShellManager.get(bash_id) |
| 194 | assert bg_shell is None |
| 195 | |
| 196 | |
| 197 | @pytest.mark.asyncio |
nothing calls this directly
no test coverage detected