Tests use the 'test_result' feature to return a predetermined command
result for particular commands. The avoids needing to have the real
command available just to run a test. It works by calling the function
provided by the test, to get the value.
However sometimes the test does need to run the real command. Allow it to
fall back to do this when the function does not return a result.
Signed-off-by: Simon Glass <sjg@chromium.org>
"""
if test_result:
if hasattr(test_result, '__call__'):
- return test_result(pipe_list=pipe_list)
- return test_result
+ result = test_result(pipe_list=pipe_list)
+ if result:
+ return result
+ else:
+ return test_result
+ # No result: fall through to normal processing
result = CommandResult()
last_pipe = None
pipeline = list(pipe_list)