diff options
author | David Horstmann <david.horstmann@arm.com> | 2023-01-04 18:33:25 +0000 |
---|---|---|
committer | David Horstmann <david.horstmann@arm.com> | 2023-01-04 18:44:35 +0000 |
commit | b92d30f987bc07f1675f6098c33458358428e5fd (patch) | |
tree | b3ab09e89cef70cab70a754dc32ee4334b90fed8 | |
parent | d6818e3f946bae8e417de532e1a4d59c3bc4f72c (diff) | |
download | mbedtls-b92d30f987bc07f1675f6098c33458358428e5fd.zip mbedtls-b92d30f987bc07f1675f6098c33458358428e5fd.tar.gz mbedtls-b92d30f987bc07f1675f6098c33458358428e5fd.tar.bz2 |
Check Uncrustify returncode in code_style.py
Signed-off-by: David Horstmann <david.horstmann@arm.com>
-rwxr-xr-x | scripts/code_style.py | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/scripts/code_style.py b/scripts/code_style.py index 8e82b93..a23d3a5 100755 --- a/scripts/code_style.py +++ b/scripts/code_style.py @@ -106,8 +106,12 @@ def check_style_is_correct(src_file_list: List[str]) -> bool: style_correct = True for src_file in src_file_list: uncrustify_cmd = [UNCRUSTIFY_EXE] + UNCRUSTIFY_ARGS + [src_file] - subprocess.run(uncrustify_cmd, stdout=subprocess.PIPE, \ + result = subprocess.run(uncrustify_cmd, stdout=subprocess.PIPE, \ stderr=subprocess.PIPE, check=False) + if result.returncode != 0: + print_err("Uncrustify returned " + str(result.returncode) + \ + " correcting file " + src_file) + return False # Uncrustify makes changes to the code and places the result in a new # file with the extension ".uncrustify". To get the changes (if any) @@ -135,15 +139,22 @@ def fix_style_single_pass(src_file_list: List[str]) -> None: code_change_args = UNCRUSTIFY_ARGS + ["--no-backup"] for src_file in src_file_list: uncrustify_cmd = [UNCRUSTIFY_EXE] + code_change_args + [src_file] - subprocess.run(uncrustify_cmd, check=False, stdout=STDOUT_UTF8, \ - stderr=STDERR_UTF8) + result = subprocess.run(uncrustify_cmd, check=False, \ + stdout=STDOUT_UTF8, stderr=STDERR_UTF8) + if result.returncode != 0: + print_err("Uncrustify with file returned: " + \ + str(result.returncode) + " correcting file " + \ + src_file) + return False def fix_style(src_file_list: List[str]) -> int: """ Fix the code style. This takes 2 passes of Uncrustify. """ - fix_style_single_pass(src_file_list) - fix_style_single_pass(src_file_list) + if fix_style_single_pass(src_file_list) != True: + return 1 + if fix_style_single_pass(src_file_list) != True: + return 1 # Guard against future changes that cause the codebase to require # more passes. |