Updates for issue #402:

Mocking the number of rules ran to make tests more robust.
This commit is contained in:
Jeremiah Leary 2020-07-28 07:32:10 -05:00
parent 862b5aab77
commit 9cf81ea67a
8 changed files with 34 additions and 15 deletions

View File

@ -233,7 +233,7 @@ class rule_list():
dRunInfo['violations'].extend(lViolations)
dRunInfo['stopPhase'] = self.lastPhaseRan
dRunInfo['num_rules_checked'] = self.iNumberRulesRan
dRunInfo['num_rules_checked'] = self.get_number_of_rules_ran()
dRunInfo['total_violations'] = len(dRunInfo['violations'])
dRunInfo['maxSeverityNameLength'] = self.oSeverityList.iMaxNameLength
dRunInfo['severities'] = {}
@ -328,6 +328,9 @@ class rule_list():
for oRule in self.rules:
oRule.clear_violations()
def get_number_of_rules_ran(self):
return self.iNumberRulesRan
def filter_out_disabled_rules(lRules):
'''

View File

@ -2,7 +2,7 @@
File: architecture.vhd
================================================================================
Phase 3 of 7... Reporting
Total Rules Checked: 201
Total Rules Checked: 200
Total Violations: 2
Error : 1
Warning : 1

View File

@ -2,7 +2,7 @@
File: entity.vhd
================================================================================
Phase 2 of 7... Reporting
Total Rules Checked: 154
Total Rules Checked: 200
Total Violations: 5
Error : 4
Warning : 0

View File

@ -2,7 +2,7 @@
File: architecture.vhd
================================================================================
Phase 7 of 7... Reporting
Total Rules Checked: 389
Total Rules Checked: 200
Total Violations: 1
Error : 0
Warning : 1

View File

@ -2,7 +2,7 @@
File: entity.vhd
================================================================================
Phase 7 of 7... Reporting
Total Rules Checked: 389
Total Rules Checked: 200
Total Violations: 1
Error : 0
Warning : 0

View File

@ -2,7 +2,7 @@
File: architecture.vhd
================================================================================
Phase 1 of 7... Reporting
Total Rules Checked: 64
Total Rules Checked: 200
Total Violations: 1
Error : 1
Warning : 0

View File

@ -2,7 +2,7 @@
File: entity.vhd
================================================================================
Phase 1 of 7... Reporting
Total Rules Checked: 64
Total Rules Checked: 200
Total Violations: 1
Error : 1
Warning : 0

View File

@ -44,7 +44,9 @@ class test_severity_using_main(unittest.TestCase):
os.remove(sJUnitFileName)
@mock.patch('sys.stdout')
def test_entity_without_configuration(self, mock_stdout):
@mock.patch('vsg.__main__.rule_list.rule_list.get_number_of_rules_ran')
def test_entity_without_configuration(self, mock_rule_ran, mock_stdout):
mock_rule_ran.return_value = 200
try:
sys.argv = ['vsg', '-f', sEntityFileName]
__main__.main()
@ -62,7 +64,9 @@ class test_severity_using_main(unittest.TestCase):
mock_stdout.write.assert_has_calls(lExpected)
@mock.patch('sys.stdout')
def test_entity_with_configuration(self, mock_stdout):
@mock.patch('vsg.__main__.rule_list.rule_list.get_number_of_rules_ran')
def test_entity_with_configuration(self, mock_rule_ran, mock_stdout):
mock_rule_ran.return_value = 200
try:
sys.argv = ['vsg', '-f', sEntityFileName, '-c', sConfigFile]
__main__.main()
@ -80,7 +84,9 @@ class test_severity_using_main(unittest.TestCase):
mock_stdout.write.assert_has_calls(lExpected)
@mock.patch('sys.stdout')
def test_entity_with_configuration_and_fixed(self, mock_stdout):
@mock.patch('vsg.__main__.rule_list.rule_list.get_number_of_rules_ran')
def test_entity_with_configuration_and_fixed(self, mock_rule_ran, mock_stdout):
mock_rule_ran.return_value = 200
try:
sys.argv = ['vsg', '-f', sEntityFileName, '-c', sConfigFile, '--fix']
__main__.main()
@ -98,7 +104,9 @@ class test_severity_using_main(unittest.TestCase):
mock_stdout.write.assert_has_calls(lExpected)
@mock.patch('sys.stdout')
def test_architecture_without_configuration(self, mock_stdout):
@mock.patch('vsg.__main__.rule_list.rule_list.get_number_of_rules_ran')
def test_architecture_without_configuration(self, mock_rule_ran, mock_stdout):
mock_rule_ran.return_value = 200
try:
sys.argv = ['vsg', '-f', sArchitectureFileName]
__main__.main()
@ -116,7 +124,9 @@ class test_severity_using_main(unittest.TestCase):
mock_stdout.write.assert_has_calls(lExpected)
@mock.patch('sys.stdout')
def test_architecture_with_configuration(self, mock_stdout):
@mock.patch('vsg.__main__.rule_list.rule_list.get_number_of_rules_ran')
def test_architecture_with_configuration(self, mock_rule_ran, mock_stdout):
mock_rule_ran.return_value = 200
try:
sys.argv = ['vsg', '-f', sArchitectureFileName, '-c', sConfigFile]
__main__.main()
@ -134,7 +144,9 @@ class test_severity_using_main(unittest.TestCase):
mock_stdout.write.assert_has_calls(lExpected)
@mock.patch('sys.stdout')
def test_architecture_with_configuration_and_fixed(self, mock_stdout):
@mock.patch('vsg.__main__.rule_list.rule_list.get_number_of_rules_ran')
def test_architecture_with_configuration_and_fixed(self, mock_rule_ran, mock_stdout):
mock_rule_ran.return_value = 200
try:
sys.argv = ['vsg', '-f', sArchitectureFileName, '-c', sConfigFile, '--fix']
__main__.main()
@ -152,7 +164,9 @@ class test_severity_using_main(unittest.TestCase):
mock_stdout.write.assert_has_calls(lExpected)
@mock.patch('sys.stdout')
def test_both_with_configuration(self, mock_stdout):
@mock.patch('vsg.__main__.rule_list.rule_list.get_number_of_rules_ran')
def test_both_with_configuration(self, mock_rule_ran, mock_stdout):
mock_rule_ran.return_value = 200
try:
sys.argv = ['vsg', '-f', sEntityFileName, sArchitectureFileName, '-c', sConfigFile]
__main__.main()
@ -172,7 +186,9 @@ class test_severity_using_main(unittest.TestCase):
mock_stdout.write.assert_has_calls(lExpected)
@mock.patch('sys.stdout')
def test_both_with_configuration_and_fixed(self, mock_stdout):
@mock.patch('vsg.__main__.rule_list.rule_list.get_number_of_rules_ran')
def test_both_with_configuration_and_fixed(self, mock_rule_ran, mock_stdout):
mock_rule_ran.return_value = 200
try:
sys.argv = ['vsg', '-f', sEntityFileName, sArchitectureFileName, '-c', sConfigFile, '--fix']
__main__.main()