Skip to content

Commit

Permalink
CLI: verdi computer test make unexpected output check optional (#6384)
Browse files Browse the repository at this point in the history
The test for unexpected output in `verdi computer test` requires to
execute a command on the remote, however, this may not be implemented
by all transport plugins. If `NotImplementedError` is raised, this now
no longer fails the test but prints why the test was skipped.
  • Loading branch information
khsrali committed May 13, 2024
1 parent 80c6068 commit 589a3b2
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/aiida/cmdline/commands/cmd_computer.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,24 @@ def _computer_test_no_unexpected_output(transport, scheduler, authinfo, computer
This can happen if e.g. there is some spurious command in the
.bashrc or .bash_profile that is not guarded in case of non-interactive
shells.
Note: This test is irrelevant if the transport plugin does not support command execution.
:param transport: an open transport
:param scheduler: the corresponding scheduler class
:param authinfo: the AuthInfo object (from which one can get computer and aiidauser)
:return: tuple of boolean indicating success or failure and an optional string message
"""
# Execute a command that should not return any error
retval, stdout, stderr = transport.exec_command_wait('echo -n')
# Execute a command that should not return any error, except ``NotImplementedError``
# since not all transport plugins implement remote command execution.
try:
retval, stdout, stderr = transport.exec_command_wait('echo -n')
except NotImplementedError:
return (
True,
f'Skipped, remote command execution is not implemented for the '
f'`{computer.transport_type}` transport plugin',
)

if retval != 0:
return False, f'The command `echo -n` returned a non-zero return code ({retval})'

Expand Down

0 comments on commit 589a3b2

Please sign in to comment.