From 7548441b4fb394012d0f14c5058bc8da8413fe56 Mon Sep 17 00:00:00 2001 From: Mathias Baumann Date: Wed, 27 May 2020 12:13:37 +0200 Subject: [PATCH] Check for wrong error codes in the CI --- .circleci/config.yml | 10 ++++++++++ scripts/correct_error_ids.py | 38 ++++++++++++++++++++++++------------ 2 files changed, 36 insertions(+), 12 deletions(-) mode change 100644 => 100755 scripts/correct_error_ids.py diff --git a/.circleci/config.yml b/.circleci/config.yml index a34649d74..7f2b46a0c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -316,6 +316,15 @@ jobs: name: checking shell scripts command: ./scripts/chk_shellscripts/chk_shellscripts.sh + chk_errorcodes: + docker: + - image: circleci/python:3.6 + steps: + - checkout + - run: + name: Check for error codes + command: ./scripts/correct_error_ids.py --noconfirm + chk_pylint: docker: - image: buildpack-deps:eoan @@ -845,6 +854,7 @@ workflows: - chk_buglist: *workflow_trigger_on_tags - chk_proofs: *workflow_trigger_on_tags - chk_pylint: *workflow_trigger_on_tags + - chk_errorcodes: *workflow_trigger_on_tags - chk_antlr_grammar: *workflow_trigger_on_tags - chk_docs_pragma_min_version: *workflow_trigger_on_tags diff --git a/scripts/correct_error_ids.py b/scripts/correct_error_ids.py old mode 100644 new mode 100755 index cce8285de..cbbad8264 --- a/scripts/correct_error_ids.py +++ b/scripts/correct_error_ids.py @@ -1,6 +1,9 @@ +#! /usr/bin/env python3 import random import re import os +import getopt +import sys from os import path ENCODING = "utf-8" @@ -115,19 +118,28 @@ def find_source_files(top_dir): return source_file_names -def main(): +def main(argv): + noconfirm = False + opts, args = getopt.getopt(argv, "", ["noconfirm"]) + + for opt, arg in opts: + if opt == '--noconfirm': + noconfirm = True + random.seed() cwd = os.getcwd() - answer = input( - f"This script checks and corrects *_error literals in .h and .cpp files\n" - f"in {cwd}, recursively.\n\n" - f"Please commit current changes first, and review the results when the script finishes.\n\n" - f"Do you want to start [Y/N]? " - ) - while len(answer) == 0 or answer not in "YNyn": - answer = input("[Y/N]? ") - if answer not in "yY": - return + + if not noconfirm: + answer = input( + f"This script checks and corrects *_error literals in .h and .cpp files\n" + f"in {cwd}, recursively.\n\n" + f"Please commit current changes first, and review the results when the script finishes.\n\n" + f"Do you want to start [Y/N]? " + ) + while len(answer) == 0 or answer not in "YNyn": + answer = input("[Y/N]? ") + if answer not in "yY": + exit(0) source_file_names = find_source_files(cwd) @@ -147,10 +159,12 @@ def main(): if ok: print("No incorrect IDs found") + exit(0) else: fix_ids(used_ids, source_file_names) print("Fixing completed") + exit(1) if __name__ == "__main__": - main() + main(sys.argv[1:])