Print reports in the same order as the files are supplied
This commit is contained in:
parent
08f1742bda
commit
c50dec32d4
|
|
@ -391,13 +391,26 @@ def main():
|
|||
|
||||
f = functools.partial(apply_rules, commandLineArguments, configuration, dIndent, fix_only)
|
||||
# It's easier to debug when not using multiprocessing.Pool()
|
||||
lReturn = []
|
||||
if commandLineArguments.jobs == 1:
|
||||
lReturn = []
|
||||
for iIndex, sFileName in enumerate(commandLineArguments.filename):
|
||||
lReturn.append(f((iIndex, sFileName)))
|
||||
fStatus, testCase, dJsonEntry, sOutputStd, sOutputErr = f((iIndex, sFileName))
|
||||
lReturn.append((fStatus, testCase, dJsonEntry))
|
||||
if sOutputStd:
|
||||
print(sOutputStd)
|
||||
if sOutputErr:
|
||||
print(sOutputErr, file=sys.stderr)
|
||||
|
||||
else:
|
||||
pool = multiprocessing.Pool(commandLineArguments.jobs)
|
||||
lReturn = pool.map(f, enumerate(commandLineArguments.filename))
|
||||
for tResult in pool.imap(f, enumerate(commandLineArguments.filename)):
|
||||
fStatus, testCase, dJsonEntry, sOutputStd, sOutputErr = tResult
|
||||
lReturn.append((fStatus, testCase, dJsonEntry))
|
||||
if sOutputStd:
|
||||
print(sOutputStd)
|
||||
if sOutputErr:
|
||||
print(sOutputErr, file=sys.stderr)
|
||||
|
||||
pool.close()
|
||||
pool.join()
|
||||
|
||||
|
|
@ -432,8 +445,9 @@ def apply_rules(commandLineArguments, configuration, dIndent, fix_only, tIndexFi
|
|||
try:
|
||||
oRules = rule_list.rule_list(oVhdlFile, configuration['severity_list'], commandLineArguments.local_rules)
|
||||
except OSError as e:
|
||||
print(f'ERROR: encountered {e.__class__.__name__}, {e.args[1]} ' + commandLineArguments.local_rules + ' when trying to open local rules file.')
|
||||
return 1, None, dJsonEntry
|
||||
sOutputStd = f'ERROR: encountered {e.__class__.__name__}, {e.args[1]} ' + commandLineArguments.local_rules + ' when trying to open local rules file.'
|
||||
sOutputErr = None
|
||||
return 1, None, dJsonEntry, sOutputStd, sOutputErr
|
||||
oRules.configure(configuration)
|
||||
try:
|
||||
oRules.configure(configuration['file_list'][iIndex][sFileName])
|
||||
|
|
@ -450,7 +464,7 @@ def apply_rules(commandLineArguments, configuration, dIndent, fix_only, tIndexFi
|
|||
|
||||
oRules.clear_violations()
|
||||
oRules.check_rules(bAllPhases=commandLineArguments.all_phases, lSkipPhase=commandLineArguments.skip_phase)
|
||||
oRules.report_violations(commandLineArguments.output_format)
|
||||
sOutputStd, sOutputErr = oRules.report_violations(commandLineArguments.output_format)
|
||||
fExitStatus = oRules.violations
|
||||
|
||||
if commandLineArguments.junit:
|
||||
|
|
@ -462,7 +476,7 @@ def apply_rules(commandLineArguments, configuration, dIndent, fix_only, tIndexFi
|
|||
dJsonEntry['file_path'] = sFileName
|
||||
dJsonEntry['violations'] = oRules.extract_violation_dictionary()['violations']
|
||||
|
||||
return fExitStatus, testCase, dJsonEntry
|
||||
return fExitStatus, testCase, dJsonEntry, sOutputStd, sOutputErr
|
||||
|
||||
|
||||
def update_exit_status(fExitStatus, oRules):
|
||||
|
|
|
|||
|
|
@ -1,7 +1,3 @@
|
|||
|
||||
import sys
|
||||
|
||||
|
||||
def print_output(dRunInfo):
|
||||
'''
|
||||
Displays results to stdout in a compact format.
|
||||
|
|
@ -32,6 +28,6 @@ def print_output(dRunInfo):
|
|||
sOutputString += str(dRunInfo['severities'][sSeverity])
|
||||
sOutputString += ']'
|
||||
if dRunInfo['severities']['Error'] == 0:
|
||||
print(sOutputString)
|
||||
return sOutputString, None
|
||||
else:
|
||||
sys.stderr.write(sOutputString + '\n')
|
||||
return None, sOutputString
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ def print_output(dRunInfo):
|
|||
Parameters:
|
||||
dRunInfo (dictionary)
|
||||
'''
|
||||
sOutputString = ''
|
||||
for dViolation in dRunInfo['violations']:
|
||||
sOutputString = _set_violation_type(dViolation)
|
||||
sOutputString += dRunInfo['filename']
|
||||
|
|
@ -18,7 +19,8 @@ def print_output(dRunInfo):
|
|||
sOutputString += dViolation['rule']
|
||||
sOutputString += ' -- '
|
||||
sOutputString += dViolation['solution']
|
||||
print(sOutputString)
|
||||
sOutputString += '\n'
|
||||
return sOutputString[:-1], None
|
||||
|
||||
|
||||
def _set_violation_type(dViolation):
|
||||
|
|
|
|||
|
|
@ -9,9 +9,10 @@ def print_output(dRunInfo):
|
|||
Parameters:
|
||||
dRunInfo (dictionary)
|
||||
'''
|
||||
print_header(dRunInfo['filename'])
|
||||
print_stats(dRunInfo)
|
||||
print_violations(dRunInfo)
|
||||
header = print_header(dRunInfo['filename'])
|
||||
stats = print_stats(dRunInfo)
|
||||
violations = print_violations(dRunInfo)
|
||||
return header + stats + violations, None
|
||||
|
||||
|
||||
def print_header(sFilename):
|
||||
|
|
@ -23,27 +24,28 @@ def print_header(sFilename):
|
|||
|
||||
Returns: Nothing
|
||||
'''
|
||||
print('=' * iLineLength)
|
||||
print('File: ' + sFilename)
|
||||
print('=' * iLineLength)
|
||||
top = '=' * iLineLength + '\n'
|
||||
filename = 'File: ' + sFilename + '\n'
|
||||
bottom = '=' * iLineLength + '\n'
|
||||
return top + filename + bottom
|
||||
|
||||
|
||||
def print_phase_information(iPhaseNumber):
|
||||
'''
|
||||
Prints information about the analysis.
|
||||
'''
|
||||
print('Phase ' + str(iPhaseNumber) + ' of 7... Reporting')
|
||||
return 'Phase ' + str(iPhaseNumber) + ' of 7... Reporting\n'
|
||||
|
||||
|
||||
def print_divider():
|
||||
'''
|
||||
Prints a divider that matches the column divisions in the violations.
|
||||
'''
|
||||
print('-'*28 + '+' + '-'*12 + '+' + '-'*12 + '+' + '-'*38)
|
||||
return '-'*28 + '+' + '-'*12 + '+' + '-'*12 + '+' + '-'*38 + '\n'
|
||||
|
||||
|
||||
def print_violation_header():
|
||||
print_divider()
|
||||
top_divider = print_divider()
|
||||
sOutputString = ' '
|
||||
sOutputString += 'Rule'.ljust(25)
|
||||
sOutputString += ' | '
|
||||
|
|
@ -51,9 +53,9 @@ def print_violation_header():
|
|||
sOutputString += ' | '
|
||||
sOutputString += 'line(s)'.center(10)
|
||||
sOutputString += ' | '
|
||||
sOutputString += 'Solution'
|
||||
print(sOutputString)
|
||||
print_divider()
|
||||
sOutputString += 'Solution\n'
|
||||
bottom_divider = print_divider()
|
||||
return top_divider + sOutputString + bottom_divider
|
||||
|
||||
|
||||
def print_stats(dRunInfo):
|
||||
|
|
@ -66,12 +68,13 @@ def print_stats(dRunInfo):
|
|||
|
||||
Returns: Nothing
|
||||
'''
|
||||
print('Phase ' + str(dRunInfo['stopPhase']) + ' of 7... Reporting')
|
||||
print('Total Rules Checked: ' + str(dRunInfo['num_rules_checked']))
|
||||
print('Total Violations: ' + str(dRunInfo['total_violations']))
|
||||
stats = 'Phase ' + str(dRunInfo['stopPhase']) + ' of 7... Reporting\n'
|
||||
stats += 'Total Rules Checked: ' + str(dRunInfo['num_rules_checked']) + '\n'
|
||||
stats += 'Total Violations: ' + str(dRunInfo['total_violations']) + '\n'
|
||||
for sSeverity in list(dRunInfo['severities'].keys()):
|
||||
sFormat = ' {0:<' + str(dRunInfo['maxSeverityNameLength']) + 's} : {1:5d}'
|
||||
print(sFormat.format(sSeverity, dRunInfo['severities'][sSeverity]))
|
||||
stats += sFormat.format(sSeverity, dRunInfo['severities'][sSeverity]) + '\n'
|
||||
return stats
|
||||
|
||||
|
||||
def print_violations(dRunInfo):
|
||||
|
|
@ -85,9 +88,9 @@ def print_violations(dRunInfo):
|
|||
Returns: Nothing
|
||||
'''
|
||||
if dRunInfo['total_violations'] > 0:
|
||||
print_violation_header()
|
||||
sOutputString = print_violation_header()
|
||||
for dViolation in dRunInfo['violations']:
|
||||
sOutputString = ' '
|
||||
sOutputString += ' '
|
||||
sOutputString += dViolation['rule'].ljust(25)
|
||||
sOutputString += ' | '
|
||||
sOutputString += dViolation['severity']['name'].ljust(10)
|
||||
|
|
@ -98,6 +101,9 @@ def print_violations(dRunInfo):
|
|||
sOutputString += dViolation['solution']
|
||||
except TypeError:
|
||||
sOutputString += 'None'
|
||||
print(sOutputString)
|
||||
print_divider()
|
||||
print('NOTE: Refer to online documentation at https://vhdl-style-guide.readthedocs.io/en/latest/index.html for more information.')
|
||||
sOutputString += '\n'
|
||||
sOutputString += print_divider()
|
||||
sOutputString += 'NOTE: Refer to online documentation at https://vhdl-style-guide.readthedocs.io/en/latest/index.html for more information.'
|
||||
return sOutputString
|
||||
else:
|
||||
return ''
|
||||
|
|
|
|||
|
|
@ -256,11 +256,12 @@ class rule_list():
|
|||
|
||||
# print(dRunInfo)
|
||||
if sOutputFormat == 'vsg':
|
||||
report.vsg_stdout.print_output(dRunInfo)
|
||||
sOutputStd, sOutputErr = report.vsg_stdout.print_output(dRunInfo)
|
||||
elif sOutputFormat == 'syntastic':
|
||||
report.syntastic_stdout.print_output(dRunInfo)
|
||||
sOutputStd, sOutputErr = report.syntastic_stdout.print_output(dRunInfo)
|
||||
else:
|
||||
report.summary_stdout.print_output(dRunInfo)
|
||||
sOutputStd, sOutputErr = report.summary_stdout.print_output(dRunInfo)
|
||||
return sOutputStd, sOutputErr
|
||||
|
||||
def configure(self, configurationFile):
|
||||
'''
|
||||
|
|
|
|||
Loading…
Reference in New Issue