Skip to content

Commit

Permalink
try using check=True on subprocess calls
Browse files Browse the repository at this point in the history
  • Loading branch information
2bndy5 committed Jan 8, 2024
1 parent 30691d3 commit 34710e2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cpp_linter/clang_tools/clang_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def run_clang_format(
if format_review:
del cmds[2] # remove `--output-replacements-xml` flag
# get formatted file from stdout
formatted_output = subprocess.run(cmds, capture_output=True)
formatted_output = subprocess.run(cmds, capture_output=True, check=True)
# store formatted_output (for comparing later)
advice.patched = formatted_output.stdout
return advice
5 changes: 1 addition & 4 deletions cpp_linter/clang_tools/clang_tidy.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,7 @@ def run_clang_tidy(
original_buf = Path(file_obj.name).read_bytes()
cmds.insert(1, "--fix-errors") # include compiler-suggested fixes
# run clang-tidy again to apply any fixes
fixed_result = subprocess.run(cmds, capture_output=True)
if fixed_result.returncode:
# log if any problems encountered (whatever they are)
logger.error("clang-tidy had problems applying fixes to %s", file_obj.name)
subprocess.run(cmds, check=True)
# store the modified output from clang-tidy
advice.patched = Path(file_obj.name).read_bytes()
# re-write original file contents (can probably skip this on CI runners)
Expand Down

0 comments on commit 34710e2

Please sign in to comment.