Skip to content

Commit

Permalink
Resolve issue with UserPrompts in test harness.
Browse files Browse the repository at this point in the history
  • Loading branch information
krypton36 committed May 30, 2023
1 parent 0b86ffa commit 10e25c5
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion scripts/py_matter_yamltests/matter_yamltests/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def step_skipped(self, name: str, expression: str):
"""
pass

def step_start(self, name: str):
def step_start(self, request):
"""
This method is called when the runner starts running a step from the test.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def get_config(test_file: str):
config_options = {}

yaml_loader = YamlLoader()
_, _, config, _ = yaml_loader.load(test_file)
_, _, _, config, _ = yaml_loader.load(test_file)
config_options = {key: value if not isinstance(
value, dict) else value['defaultValue'] for key, value in config.items()}
return config_options
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ class LogCommands(PseudoCluster):
definition = _DEFINITION

async def UserPrompt(self, request):
pass
input_result = input("")
for value in request.arguments.get("values", []):
if value.get('name') and 'expectedValue' in value['name']:
request.responses = [{"values": [{"name": "expectedValue", "value": value['value']}]}]
return {"value": {"expectedValue": input_result}}
return {}

async def Log(self, request):
pass
4 changes: 2 additions & 2 deletions scripts/py_matter_yamltests/matter_yamltests/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,11 @@ async def _run(self, parser: TestParser, config: TestRunnerConfig):
hooks.step_skipped(request.label, request.pics)
continue
elif not config.adapter:
hooks.step_start(request.label)
hooks.step_start(request)
hooks.step_unknown()
continue
else:
hooks.step_start(request.label)
hooks.step_start(request)

start = time.time()
if config.pseudo_clusters.supports(request):
Expand Down
12 changes: 6 additions & 6 deletions scripts/tests/yaml/tests_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,14 @@ def step_skipped(self, name: str, expression: str):
self.__index += 1
self.__skipped += 1

def step_start(self, name: str):
def step_start(self, request):
if self.__use_test_harness_log_format:
print(self.__strings.test_harness_step_start.format(index=self.__index, name=name))
print(self.__strings.test_harness_step_start.format(index=self.__index, name=request.label))

print(self.__strings.step_start.format(index=self.__index, name=click.style(name, bold=True)), end='')
print(self.__strings.step_start.format(index=self.__index, name=click.style(request.label, bold=True)), end='')
if request.command == 'UserPrompt':
message = request.arguments['values'][0]['value']
print("\n" + self.__strings.user_prompt.format(message=f'{message}'))
# flushing stdout such that the previous print statement is visible on the screen for long running tasks.
sys.stdout.flush()

Expand All @@ -218,9 +221,6 @@ def step_success(self, logger, logs, duration: int, request):
elif request.command == 'Log':
message = request.arguments['values'][0]['value']
print(self.__strings.log.format(message=f'{message}'))
elif request.command == 'UserPrompt':
message = request.arguments['values'][0]['value']
print(self.__strings.user_prompt.format(message=f'{message}'))

if self.__show_adapter_logs:
self.__log_printer.print(logs)
Expand Down

0 comments on commit 10e25c5

Please sign in to comment.