mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-01-30 15:32:58 +00:00
Output diff without capturing it
Instead of capturing the output of diff and printing it, let diff do its own outputting and se the return code to decide what to do. This also means that the conversion of stdout to UTF-8 is not necessary, as the reason it was needed was for printing diffs of files with UTF-8 characters in them. Signed-off-by: David Horstmann <david.horstmann@arm.com>
This commit is contained in:
parent
089d0d08a0
commit
ce42cc24d1
@ -115,13 +115,14 @@ def check_style_is_correct(src_file_list: List[str]) -> bool:
|
||||
# file with the extension ".uncrustify". To get the changes (if any)
|
||||
# simply diff the 2 files.
|
||||
diff_cmd = ["diff", "-u", src_file, src_file + ".uncrustify"]
|
||||
result = subprocess.run(diff_cmd, stdout=subprocess.PIPE, \
|
||||
stderr=STDERR_UTF8, check=False)
|
||||
if len(result.stdout) > 0:
|
||||
print(src_file + " - Incorrect code style.", file=STDOUT_UTF8)
|
||||
print("File changed - diff:", file=STDOUT_UTF8)
|
||||
print(str(result.stdout, "utf-8"), file=STDOUT_UTF8)
|
||||
cp = subprocess.run(diff_cmd, check=False)
|
||||
|
||||
if cp.returncode == 1:
|
||||
print(src_file + " changed - code style is incorrect.", file=STDOUT_UTF8)
|
||||
style_correct = False
|
||||
elif cp.returncode != 0:
|
||||
raise subprocess.CalledProcessError(cp.returncode, cp.args,
|
||||
cp.stdout, cp.stderr)
|
||||
|
||||
# Tidy up artifact
|
||||
os.remove(src_file + ".uncrustify")
|
||||
|
Loading…
x
Reference in New Issue
Block a user