mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-03-24 01:43:33 +00:00
Don't reuse a variable name inside a function
Use different names for task name, a task class and a task instance. The interpreter doesn't care, but it's less confusing for both humans and type checkers. Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
parent
40a98a4b64
commit
c2df8d4e9b
@ -784,17 +784,17 @@ def main():
|
|||||||
options = parser.parse_args()
|
options = parser.parse_args()
|
||||||
|
|
||||||
if options.list:
|
if options.list:
|
||||||
for task in KNOWN_TASKS:
|
for task_name in KNOWN_TASKS:
|
||||||
print(task)
|
print(task_name)
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
if options.specified_tasks == 'all':
|
if options.specified_tasks == 'all':
|
||||||
tasks_list = KNOWN_TASKS.keys()
|
tasks_list = KNOWN_TASKS.keys()
|
||||||
else:
|
else:
|
||||||
tasks_list = re.split(r'[, ]+', options.specified_tasks)
|
tasks_list = re.split(r'[, ]+', options.specified_tasks)
|
||||||
for task in tasks_list:
|
for task_name in tasks_list:
|
||||||
if task not in KNOWN_TASKS:
|
if task_name not in KNOWN_TASKS:
|
||||||
sys.stderr.write('invalid task: {}\n'.format(task))
|
sys.stderr.write('invalid task: {}\n'.format(task_name))
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
|
|
||||||
# If the outcome file exists, parse it once and share the result
|
# If the outcome file exists, parse it once and share the result
|
||||||
@ -806,22 +806,22 @@ def main():
|
|||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
|
|
||||||
task_name = tasks_list[0]
|
task_name = tasks_list[0]
|
||||||
task = KNOWN_TASKS[task_name]
|
task_class = KNOWN_TASKS[task_name]
|
||||||
if not issubclass(task, DriverVSReference):
|
if not issubclass(task_class, DriverVSReference):
|
||||||
sys.stderr.write("please provide valid outcomes file for {}.\n".format(task_name))
|
sys.stderr.write("please provide valid outcomes file for {}.\n".format(task_name))
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
execute_reference_driver_tests(main_results,
|
execute_reference_driver_tests(main_results,
|
||||||
task.REFERENCE,
|
task_class.REFERENCE,
|
||||||
task.DRIVER,
|
task_class.DRIVER,
|
||||||
options.outcomes)
|
options.outcomes)
|
||||||
|
|
||||||
outcomes = read_outcome_file(options.outcomes)
|
outcomes = read_outcome_file(options.outcomes)
|
||||||
|
|
||||||
for task_name in tasks_list:
|
for task_name in tasks_list:
|
||||||
task_constructor = KNOWN_TASKS[task_name]
|
task_constructor = KNOWN_TASKS[task_name]
|
||||||
task = task_constructor(options)
|
task_instance = task_constructor(options)
|
||||||
main_results.new_section(task.section_name())
|
main_results.new_section(task_instance.section_name())
|
||||||
task.run(main_results, outcomes)
|
task_instance.run(main_results, outcomes)
|
||||||
|
|
||||||
main_results.info("Overall results: {} warnings and {} errors",
|
main_results.info("Overall results: {} warnings and {} errors",
|
||||||
main_results.warning_count, main_results.error_count)
|
main_results.warning_count, main_results.error_count)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user