diff --git a/vsg/rule_list.py b/vsg/rule_list.py index 468fcbb6..76796ecc 100644 --- a/vsg/rule_list.py +++ b/vsg/rule_list.py @@ -142,6 +142,10 @@ class rule_list(): self.oVhdlFile.set_token_indent() continue + # Update indents before checking indent + if phase == 4: + self.oVhdlFile.set_token_indent() + for subphase in range(0, 5): lRules = self.get_rules_in_phase(phase) lRules = self.get_rules_in_subphase(lRules, subphase) diff --git a/vsg/tests/styles/code_examples/library_statements.vhd b/vsg/tests/styles/code_examples/library_statements.vhd new file mode 100644 index 00000000..5cf5ff1a --- /dev/null +++ b/vsg/tests/styles/code_examples/library_statements.vhd @@ -0,0 +1,8 @@ +library work; +use work.tb_utilities.all; +use work.tb_wait_clock_package.all; +use work.random_pkg.all; + +use work.dsd_types.all; +--use work.channel_types.all; + diff --git a/vsg/tests/styles/jcl/library_statements.fixed.vhd b/vsg/tests/styles/jcl/library_statements.fixed.vhd new file mode 100644 index 00000000..b2bd78a2 --- /dev/null +++ b/vsg/tests/styles/jcl/library_statements.fixed.vhd @@ -0,0 +1,7 @@ +library work; + use work.tb_utilities.all; + use work.tb_wait_clock_package.all; + use work.random_pkg.all; + use work.dsd_types.all; + -- use work.channel_types.all; + diff --git a/vsg/tests/styles/jcl/test_code_examples.py b/vsg/tests/styles/jcl/test_code_examples.py index 4120b397..7e4247d4 100644 --- a/vsg/tests/styles/jcl/test_code_examples.py +++ b/vsg/tests/styles/jcl/test_code_examples.py @@ -32,6 +32,10 @@ lPIC, ePICError = vhdlFile.utils.read_vhdlfile(os.path.join(sSourceCodeDir,'PIC. oPIC = vhdlFile.vhdlFile(lPIC) oPIC.set_indent_map(dIndentMap) +lLibraryStatements, eLibraryStatementsError = vhdlFile.utils.read_vhdlfile(os.path.join(sSourceCodeDir,'library_statements.vhd')) +oLibraryStatements = vhdlFile.vhdlFile(lLibraryStatements) +oLibraryStatements.set_indent_map(dIndentMap) + oConfig = utils.read_configuration(os.path.join(os.path.dirname(__file__),'..','..','..','styles', 'jcl.yaml')) oSeverityList = severity.create_list({}) @@ -44,6 +48,7 @@ class testCodeExample(unittest.TestCase): self.assertIsNone(eSpiMasterError) self.assertIsNone(eGrpDebouncerError) self.assertIsNone(ePICError) + self.assertIsNone(eLibraryStatementsError) def test_timestamp_vhdl(self): oRuleList = rule_list.rule_list(oTimestamp, oSeverityList) @@ -93,3 +98,17 @@ class testCodeExample(unittest.TestCase): utils.read_file(os.path.join(os.path.dirname(__file__),'PIC.fixed.vhd'), lExpected) self.assertEqual(lExpected, oPIC.get_lines()) + + def test_library_statements(self): + oRuleList = rule_list.rule_list(oLibraryStatements, oSeverityList) + oRuleList.configure(oConfig) + oRuleList.fix() + + lExpected = [''] + utils.read_file(os.path.join(os.path.dirname(__file__),'library_statements.fixed.vhd'), lExpected) + + self.assertEqual(lExpected, oLibraryStatements.get_lines()) + + self.assertFalse(oRuleList.violations) + oRuleList.check_rules() + self.assertFalse(oRuleList.violations)