Factor description-checking code into a common function
Behavior change: some error messages are slightly different.
This commit is contained in:
parent
283df2e90c
commit
32b9421f12
1 changed files with 20 additions and 24 deletions
|
@ -54,6 +54,22 @@ def collect_test_directories():
|
||||||
directories.append(crypto_tests_dir)
|
directories.append(crypto_tests_dir)
|
||||||
return directories
|
return directories
|
||||||
|
|
||||||
|
def check_description(results, seen, file_name, line_number, description):
|
||||||
|
if description in seen:
|
||||||
|
results.error(file_name, line_number,
|
||||||
|
'Duplicate description (also line {})',
|
||||||
|
seen[description])
|
||||||
|
return
|
||||||
|
if re.search(r'[\t;]', description):
|
||||||
|
results.error(file_name, line_number,
|
||||||
|
'Forbidden character \'{}\' in description',
|
||||||
|
re.search(r'[\t;]', description).group(0))
|
||||||
|
if len(description) > 66:
|
||||||
|
results.warning(file_name, line_number,
|
||||||
|
'Test description too long ({} > 66)',
|
||||||
|
len(description))
|
||||||
|
seen[description] = line_number
|
||||||
|
|
||||||
def check_test_suite(results, data_file_name):
|
def check_test_suite(results, data_file_name):
|
||||||
in_paragraph = False
|
in_paragraph = False
|
||||||
descriptions = {}
|
descriptions = {}
|
||||||
|
@ -69,18 +85,8 @@ def check_test_suite(results, data_file_name):
|
||||||
continue
|
continue
|
||||||
if not in_paragraph:
|
if not in_paragraph:
|
||||||
# This is a test case description line.
|
# This is a test case description line.
|
||||||
if line in descriptions:
|
check_description(results, descriptions,
|
||||||
results.error(data_file_name, line_number,
|
data_file_name, line_number, line)
|
||||||
'Duplicate description (also line {}): {}',
|
|
||||||
descriptions[line], line)
|
|
||||||
else:
|
|
||||||
if re.search(r'[\t;]', line):
|
|
||||||
results.error(data_file_name, line_number,
|
|
||||||
'Forbidden character in description')
|
|
||||||
if len(line) > 66:
|
|
||||||
results.warning(data_file_name, line_number,
|
|
||||||
'Test description will be truncated')
|
|
||||||
descriptions[line] = line_number
|
|
||||||
in_paragraph = True
|
in_paragraph = True
|
||||||
|
|
||||||
def check_ssl_opt_sh(results, file_name):
|
def check_ssl_opt_sh(results, file_name):
|
||||||
|
@ -96,18 +102,8 @@ def check_ssl_opt_sh(results, file_name):
|
||||||
if not m:
|
if not m:
|
||||||
continue
|
continue
|
||||||
description = m.group(1)
|
description = m.group(1)
|
||||||
if description in descriptions:
|
check_description(results, descriptions,
|
||||||
results.error(data_file_name, line_number,
|
file_name, line_number, description)
|
||||||
'Duplicate description (also line {}): {}',
|
|
||||||
descriptions[line], line)
|
|
||||||
else:
|
|
||||||
if re.search(r'[\t;]', line):
|
|
||||||
results.error(data_file_name, line_number,
|
|
||||||
'Forbidden character in description')
|
|
||||||
if len(line) > 66:
|
|
||||||
results.warning(data_file_name, line_number,
|
|
||||||
'Test description will break visual alignment')
|
|
||||||
descriptions[line] = line_number
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
test_directories = collect_test_directories()
|
test_directories = collect_test_directories()
|
||||||
|
|
Loading…
Reference in a new issue