Updates for issue #149:
1) Added command line option --fix_phase which will apply fixes up to and including that phase.
Analysis will then be ran on all remaining phases.
2) Updated tests
This commit is contained in:
parent
eb9c80629a
commit
69e569c992
3
bin/vsg
3
bin/vsg
|
|
@ -28,6 +28,7 @@ def parse_command_line_arguments():
|
|||
parser.add_argument('--local_rules', help='Path to local rules')
|
||||
parser.add_argument('--configuration', help='JSON configuration file')
|
||||
parser.add_argument('--fix', default=False, action='store_true', help='Fix issues found')
|
||||
parser.add_argument('--fix_phase', default=10, action='store', help='Fix issues up to and including this phase')
|
||||
parser.add_argument('--junit', action='store', help='Extract Junit file')
|
||||
|
||||
if len(sys.argv) == 1:
|
||||
|
|
@ -95,7 +96,7 @@ def main():
|
|||
oRules.configure(configuration)
|
||||
|
||||
if commandLineArguments.fix:
|
||||
oRules.fix()
|
||||
oRules.fix(commandLineArguments.fix_phase)
|
||||
write_vhdl_file(oVhdlFile)
|
||||
|
||||
oRules.check_rules()
|
||||
|
|
|
|||
|
|
@ -82,11 +82,11 @@ class rule_list():
|
|||
self.oVhdlFile = oVhdlFile
|
||||
self.maximumPhase = maximum_phase(self.rules)
|
||||
|
||||
def fix(self):
|
||||
def fix(self, iPhase):
|
||||
'''
|
||||
Applies fixes to all violations found.
|
||||
'''
|
||||
for phase in range(1, 10):
|
||||
for phase in range(1, int(iPhase) + 1):
|
||||
for oRule in self.rules:
|
||||
if oRule.phase == phase and not oRule.disable:
|
||||
oRule.fix(self.oVhdlFile)
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ class testCodeExample(unittest.TestCase):
|
|||
|
||||
def test_baudgen(self):
|
||||
oRuleList = rule_list.rule_list(oBaudGen)
|
||||
oRuleList.fix()
|
||||
oRuleList.fix(7)
|
||||
lExpected = ['']
|
||||
utils.read_file(os.path.join(os.path.dirname(__file__),'BaudGen.fixed.vhd'), lExpected)
|
||||
for iLineNumber, sLine in enumerate(lExpected):
|
||||
|
|
@ -23,7 +23,7 @@ class testCodeExample(unittest.TestCase):
|
|||
|
||||
def test_board_cpu(self):
|
||||
oRuleList = rule_list.rule_list(oBoardCpu)
|
||||
oRuleList.fix()
|
||||
oRuleList.fix(7)
|
||||
lExpected = ['']
|
||||
utils.read_file(os.path.join(os.path.dirname(__file__),'Board_cpu.fixed.vhd'), lExpected)
|
||||
for iLineNumber, sLine in enumerate(lExpected):
|
||||
|
|
@ -31,7 +31,7 @@ class testCodeExample(unittest.TestCase):
|
|||
|
||||
def test_data_core(self):
|
||||
oRuleList = rule_list.rule_list(oDataCore)
|
||||
oRuleList.fix()
|
||||
oRuleList.fix(7)
|
||||
lExpected = ['']
|
||||
utils.read_file(os.path.join(os.path.dirname(__file__),'data_core.fixed.vhd'), lExpected)
|
||||
for iLineNumber, sLine in enumerate(lExpected):
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ class testCodeExample(unittest.TestCase):
|
|||
|
||||
def test_bresenhamer(self):
|
||||
oRuleList = rule_list.rule_list(oBresenhamer)
|
||||
oRuleList.fix()
|
||||
oRuleList.fix(7)
|
||||
lExpected = ['']
|
||||
utils.read_file(os.path.join(os.path.dirname(__file__),'Bresenhamer.fixed.vhd'), lExpected)
|
||||
for iLineNumber, sLine in enumerate(lExpected):
|
||||
|
|
@ -26,7 +26,7 @@ class testCodeExample(unittest.TestCase):
|
|||
|
||||
def test_debouncer(self):
|
||||
oRuleList = rule_list.rule_list(oDebouncer)
|
||||
oRuleList.fix()
|
||||
oRuleList.fix(7)
|
||||
lExpected = ['']
|
||||
utils.read_file(os.path.join(os.path.dirname(__file__),'Debouncer.fixed.vhd'), lExpected)
|
||||
for iLineNumber, sLine in enumerate(lExpected):
|
||||
|
|
@ -34,7 +34,7 @@ class testCodeExample(unittest.TestCase):
|
|||
|
||||
def test_vga_top(self):
|
||||
oRuleList = rule_list.rule_list(oVgatop)
|
||||
oRuleList.fix()
|
||||
oRuleList.fix(7)
|
||||
lExpected = ['']
|
||||
utils.read_file(os.path.join(os.path.dirname(__file__),'VGA_Top.fixed.vhd'), lExpected)
|
||||
for iLineNumber, sLine in enumerate(lExpected):
|
||||
|
|
@ -42,7 +42,7 @@ class testCodeExample(unittest.TestCase):
|
|||
|
||||
def test_pointer(self):
|
||||
oRuleList = rule_list.rule_list(oPointer)
|
||||
oRuleList.fix()
|
||||
oRuleList.fix(7)
|
||||
lExpected = ['']
|
||||
utils.read_file(os.path.join(os.path.dirname(__file__),'Pointer.fixed.vhd'), lExpected)
|
||||
for iLineNumber, sLine in enumerate(lExpected):
|
||||
|
|
@ -50,7 +50,7 @@ class testCodeExample(unittest.TestCase):
|
|||
|
||||
def test_freqdiv(self):
|
||||
oRuleList = rule_list.rule_list(oFreqDiv)
|
||||
oRuleList.fix()
|
||||
oRuleList.fix(7)
|
||||
lExpected = ['']
|
||||
utils.read_file(os.path.join(os.path.dirname(__file__),'FreqDiv.fixed.vhd'), lExpected)
|
||||
for iLineNumber, sLine in enumerate(lExpected):
|
||||
|
|
@ -58,7 +58,7 @@ class testCodeExample(unittest.TestCase):
|
|||
|
||||
def test_synchronizer(self):
|
||||
oRuleList = rule_list.rule_list(oSynchronizer)
|
||||
oRuleList.fix()
|
||||
oRuleList.fix(7)
|
||||
lExpected = ['']
|
||||
utils.read_file(os.path.join(os.path.dirname(__file__),'Synchronizer.fixed.vhd'), lExpected)
|
||||
for iLineNumber, sLine in enumerate(lExpected):
|
||||
|
|
@ -66,7 +66,7 @@ class testCodeExample(unittest.TestCase):
|
|||
|
||||
def test_framebuffer(self):
|
||||
oRuleList = rule_list.rule_list(oFrameBuffer)
|
||||
oRuleList.fix()
|
||||
oRuleList.fix(7)
|
||||
lExpected = ['']
|
||||
utils.read_file(os.path.join(os.path.dirname(__file__),'FrameBuffer2.fixed.vhd'), lExpected)
|
||||
for iLineNumber, sLine in enumerate(lExpected):
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ class testVhdlFileMethods(unittest.TestCase):
|
|||
|
||||
def test_timestamp_vhdl(self):
|
||||
oRuleList = rule_list.rule_list(oTimestamp)
|
||||
oRuleList.fix()
|
||||
oRuleList.fix(7)
|
||||
lExpected = ['']
|
||||
utils.read_file(os.path.join(os.path.dirname(__file__),'timestamp.fixed.vhdl'), lExpected)
|
||||
for iLineNumber, sLine in enumerate(lExpected):
|
||||
|
|
@ -24,7 +24,7 @@ class testVhdlFileMethods(unittest.TestCase):
|
|||
|
||||
def test_spi_slave(self):
|
||||
oRuleList = rule_list.rule_list(oSpiSlave)
|
||||
oRuleList.fix()
|
||||
oRuleList.fix(7)
|
||||
lExpected = ['']
|
||||
utils.read_file(os.path.join(os.path.dirname(__file__),'spi_slave.fixed.vhd'), lExpected)
|
||||
for iLineNumber, sLine in enumerate(lExpected):
|
||||
|
|
@ -32,7 +32,7 @@ class testVhdlFileMethods(unittest.TestCase):
|
|||
|
||||
def test_spi_master(self):
|
||||
oRuleList = rule_list.rule_list(oSpiMaster)
|
||||
oRuleList.fix()
|
||||
oRuleList.fix(7)
|
||||
lExpected = ['']
|
||||
utils.read_file(os.path.join(os.path.dirname(__file__),'spi_master.fixed.vhd'), lExpected)
|
||||
for iLineNumber, sLine in enumerate(lExpected):
|
||||
|
|
@ -40,7 +40,7 @@ class testVhdlFileMethods(unittest.TestCase):
|
|||
|
||||
def test_grp_debouncer(self):
|
||||
oRuleList = rule_list.rule_list(oGrpDebouncer)
|
||||
oRuleList.fix()
|
||||
oRuleList.fix(7)
|
||||
lExpected = ['']
|
||||
utils.read_file(os.path.join(os.path.dirname(__file__),'grp_debouncer.fixed.vhd'), lExpected)
|
||||
for iLineNumber, sLine in enumerate(lExpected):
|
||||
|
|
@ -48,7 +48,7 @@ class testVhdlFileMethods(unittest.TestCase):
|
|||
|
||||
def test_pic(self):
|
||||
oRuleList = rule_list.rule_list(oPIC)
|
||||
oRuleList.fix()
|
||||
oRuleList.fix(7)
|
||||
lExpected = ['']
|
||||
utils.read_file(os.path.join(os.path.dirname(__file__),'PIC.fixed.vhd'), lExpected)
|
||||
for iLineNumber, sLine in enumerate(lExpected):
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ class testCodeExample(unittest.TestCase):
|
|||
|
||||
def test_iteration_synth(self):
|
||||
oRuleList = rule_list.rule_list(oIteration)
|
||||
oRuleList.fix()
|
||||
oRuleList.fix(7)
|
||||
lExpected = ['']
|
||||
utils.read_file(os.path.join(os.path.dirname(__file__),'iteration_synth.fixed.vhd'), lExpected)
|
||||
for iLineNumber, sLine in enumerate(lExpected):
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ class testFixRuleCommentMethods(unittest.TestCase):
|
|||
def test_rule_001(self):
|
||||
oRuleList = rule_list.rule_list(oFileLibrary)
|
||||
dExpected = []
|
||||
oRuleList.fix()
|
||||
oRuleList.fix(7)
|
||||
oRuleList.check_rules()
|
||||
|
||||
self.assertEqual(oFileLibrary.lines[4].indentLevel, 1)
|
||||
|
|
|
|||
|
|
@ -214,7 +214,7 @@ class testFixRuleIfMethods(unittest.TestCase):
|
|||
|
||||
def test_fix_compressed_line(self):
|
||||
oRuleList = rule_list.rule_list(oFileCompress)
|
||||
oRuleList.fix()
|
||||
oRuleList.fix(7)
|
||||
# utils.debug_lines(oFileCompress, 9, 10)
|
||||
self.assertEqual(oFileCompress.lines[10].line, ' if (A = \'1\' and B = \'1\') then')
|
||||
self.assertEqual(oFileCompress.lines[11].line, ' X <= \'1\';')
|
||||
|
|
|
|||
Loading…
Reference in New Issue