Merge pull request #9031 from ethereum/extend-check-srcipt

Add check for 0000_error to script
This commit is contained in:
chriseth 2020-05-27 18:29:26 +02:00 committed by GitHub
commit 9f407fe0e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 12 deletions

View File

@ -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

20
scripts/correct_error_ids.py Normal file → Executable file
View File

@ -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,9 +118,18 @@ 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()
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"
@ -127,7 +139,7 @@ def main():
while len(answer) == 0 or answer not in "YNyn":
answer = input("[Y/N]? ")
if answer not in "yY":
return
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:])