Updates for base rule class:
1) Added ability to disable rules
This commit is contained in:
parent
17dbd43300
commit
1f9af5a8d4
|
|
@ -10,6 +10,10 @@ class rule():
|
|||
self.violations = []
|
||||
self.indentSize = 2
|
||||
self.phase = None
|
||||
self.disable = False
|
||||
|
||||
def disable_rule(self):
|
||||
self.disable = True
|
||||
|
||||
def report_violations(self, iLineNumber):
|
||||
if len(self.violations) > 0:
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ class list():
|
|||
for phase in range(1,10):
|
||||
iPhaseRuleCount = 0
|
||||
for oRule in self.rules:
|
||||
if oRule.phase == phase:
|
||||
if oRule.phase == phase and not oRule.disable:
|
||||
oRule.analyze(self.oVhdlFile)
|
||||
iFailures += len(oRule.violations)
|
||||
self.iNumberRulesRan += 1
|
||||
|
|
|
|||
|
|
@ -33,11 +33,16 @@ class testRuleMethods(unittest.TestCase):
|
|||
oRule = rule.rule()
|
||||
self.assertEqual(oRule.violations, [])
|
||||
oRule.add_violation(1)
|
||||
self.assertEqual(oRule.violations, [2])
|
||||
self.assertEqual(oRule.violations, [1])
|
||||
oRule.add_violation(10)
|
||||
oRule.add_violation(33)
|
||||
self.assertEqual(oRule.violations, [2,11,34])
|
||||
self.assertEqual(oRule.violations, [1,10,33])
|
||||
|
||||
def test_rule_disable(self):
|
||||
oRule = rule.rule()
|
||||
self.assertFalse(oRule.disable)
|
||||
oRule.disable_rule()
|
||||
self.assertTrue(oRule.disable)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Loading…
Reference in New Issue