Skip to content

Commit

Permalink
hopefully fixes the bash
Browse files Browse the repository at this point in the history
  • Loading branch information
xingyaoww committed Nov 19, 2024
1 parent f2d57f9 commit cf7897b
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions tests/runtime/test_bash.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,31 +602,31 @@ def test_command_output_continuation(temp_dir, runtime_cls, run_as_openhands):
try:
# Start a command that produces output slowly
action = CmdRunAction('for i in {1..5}; do echo $i; sleep 3; done')
action.timeout = 2 # Set timeout to 2 seconds
action.timeout = 2.5 # Set timeout to 2.5 seconds
obs = runtime.run_action(action)
assert obs.content.strip() == '1'
assert obs.metadata.prefix == ''
assert '[The command timed out after 2 seconds.' in obs.metadata.suffix
assert '[The command timed out after 2.5 seconds.' in obs.metadata.suffix

# Continue watching output
action = CmdRunAction('')
action.timeout = 2
action.timeout = 2.5
obs = runtime.run_action(action)
assert '[Command output continued from previous command]' in obs.metadata.prefix
assert obs.content.strip() == '2'
assert '[The command timed out after 2 seconds.' in obs.metadata.suffix
assert '[The command timed out after 2.5 seconds.' in obs.metadata.suffix

# Continue until completion
for expected in ['3', '4', '5']:
action = CmdRunAction('')
action.timeout = 2
action.timeout = 2.5
obs = runtime.run_action(action)
assert (
'[Command output continued from previous command]'
in obs.metadata.prefix
)
assert obs.content.strip() == expected
assert '[The command timed out after 2 seconds.' in obs.metadata.suffix
assert '[The command timed out after 2.5 seconds.' in obs.metadata.suffix

# Final empty command to complete
action = CmdRunAction('')
Expand All @@ -643,34 +643,34 @@ def test_long_running_command_follow_by_execute(
try:
# Test command that produces output slowly
action = CmdRunAction('for i in {1..3}; do echo $i; sleep 3; done')
action.timeout = 2
action.timeout = 2.5
action.blocking = False
obs = runtime.run_action(action)
assert '1' in obs.content # First number should appear before timeout
assert obs.metadata.exit_code == -1 # -1 indicates command is still running
assert '[The command timed out after 2 seconds.' in obs.metadata.suffix
assert '[The command timed out after 2.5 seconds.' in obs.metadata.suffix
assert obs.metadata.prefix == ''

# Continue watching output
action = CmdRunAction('')
action.timeout = 2
action.timeout = 2.5
obs = runtime.run_action(action)
assert '2' in obs.content
assert (
obs.metadata.prefix == '[Command output continued from previous command]\n'
)
assert '[The command timed out after 2 seconds.' in obs.metadata.suffix
assert '[The command timed out after 2.5 seconds.' in obs.metadata.suffix
assert obs.metadata.exit_code == -1 # -1 indicates command is still running

# Test command that produces no output
action = CmdRunAction('sleep 15')
action.timeout = 2
action.timeout = 2.5
obs = runtime.run_action(action)
assert '3' in obs.content
assert (
obs.metadata.prefix == '[Command output continued from previous command]\n'
)
assert '[The command timed out after 2 seconds.' in obs.metadata.suffix
assert '[The command timed out after 2.5 seconds.' in obs.metadata.suffix
assert obs.metadata.exit_code == -1 # -1 indicates command is still running
finally:
_close_test_runtime(runtime)
Expand Down

0 comments on commit cf7897b

Please sign in to comment.