diff --git a/tests/restyle.py b/tests/restyle.py index d0477c2099..8e87be439d 100755 --- a/tests/restyle.py +++ b/tests/restyle.py @@ -86,7 +86,7 @@ def find_arduino_files(): class Changed: file: str hunk: list[str] - lines: list[str] + lines: list[int] @dataclass @@ -122,7 +122,9 @@ def reset_with_line(ctx, line): def pop(out, context, line): if ctx.file and ctx.hunk and ctx.markers: - out.append(Changed(ctx.file, "\n".join(ctx.hunk), ", ".join(ctx.markers))) + out.append( + Changed(file=ctx.file, hunk="\n".join(ctx.hunk), lines=ctx.markers) + ) reset_with_line(context, line) @@ -157,7 +159,7 @@ def pop(out, context, line): numbers = numbers.replace("+", "") numbers = numbers.replace("-", "") - ctx.markers.append(numbers) + ctx.markers.append(int(numbers)) ctx.append_hunk = True # capture diff for the summary @@ -169,10 +171,12 @@ def pop(out, context, line): return out -def warning_changed(changed: Changed): - print( - f"::warning file={changed.file},title=Run tests/restyle.sh and re-commit {changed.file}::File {changed.file} failed clang-format style check. (lines {changed.lines})" - ) +def errors_changed(changed: Changed): + all_lines = ", ".join(str(x) for x in changed.lines) + for line in changed.lines: + print( + f"::error file={changed.file},title=Run tests/restyle.sh and re-commit {changed.file},line={line}::File {changed.file} failed clang-format style check. (lines {all_lines})" + ) SUMMARY_PATH = pathlib.Path(os.environ.get("GITHUB_STEP_SUMMARY", os.devnull)) @@ -214,8 +218,8 @@ def run_format(args): def run_assert(args): for changed in changed_files(): - if args.with_warnings: - warning_changed(changed) + if args.with_errors: + errors_changed(changed) if args.with_summary: summary_diff(changed) @@ -246,7 +250,7 @@ def run_assert(args): assert_ = cmd.add_parser("assert") assert_.set_defaults(func=run_assert) assert_.add_argument("--with-summary", action="store_true") - assert_.add_argument("--with-warnings", action="store_true") + assert_.add_argument("--with-errors", action="store_true") args = parser.parse_args() args.func(args) diff --git a/tests/restyle.sh b/tests/restyle.sh index 3e554fa5fb..09f0b81163 100755 --- a/tests/restyle.sh +++ b/tests/restyle.sh @@ -13,4 +13,4 @@ CLANG_FORMAT=${CLANG_FORMAT:-clang-format-15} cd $root python $root/tests/restyle.py format --clang-format=$CLANG_FORMAT preset --include core --include arduino -python $root/tests/restyle.py assert --with-summary --with-warnings +python $root/tests/restyle.py assert --with-summary --with-errors