Commit 2b19321ef9cdc77e00c4d063330e2a4a6818c4fc
1 parent
1d85888cdc
Exists in
smarc_8mq_lf_v2020.04
and in
11 other branches
patman: Allow test commands to fall back to real ones
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>
Showing 1 changed file with 6 additions and 2 deletions Side-by-side Diff
tools/patman/command.py
... | ... | @@ -61,8 +61,12 @@ |
61 | 61 | """ |
62 | 62 | if test_result: |
63 | 63 | if hasattr(test_result, '__call__'): |
64 | - return test_result(pipe_list=pipe_list) | |
65 | - return test_result | |
64 | + result = test_result(pipe_list=pipe_list) | |
65 | + if result: | |
66 | + return result | |
67 | + else: | |
68 | + return test_result | |
69 | + # No result: fall through to normal processing | |
66 | 70 | result = CommandResult() |
67 | 71 | last_pipe = None |
68 | 72 | pipeline = list(pipe_list) |