#131 if `process_name` is specified to `execute_command()` keep the process alive
parent
a741261c15
commit
b8fec00b20
@ -1,6 +1,8 @@
|
||||
{{ additional_info }}I ran the command `{{ command }}` and for this response from CLI:
|
||||
{{ additional_info }}I ran the command `{{ command }}`
|
||||
{%- if exit_code %}, the exit code was {{ exit_code }} {% endif -%}
|
||||
and the output was:
|
||||
```
|
||||
{{ cli_response }}
|
||||
```
|
||||
|
||||
If the command was successfully executed, respond with `DONE` and if it wasn't, respond with `NEEDS_DEBUGGING`.
|
||||
If the command was successfully executed, respond with `DONE` and if it wasn't, respond with `NEEDS_DEBUGGING`.
|
||||
|
||||
@ -0,0 +1,36 @@
|
||||
import pytest
|
||||
from unittest.mock import patch
|
||||
|
||||
from helpers.AgentConvo import AgentConvo
|
||||
from helpers.agents import Developer
|
||||
from .utils import create_project
|
||||
from helpers.cli import terminate_running_processes
|
||||
from test.mock_questionary import MockQuestionary
|
||||
|
||||
|
||||
@pytest.mark.ux_test
|
||||
@patch('utils.questionary.get_saved_user_input')
|
||||
@patch('helpers.cli.get_saved_command_run')
|
||||
@patch('helpers.AgentConvo.get_saved_development_step')
|
||||
@patch('helpers.AgentConvo.save_development_step')
|
||||
def test_continue_development(mock_4, mock_3, mock_2, mock_1):
|
||||
# Given
|
||||
project = create_project('continue_development', 'hello_world_server')
|
||||
# execute_command(project, 'npm install', 13000)
|
||||
|
||||
developer = Developer(project)
|
||||
project.developer = developer
|
||||
convo = AgentConvo(developer)
|
||||
convo.load_branch = lambda last_branch_name: None
|
||||
developer.run_command = 'node server.js'
|
||||
|
||||
# Note: uncomment the following 2 lines and indent the remaining lines when debugging without console input
|
||||
mock_questionary = MockQuestionary(['r', 'continue'])
|
||||
with patch('utils.questionary.questionary', mock_questionary):
|
||||
|
||||
# When
|
||||
# `continue_development` calls `run_command_until_success()` if the user types "r"
|
||||
developer.continue_development(convo, 'branch_name', 'The web page should say "Hello, World!"')
|
||||
print('end of "continue_development" scenario')
|
||||
|
||||
terminate_running_processes()
|
||||
@ -1,10 +1,20 @@
|
||||
from .run_command_until_success import run_command_until_success
|
||||
# from .run_command_until_success import run_command_until_success
|
||||
from .cli_execute_command import cli_execute_command
|
||||
from .Dev_continue_development import test_continue_development
|
||||
from .utils import use_args
|
||||
|
||||
|
||||
def run_test(test_name: str):
|
||||
def run_test(test_name: str, args):
|
||||
print(f'Running UX test "{test_name}"...')
|
||||
|
||||
if test_name == 'run_command_until_success':
|
||||
return run_command_until_success()
|
||||
tests = {
|
||||
# 'run_command_until_success': run_command_until_success,
|
||||
'cli_execute_command': cli_execute_command,
|
||||
'continue_development': test_continue_development,
|
||||
}
|
||||
|
||||
if test_name in tests:
|
||||
use_args(args)
|
||||
return tests[test_name]()
|
||||
|
||||
print(f'UX test "{test_name}" not found')
|
||||
|
||||
@ -0,0 +1,40 @@
|
||||
import builtins
|
||||
from helpers.ipc import IPCClient
|
||||
from const.ipc import MESSAGE_TYPE
|
||||
|
||||
|
||||
def get_custom_print(args):
|
||||
built_in_print = builtins.print
|
||||
|
||||
def print_to_external_process(*args, **kwargs):
|
||||
# message = " ".join(map(str, args))
|
||||
message = args[0]
|
||||
|
||||
if 'type' not in kwargs:
|
||||
kwargs['type'] = 'verbose'
|
||||
elif kwargs['type'] == MESSAGE_TYPE['local']:
|
||||
local_print(*args, **kwargs)
|
||||
return
|
||||
|
||||
ipc_client_instance.send({
|
||||
'type': MESSAGE_TYPE[kwargs['type']],
|
||||
'content': message,
|
||||
})
|
||||
if kwargs['type'] == MESSAGE_TYPE['user_input_request']:
|
||||
return ipc_client_instance.listen()
|
||||
|
||||
def local_print(*args, **kwargs):
|
||||
message = " ".join(map(str, args))
|
||||
if 'type' in kwargs:
|
||||
if kwargs['type'] == MESSAGE_TYPE['info']:
|
||||
return
|
||||
del kwargs['type']
|
||||
|
||||
built_in_print(message, **kwargs)
|
||||
|
||||
ipc_client_instance = None
|
||||
if '--external-log-process-port' in args:
|
||||
ipc_client_instance = IPCClient(args['--external-log-process-port'])
|
||||
return print_to_external_process, ipc_client_instance
|
||||
else:
|
||||
return local_print, ipc_client_instance
|
||||
Loading…
Reference in New Issue