From b0971f5501b52b3fdcd93f6b00ff6c67dffaa64f Mon Sep 17 00:00:00 2001 From: Jeremiah Leary Date: Sat, 26 Sep 2020 10:21:53 -0500 Subject: [PATCH] Refactored rule architecture_002 for new parser. 1) Removed rule architecture_002 2) Added rules: architecture_030 architecture_031 architecture_032 architecture_033 3) Updated documentation --- docs/architecture_rules.rst | 85 ++++++- vsg/rules/architecture/__init__.py | 6 +- vsg/rules/architecture/rule_030.py | 12 + vsg/rules/architecture/rule_031.py | 12 + vsg/rules/architecture/rule_032.py | 12 + vsg/rules/architecture/rule_033.py | 12 + ...architecture_classification_test_input.vhd | 34 --- .../architecture_comment_test_input.vhd | 12 - .../architecture_end_test_input.vhd | 32 --- ...chitecture_loop_in_function_test_input.vhd | 23 -- .../architecture_loop_test_input.vhd | 17 -- .../architecture/architecture_test_input.vhd | 85 ------- .../rule_029_configurations_test_input.vhd | 18 -- .../rule_030_test_input.fixed.vhd | 11 + .../architecture/rule_030_test_input.vhd | 11 + .../rule_031_test_input.fixed.vhd | 11 + .../architecture/rule_031_test_input.vhd | 11 + .../rule_032_test_input.fixed.vhd | 11 + .../architecture/rule_032_test_input.vhd | 11 + .../rule_033_test_input.fixed.vhd | 11 + .../architecture/rule_033_test_input.vhd | 11 + .../test_fix_rule_architecture.py | 204 --------------- vsg/tests/architecture/test_rule_030.py | 46 ++++ vsg/tests/architecture/test_rule_031.py | 46 ++++ vsg/tests/architecture/test_rule_032.py | 46 ++++ vsg/tests/architecture/test_rule_033.py | 46 ++++ .../architecture/test_rule_architecture.py | 36 --- vsg/tests/vhdlFile/test_vhdlFile.py | 22 -- .../vhdlFile/test_vhdlFile_architecture.py | 237 ------------------ 29 files changed, 398 insertions(+), 733 deletions(-) create mode 100644 vsg/rules/architecture/rule_030.py create mode 100644 vsg/rules/architecture/rule_031.py create mode 100644 vsg/rules/architecture/rule_032.py create mode 100644 vsg/rules/architecture/rule_033.py delete mode 100644 vsg/tests/architecture/architecture_classification_test_input.vhd delete mode 100644 vsg/tests/architecture/architecture_comment_test_input.vhd delete mode 100644 vsg/tests/architecture/architecture_end_test_input.vhd delete mode 100644 vsg/tests/architecture/architecture_loop_in_function_test_input.vhd delete mode 100644 vsg/tests/architecture/architecture_loop_test_input.vhd delete mode 100644 vsg/tests/architecture/architecture_test_input.vhd delete mode 100644 vsg/tests/architecture/rule_029_configurations_test_input.vhd create mode 100644 vsg/tests/architecture/rule_030_test_input.fixed.vhd create mode 100644 vsg/tests/architecture/rule_030_test_input.vhd create mode 100644 vsg/tests/architecture/rule_031_test_input.fixed.vhd create mode 100644 vsg/tests/architecture/rule_031_test_input.vhd create mode 100644 vsg/tests/architecture/rule_032_test_input.fixed.vhd create mode 100644 vsg/tests/architecture/rule_032_test_input.vhd create mode 100644 vsg/tests/architecture/rule_033_test_input.fixed.vhd create mode 100644 vsg/tests/architecture/rule_033_test_input.vhd delete mode 100644 vsg/tests/architecture/test_fix_rule_architecture.py create mode 100644 vsg/tests/architecture/test_rule_030.py create mode 100644 vsg/tests/architecture/test_rule_031.py create mode 100644 vsg/tests/architecture/test_rule_032.py create mode 100644 vsg/tests/architecture/test_rule_033.py delete mode 100644 vsg/tests/architecture/test_rule_architecture.py delete mode 100644 vsg/tests/vhdlFile/test_vhdlFile_architecture.py diff --git a/docs/architecture_rules.rst b/docs/architecture_rules.rst index 994751dc..f4fa967a 100644 --- a/docs/architecture_rules.rst +++ b/docs/architecture_rules.rst @@ -23,19 +23,12 @@ This rule checks for blank spaces before the **architecture** keyword. architecture_002 ################ -This rule checks for a single space between **architecture**, **of**, and **is** keywords. +This rule has been split into the following rules: -**Violation** - -.. code-block:: vhdl - - architecture rtl of fifo is - -**Fix** - -.. code-block:: vhdl - - architecture rtl of fifo is +* architecture_030 +* architecture_031 +* architecture_032 +* architecture_033 architecture_003 ################ @@ -595,3 +588,71 @@ Refer to the section `Configuring Identifier Alignment Rules w_sig1, - ENDAT_DATA_RC => endat_DATA_RC, - endsignal => w_sig2 - ); - - END_PROC : process () is - begin - end process END_PROC; - - ENDPROC : process () is - begin - end process ENDPROC; - -end architecture RTL; - diff --git a/vsg/tests/architecture/architecture_loop_in_function_test_input.vhd b/vsg/tests/architecture/architecture_loop_in_function_test_input.vhd deleted file mode 100644 index 0743d936..00000000 --- a/vsg/tests/architecture/architecture_loop_in_function_test_input.vhd +++ /dev/null @@ -1,23 +0,0 @@ - - -architecture ARCH of ENTITY is - - function FUNC1 return RESULT is - variable a : integer; - variable b : integer; - begin - - for i in 0 to 32 loop - a(i) := 0; - end loop; - return a; - - end FUNC1; - -begin - - - -end architecture ARCH; - - diff --git a/vsg/tests/architecture/architecture_loop_test_input.vhd b/vsg/tests/architecture/architecture_loop_test_input.vhd deleted file mode 100644 index ade5d5e2..00000000 --- a/vsg/tests/architecture/architecture_loop_test_input.vhd +++ /dev/null @@ -1,17 +0,0 @@ - - -architecture ARCH of ent1 is - -begin - - process begin - - for i in 0 to 32 loop - - end loop; - - end process; - -end architecture ARCH; - - diff --git a/vsg/tests/architecture/architecture_test_input.vhd b/vsg/tests/architecture/architecture_test_input.vhd deleted file mode 100644 index d1c2020e..00000000 --- a/vsg/tests/architecture/architecture_test_input.vhd +++ /dev/null @@ -1,85 +0,0 @@ - - -architecture Arch of ENTITY is - -begin - -End architecture ARCH; - - architecture ARCH of EntITY is - -begin - -end Architecture; -architecture ARCH of ENTITY is - -begin - -end architecture ARCH; - - Architecture ARch Of entity Is - - begin - - eND architecture ArCh; - -architecture ARch - of ENTITY is - -BEGIN - - end archITecture ARCH; - -architecture ARCH of ENTITY iS -begin -end architecture ARCH; - -architecture ARCH of ENTITY is - -begin - - process () is - begin - end process; - -end architecture ARCH; - -architecture ARCH of ENTITY is - -begin - - process () is - begin - end process; - -end ARCH; - --- Comment - -architecture ARCH of ENTITY is - -begin - - GEN1 : if CONDITION = 1 generate - - process () is - begin - end process; - - end generate; - - END_PROC : process () is - begin - end process END_PROC; - - end_signal <= '0'; - -end; - --- Comment - -architecture ARCH of ent is - -begin - -end architecture ARCH; diff --git a/vsg/tests/architecture/rule_029_configurations_test_input.vhd b/vsg/tests/architecture/rule_029_configurations_test_input.vhd deleted file mode 100644 index 1afcd08a..00000000 --- a/vsg/tests/architecture/rule_029_configurations_test_input.vhd +++ /dev/null @@ -1,18 +0,0 @@ - - -architecture ARCH of ENTITY1 is - - signal sig1 : std_logic; - file fil1 : something; - -- Comment1 - type typ1 is range 31 downto 0; - subtype sub1 is resolved std_ulogic; - -- Comment1 - variable var1 : integer; - constant con1 : integer := 0; - - attribute att1 : some_attr; - -begin - -end architecture ARCH; diff --git a/vsg/tests/architecture/rule_030_test_input.fixed.vhd b/vsg/tests/architecture/rule_030_test_input.fixed.vhd new file mode 100644 index 00000000..5f8597dc --- /dev/null +++ b/vsg/tests/architecture/rule_030_test_input.fixed.vhd @@ -0,0 +1,11 @@ + +architecture rtl of fifo is begin end architecture rtl; + +architecture rtl of fifo is begin end architecture rtl; + +architecture rtl of fifo is begin end architecture rtl; + +architecture rtl of fifo is begin end architecture rtl; + +architecture rtl of fifo is begin end architecture rtl; + diff --git a/vsg/tests/architecture/rule_030_test_input.vhd b/vsg/tests/architecture/rule_030_test_input.vhd new file mode 100644 index 00000000..cf4b5e56 --- /dev/null +++ b/vsg/tests/architecture/rule_030_test_input.vhd @@ -0,0 +1,11 @@ + +architecture rtl of fifo is begin end architecture rtl; + +architecture rtl of fifo is begin end architecture rtl; + +architecture rtl of fifo is begin end architecture rtl; + +architecture rtl of fifo is begin end architecture rtl; + +architecture rtl of fifo is begin end architecture rtl; + diff --git a/vsg/tests/architecture/rule_031_test_input.fixed.vhd b/vsg/tests/architecture/rule_031_test_input.fixed.vhd new file mode 100644 index 00000000..1481ab7d --- /dev/null +++ b/vsg/tests/architecture/rule_031_test_input.fixed.vhd @@ -0,0 +1,11 @@ + +architecture rtl of fifo is begin end architecture rtl; + +architecture rtl of fifo is begin end architecture rtl; + +architecture rtl of fifo is begin end architecture rtl; + +architecture rtl of fifo is begin end architecture rtl; + +architecture rtl of fifo is begin end architecture rtl; + diff --git a/vsg/tests/architecture/rule_031_test_input.vhd b/vsg/tests/architecture/rule_031_test_input.vhd new file mode 100644 index 00000000..cf4b5e56 --- /dev/null +++ b/vsg/tests/architecture/rule_031_test_input.vhd @@ -0,0 +1,11 @@ + +architecture rtl of fifo is begin end architecture rtl; + +architecture rtl of fifo is begin end architecture rtl; + +architecture rtl of fifo is begin end architecture rtl; + +architecture rtl of fifo is begin end architecture rtl; + +architecture rtl of fifo is begin end architecture rtl; + diff --git a/vsg/tests/architecture/rule_032_test_input.fixed.vhd b/vsg/tests/architecture/rule_032_test_input.fixed.vhd new file mode 100644 index 00000000..124df1c6 --- /dev/null +++ b/vsg/tests/architecture/rule_032_test_input.fixed.vhd @@ -0,0 +1,11 @@ + +architecture rtl of fifo is begin end architecture rtl; + +architecture rtl of fifo is begin end architecture rtl; + +architecture rtl of fifo is begin end architecture rtl; + +architecture rtl of fifo is begin end architecture rtl; + +architecture rtl of fifo is begin end architecture rtl; + diff --git a/vsg/tests/architecture/rule_032_test_input.vhd b/vsg/tests/architecture/rule_032_test_input.vhd new file mode 100644 index 00000000..cf4b5e56 --- /dev/null +++ b/vsg/tests/architecture/rule_032_test_input.vhd @@ -0,0 +1,11 @@ + +architecture rtl of fifo is begin end architecture rtl; + +architecture rtl of fifo is begin end architecture rtl; + +architecture rtl of fifo is begin end architecture rtl; + +architecture rtl of fifo is begin end architecture rtl; + +architecture rtl of fifo is begin end architecture rtl; + diff --git a/vsg/tests/architecture/rule_033_test_input.fixed.vhd b/vsg/tests/architecture/rule_033_test_input.fixed.vhd new file mode 100644 index 00000000..3c89c47e --- /dev/null +++ b/vsg/tests/architecture/rule_033_test_input.fixed.vhd @@ -0,0 +1,11 @@ + +architecture rtl of fifo is begin end architecture rtl; + +architecture rtl of fifo is begin end architecture rtl; + +architecture rtl of fifo is begin end architecture rtl; + +architecture rtl of fifo is begin end architecture rtl; + +architecture rtl of fifo is begin end architecture rtl; + diff --git a/vsg/tests/architecture/rule_033_test_input.vhd b/vsg/tests/architecture/rule_033_test_input.vhd new file mode 100644 index 00000000..cf4b5e56 --- /dev/null +++ b/vsg/tests/architecture/rule_033_test_input.vhd @@ -0,0 +1,11 @@ + +architecture rtl of fifo is begin end architecture rtl; + +architecture rtl of fifo is begin end architecture rtl; + +architecture rtl of fifo is begin end architecture rtl; + +architecture rtl of fifo is begin end architecture rtl; + +architecture rtl of fifo is begin end architecture rtl; + diff --git a/vsg/tests/architecture/test_fix_rule_architecture.py b/vsg/tests/architecture/test_fix_rule_architecture.py deleted file mode 100644 index 21b58885..00000000 --- a/vsg/tests/architecture/test_fix_rule_architecture.py +++ /dev/null @@ -1,204 +0,0 @@ -import os -import unittest - -from vsg.rules import architecture -from vsg import vhdlFile -from vsg.tests import utils - -# Read in test file used for all tests - -lFile = utils.read_vhdlfile(os.path.join(os.path.dirname(__file__),'architecture_test_input.vhd')) - -class testFixRuleArchitectureMethods(unittest.TestCase): - - def setUp(self): - self.oFile = vhdlFile.vhdlFile(lFile) - - def test_fix_rule_001(self): - oRule = architecture.rule_001() - dExpected = [] - oRule.fix(self.oFile) - oRule.analyze(self.oFile) - self.assertEqual(oRule.violations, dExpected) - - def test_fix_rule_002(self): - oRule = architecture.rule_002() - dExpected = [] - oRule.fix(self.oFile) - oRule.analyze(self.oFile) - self.assertEqual(oRule.violations, dExpected) - - def test_fix_rule_003(self): - oRule = architecture.rule_003() - dExpected = [] - oRule.fix(self.oFile) - oRule.analyze(self.oFile) - self.assertEqual(oRule.violations, dExpected) - - def test_fix_rule_004_lowercase(self): - oRule = architecture.rule_004() - dExpected = [] - oRule.fix(self.oFile) - self.assertEqual(self.oFile.lines[20].line, ' architecture ARch Of entity Is') - - oRule.analyze(self.oFile) - self.assertEqual(oRule.violations, dExpected) - - def test_fix_rule_004_uppercase(self): - oRule = architecture.rule_004() - oRule.case = 'upper' - dExpected = [] - oRule.fix(self.oFile) - self.assertEqual(self.oFile.lines[20].line, ' ARCHITECTURE ARch Of entity Is') - - oRule.analyze(self.oFile) - self.assertEqual(oRule.violations, dExpected) - - def test_fix_rule_007(self): - oRule = architecture.rule_007() - dExpected = [] - oRule.fix(self.oFile) - oRule.analyze(self.oFile) - self.assertEqual(oRule.violations, dExpected) - - def test_fix_rule_008(self): - oRule = architecture.rule_008() - dExpected = [] - oRule.fix(self.oFile) - oRule.analyze(self.oFile) - self.assertEqual(oRule.violations, dExpected) - - def test_fix_rule_009(self): - oRule = architecture.rule_009() - dExpected = [] - oRule.fix(self.oFile) - oRule.analyze(self.oFile) - self.assertEqual(oRule.violations, dExpected) - - def test_fix_rule_012(self): - oRule = architecture.rule_012() - dExpected = [] - oRule.fix(self.oFile) - oRule.analyze(self.oFile) - self.assertEqual(oRule.violations, dExpected) - - def test_fix_rule_014_uppercase(self): - oRule = architecture.rule_014() - oRule.case = 'upper' - dExpected = [] - oRule.fix(self.oFile) - self.assertEqual(self.oFile.lines[81].line, 'architecture ARCH of ENT is') - - oRule.analyze(self.oFile) - self.assertEqual(oRule.violations, dExpected) - - def test_fix_rule_014_lowercase(self): - oRule = architecture.rule_014() - dExpected = [] - oRule.fix(self.oFile) - self.assertEqual(self.oFile.lines[59].line, 'architecture ARCH of entity is') - - oRule.analyze(self.oFile) - self.assertEqual(oRule.violations, dExpected) - - def test_fix_rule_016(self): - oRule = architecture.rule_016() - dExpected = [] - oRule.fix(self.oFile) - oRule.analyze(self.oFile) - self.assertEqual(oRule.violations, dExpected) - - def test_fix_rule_017(self): - oRule = architecture.rule_017() - dExpected = [] - oRule.fix(self.oFile) - oRule.analyze(self.oFile) - self.assertEqual(oRule.violations, dExpected) - - def test_fix_rule_018(self): - oRule = architecture.rule_018() - dExpected = [] - oRule.fix(self.oFile) - oRule.analyze(self.oFile) - self.assertEqual(oRule.violations, dExpected) - - def test_fix_rule_019_lowercase(self): - oRule = architecture.rule_019() - dExpected = [] - oRule.fix(self.oFile) - self.assertEqual(self.oFile.lines[20].line, ' Architecture ARch of entity Is') - - oRule.analyze(self.oFile) - self.assertEqual(oRule.violations, dExpected) - - def test_fix_rule_019_uppercase(self): - oRule = architecture.rule_019() - oRule.case = 'upper' - dExpected = [] - oRule.fix(self.oFile) - self.assertEqual(self.oFile.lines[20].line, ' Architecture ARch OF entity Is') - - oRule.analyze(self.oFile) - self.assertEqual(oRule.violations, dExpected) - - def test_fix_rule_020_lowercase(self): - oRule = architecture.rule_020() - dExpected = [] - oRule.fix(self.oFile) - self.assertEqual(self.oFile.lines[20].line, ' Architecture ARch Of entity is') - - oRule.analyze(self.oFile) - self.assertEqual(oRule.violations, dExpected) - - def test_fix_rule_020_uppercase(self): - oRule = architecture.rule_020() - oRule.case = 'upper' - dExpected = [] - oRule.fix(self.oFile) - self.assertEqual(self.oFile.lines[20].line, ' Architecture ARch Of entity IS') - - oRule.analyze(self.oFile) - self.assertEqual(oRule.violations, dExpected) - - def test_fix_rule_021_lowercase(self): - oRule = architecture.rule_021() - dExpected = [] - oRule.fix(self.oFile) - self.assertEqual(self.oFile.lines[29].line, 'begin') - - oRule.analyze(self.oFile) - self.assertEqual(oRule.violations, dExpected) - - def test_fix_rule_021_uppercase(self): - oRule = architecture.rule_021() - oRule.case = 'upper' - dExpected = [] - oRule.fix(self.oFile) - self.assertEqual(self.oFile.lines[39].line, 'BEGIN') - - oRule.analyze(self.oFile) - self.assertEqual(oRule.violations, dExpected) - - def test_fix_rule_022(self): - oRule = architecture.rule_022() - dExpected = [] - oRule.fix(self.oFile) - oRule.analyze(self.oFile) - self.assertEqual(oRule.violations, dExpected) - - def test_fix_rule_024(self): - oRule = architecture.rule_024() - dExpected = [] - oRule.fix(self.oFile) - oRule.analyze(self.oFile) - self.assertEqual(self.oFile.lines[13].line, 'end Architecture ARCH;') - self.assertEqual(self.oFile.lines[77].line, 'end ARCH;') - self.assertEqual(oRule.violations, dExpected) - - def test_fix_rule_027(self): - oRule = architecture.rule_027() - dExpected = [] - oRule.fix(self.oFile) - oRule.analyze(self.oFile) - self.assertEqual(oRule.violations, dExpected) - diff --git a/vsg/tests/architecture/test_rule_030.py b/vsg/tests/architecture/test_rule_030.py new file mode 100644 index 00000000..7fca7dde --- /dev/null +++ b/vsg/tests/architecture/test_rule_030.py @@ -0,0 +1,46 @@ + +import os +import unittest + +from vsg.rules import architecture +from vsg import vhdlFile +from vsg.tests import utils + +sTestDir = os.path.dirname(__file__) + +lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_030_test_input.vhd')) + +lExpected = [] +lExpected.append('') +utils.read_file(os.path.join(sTestDir, 'rule_030_test_input.fixed.vhd'), lExpected) + + +class test_architecture_rule(unittest.TestCase): + + def setUp(self): + self.oFile = vhdlFile.vhdlFile(lFile) + + def test_rule_030(self): + oRule = architecture.rule_030() + self.assertTrue(oRule) + self.assertEqual(oRule.name, 'architecture') + self.assertEqual(oRule.identifier, '030') + + lExpected = [4] + + oRule.analyze(self.oFile) + self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) + + def test_fix_rule_030(self): + oRule = architecture.rule_030() + + oRule.fix(self.oFile) + + lActual = [] + for oLine in self.oFile.lines: + lActual.append(oLine.line) + + self.assertEqual(lExpected, lActual) + + oRule.analyze(self.oFile) + self.assertEqual(oRule.violations, []) diff --git a/vsg/tests/architecture/test_rule_031.py b/vsg/tests/architecture/test_rule_031.py new file mode 100644 index 00000000..de36c7fb --- /dev/null +++ b/vsg/tests/architecture/test_rule_031.py @@ -0,0 +1,46 @@ + +import os +import unittest + +from vsg.rules import architecture +from vsg import vhdlFile +from vsg.tests import utils + +sTestDir = os.path.dirname(__file__) + +lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_031_test_input.vhd')) + +lExpected = [] +lExpected.append('') +utils.read_file(os.path.join(sTestDir, 'rule_031_test_input.fixed.vhd'), lExpected) + + +class test_architecture_rule(unittest.TestCase): + + def setUp(self): + self.oFile = vhdlFile.vhdlFile(lFile) + + def test_rule_031(self): + oRule = architecture.rule_031() + self.assertTrue(oRule) + self.assertEqual(oRule.name, 'architecture') + self.assertEqual(oRule.identifier, '031') + + lExpected = [6] + + oRule.analyze(self.oFile) + self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) + + def test_fix_rule_031(self): + oRule = architecture.rule_031() + + oRule.fix(self.oFile) + + lActual = [] + for oLine in self.oFile.lines: + lActual.append(oLine.line) + + self.assertEqual(lExpected, lActual) + + oRule.analyze(self.oFile) + self.assertEqual(oRule.violations, []) diff --git a/vsg/tests/architecture/test_rule_032.py b/vsg/tests/architecture/test_rule_032.py new file mode 100644 index 00000000..81975c3e --- /dev/null +++ b/vsg/tests/architecture/test_rule_032.py @@ -0,0 +1,46 @@ + +import os +import unittest + +from vsg.rules import architecture +from vsg import vhdlFile +from vsg.tests import utils + +sTestDir = os.path.dirname(__file__) + +lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_032_test_input.vhd')) + +lExpected = [] +lExpected.append('') +utils.read_file(os.path.join(sTestDir, 'rule_032_test_input.fixed.vhd'), lExpected) + + +class test_architecture_rule(unittest.TestCase): + + def setUp(self): + self.oFile = vhdlFile.vhdlFile(lFile) + + def test_rule_032(self): + oRule = architecture.rule_032() + self.assertTrue(oRule) + self.assertEqual(oRule.name, 'architecture') + self.assertEqual(oRule.identifier, '032') + + lExpected = [8] + + oRule.analyze(self.oFile) + self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) + + def test_fix_rule_032(self): + oRule = architecture.rule_032() + + oRule.fix(self.oFile) + + lActual = [] + for oLine in self.oFile.lines: + lActual.append(oLine.line) + + self.assertEqual(lExpected, lActual) + + oRule.analyze(self.oFile) + self.assertEqual(oRule.violations, []) diff --git a/vsg/tests/architecture/test_rule_033.py b/vsg/tests/architecture/test_rule_033.py new file mode 100644 index 00000000..0cb7a5a5 --- /dev/null +++ b/vsg/tests/architecture/test_rule_033.py @@ -0,0 +1,46 @@ + +import os +import unittest + +from vsg.rules import architecture +from vsg import vhdlFile +from vsg.tests import utils + +sTestDir = os.path.dirname(__file__) + +lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_033_test_input.vhd')) + +lExpected = [] +lExpected.append('') +utils.read_file(os.path.join(sTestDir, 'rule_033_test_input.fixed.vhd'), lExpected) + + +class test_architecture_rule(unittest.TestCase): + + def setUp(self): + self.oFile = vhdlFile.vhdlFile(lFile) + + def test_rule_033(self): + oRule = architecture.rule_033() + self.assertTrue(oRule) + self.assertEqual(oRule.name, 'architecture') + self.assertEqual(oRule.identifier, '033') + + lExpected = [10] + + oRule.analyze(self.oFile) + self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations)) + + def test_fix_rule_033(self): + oRule = architecture.rule_033() + + oRule.fix(self.oFile) + + lActual = [] + for oLine in self.oFile.lines: + lActual.append(oLine.line) + + self.assertEqual(lExpected, lActual) + + oRule.analyze(self.oFile) + self.assertEqual(oRule.violations, []) diff --git a/vsg/tests/architecture/test_rule_architecture.py b/vsg/tests/architecture/test_rule_architecture.py deleted file mode 100644 index 69dc82d7..00000000 --- a/vsg/tests/architecture/test_rule_architecture.py +++ /dev/null @@ -1,36 +0,0 @@ -import os -import unittest - -from vsg.rules import architecture -from vsg import vhdlFile -from vsg.tests import utils - -# Read in test file used for all tests -lFile = utils.read_vhdlfile(os.path.join(os.path.dirname(__file__),'..','architecture','architecture_test_input.vhd')) -oFile = vhdlFile.vhdlFile(lFile) - -lFileComment = utils.read_vhdlfile(os.path.join(os.path.dirname(__file__),'..','architecture','architecture_comment_test_input.vhd')) -oFileComment = vhdlFile.vhdlFile(lFileComment) - - -class testRuleArchitectureMethods(unittest.TestCase): - - def test_rule_002_exists(self): - oRule = architecture.rule_002() - self.assertTrue(oRule) - self.assertEqual(oRule.name, 'architecture') - self.assertEqual(oRule.identifier, '002') - - def test_rule_002(self): - oRule = architecture.rule_002() - - dExpected = [utils.add_violation(14)] - oRule.analyze(oFile) - self.assertEqual(oRule.violations, dExpected) - - def test_rule_003_exists(self): - oRule = architecture.rule_003() - self.assertTrue(oRule) - self.assertEqual(oRule.name, 'architecture') - self.assertEqual(oRule.identifier, '003') - diff --git a/vsg/tests/vhdlFile/test_vhdlFile.py b/vsg/tests/vhdlFile/test_vhdlFile.py index fc834a17..c9af0cd3 100644 --- a/vsg/tests/vhdlFile/test_vhdlFile.py +++ b/vsg/tests/vhdlFile/test_vhdlFile.py @@ -18,8 +18,6 @@ lFileEntity = utils.read_vhdlfile(os.path.join(os.path.dirname(__file__),'..','e oFileEntity = vhdlFile.vhdlFile(lFileEntity) lFileConcurrent = utils.read_vhdlfile(os.path.join(os.path.dirname(__file__),'..','concurrent','concurrent_test_input.vhd')) oFileConcurrent = vhdlFile.vhdlFile(lFileConcurrent) -lFileArchitectureLoop = utils.read_vhdlfile(os.path.join(os.path.dirname(__file__),'..','architecture','architecture_loop_test_input.vhd')) -oFileArchitectureLoop = vhdlFile.vhdlFile(lFileArchitectureLoop) lFileArchitectureFunctionLoop = utils.read_vhdlfile(os.path.join(os.path.dirname(__file__),'..','architecture','architecture_loop_in_function_test_input.vhd')) oFileArchitectureFunctionLoop = vhdlFile.vhdlFile(lFileArchitectureFunctionLoop) lFileFunction = utils.read_vhdlfile(os.path.join(os.path.dirname(__file__),'..','function','function_test_input.vhd')) @@ -212,26 +210,6 @@ class testVhdlFileMethods(unittest.TestCase): # Compare self.assertEqual(lActual, lExpected) - def test_isEndArchitecture_assignment_with_loop(self): - lExpected = [15] - # Generic actual list - lActual = [] - for iIndex, oLine in enumerate(oFileArchitectureLoop.lines): - if oLine.isEndArchitecture: - lActual.append(iIndex) - # Compare - self.assertEqual(lActual, lExpected) - - def test_isEndArchitecture_assignment_with_loop_inside_function(self): - lExpected = [21] - # Generic actual list - lActual = [] - for iIndex, oLine in enumerate(oFileArchitectureFunctionLoop.lines): - if oLine.isEndArchitecture: - lActual.append(iIndex) - # Compare - self.assertEqual(lActual, lExpected) - def test_isEndArchitecture_function_assignment(self): lExpected = [122, 153] # Generic actual list diff --git a/vsg/tests/vhdlFile/test_vhdlFile_architecture.py b/vsg/tests/vhdlFile/test_vhdlFile_architecture.py deleted file mode 100644 index e14ff59b..00000000 --- a/vsg/tests/vhdlFile/test_vhdlFile_architecture.py +++ /dev/null @@ -1,237 +0,0 @@ -import os - -import unittest -from vsg import vhdlFile -from vsg.tests import utils -from vsg.token import architecture_body - - -lFileArchitecture = utils.read_vhdlfile(os.path.join(os.path.dirname(__file__),'..','architecture','architecture_test_input.vhd')) -oFileArchitecture = vhdlFile.vhdlFile(lFileArchitecture) - -lFileArch2 = utils.read_vhdlfile(os.path.join(os.path.dirname(__file__),'..','architecture','rule_029_test_input.vhd')) -oFileArch2 = vhdlFile.vhdlFile(lFileArch2) - -lFile = utils.read_vhdlfile(os.path.join(os.path.dirname(__file__),'..','architecture','architecture_classification_test_input.vhd')) -oFile = vhdlFile.vhdlFile(lFile) - -class testVhdlFileMethods(unittest.TestCase): - - def test_insideArchitecture_assignment(self): - lExpected = [3,4,5,6,7,9,10,11,12,13,14,15,16,17,18,20,21,22,23,24,26,27,28,29,30,31,33,34,35,37,38,39,40,41,42,43,44,45,47,48,49,50,51,52,53,54,55,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,81,82,83,84,85] - # Generic actual list - lActual = [] - for iIndex, oLine in enumerate(oFileArchitecture.lines): - if oLine.insideArchitecture: - lActual.append(iIndex) - # Compare - self.assertEqual(lActual, lExpected) - - def test_isArchitectureBegin_assignment(self): - lExpected = [5,11,16,22,29,34,39,49,61,83] - # Generic actual list - lActual = [] - for iIndex, oLine in enumerate(oFileArchitecture.lines): - if oLine.isArchitectureBegin: - lActual.append(iIndex) - # Compare - self.assertEqual(lActual, lExpected) - - def test_isArchitectureKeyword_assignment(self): - lExpected = [3,9,14,20,26,33,37,47,59,81] - # Generic actual list - lActual = [] - for iIndex, oLine in enumerate(oFileArchitecture.lines): - if oLine.isArchitectureKeyword: - lActual.append(iIndex) - # Compare - self.assertEqual(lActual, lExpected) - - def test_isEndArchitecture_assignment(self): - lExpected = [7,13,18,24,31,35,45,55,77,85] - # Generic actual list - lActual = [] - for iIndex, oLine in enumerate(oFileArchitecture.lines): - if oLine.isEndArchitecture: - lActual.append(iIndex) - # Compare - self.assertEqual(lActual, lExpected) - - def test_insideArchitectureDeclarativeRegion(self): - lExpected = [] - lExpected.extend(range(3,6)) - lExpected.extend(range(9,12)) - lExpected.extend(range(14,17)) - lExpected.extend(range(20,23)) - lExpected.extend(range(26,30)) - lExpected.extend(range(33,35)) - lExpected.extend(range(37,40)) - lExpected.extend(range(47,50)) - lExpected.extend(range(59,62)) - lExpected.extend(range(81,84)) - # Generic actual list - lActual = [] - for iIndex, oLine in enumerate(oFileArchitecture.lines): - if oLine.insideArchitectureDeclarativeRegion: - lActual.append(iIndex) - # Compare - self.assertEqual(lActual, lExpected) - - def test_insideArchitectureDeclarativeRegion_2(self): - lExpected = [] - lExpected.extend(range(2,59)) - lExpected.extend(range(64,120)) - # Generic actual list - lActual = [] - for iIndex, oLine in enumerate(oFileArch2.lines): - if oLine.insideArchitectureDeclarativeRegion: - lActual.append(iIndex) - # Compare - self.assertEqual(lActual, lExpected) - - def test_architecture_keyword(self): - lExpected = [] - lExpected.append((3,0)) - lExpected.append((11,0)) - lExpected.append((18,0)) - lExpected.append((25,0)) -# utils.print_objects(oFile, True) - lActual = [] - for iLine, lLine in enumerate(oFile.get_lines()): - for iItem, oItem in enumerate(lLine.objects): - if isinstance(oItem, architecture_body.architecture_keyword): - lActual.append((iLine, iItem)) - - self.assertEqual(lExpected, lActual) - - def test_architecture_semicolon(self): - lExpected = [] - lExpected.append((7,5)) - lExpected.append((15,1)) - lExpected.append((22,3)) - lExpected.append((34,0)) - - lActual = [] - for iLine, lLine in enumerate(oFile.get_lines()): - for iItem, oItem in enumerate(lLine.objects): - if isinstance(oItem, architecture_body.semicolon): - lActual.append((iLine, iItem)) - - self.assertEqual(lExpected, lActual) - - def test_architecture_end_keyword(self): - lExpected = [] - lExpected.append((7,0)) - lExpected.append((15,0)) - lExpected.append((22,0)) - lExpected.append((31,0)) - - lActual = [] - for iLine, lLine in enumerate(oFile.get_lines()): - for iItem, oItem in enumerate(lLine.objects): - if isinstance(oItem, architecture_body.end_keyword): - lActual.append((iLine, iItem)) - - self.assertEqual(lExpected, lActual) - - def test_architecture_end_architecture_keyword(self): - lExpected = [] - lExpected.append((7,2)) - lExpected.append((22,2)) - lExpected.append((32,0)) - - lActual = [] - for iLine, lLine in enumerate(oFile.get_lines()): - for iItem, oItem in enumerate(lLine.objects): - if isinstance(oItem, architecture_body.end_architecture_keyword): - lActual.append((iLine, iItem)) - - self.assertEqual(lExpected, lActual) - - def test_architecture_simple_name(self): - lExpected = [] - lExpected.append((7,4)) - lExpected.append((33,0)) - - lActual = [] - for iLine, lLine in enumerate(oFile.get_lines()): - for iItem, oItem in enumerate(lLine.objects): - if isinstance(oItem, architecture_body.architecture_simple_name): - lActual.append((iLine, iItem)) - - self.assertEqual(lExpected, lActual) - - def test_architecture_identifier(self): - lExpected = [] - lExpected.append((3,2)) - lExpected.append((11,2)) - lExpected.append((18,2)) - lExpected.append((26,0)) - - lActual = [] - for iLine, lLine in enumerate(oFile.get_lines()): - for iItem, oItem in enumerate(lLine.objects): - if isinstance(oItem, architecture_body.identifier): - lActual.append((iLine, iItem)) - - self.assertEqual(lExpected, lActual) - - def test_architecture_of_keyword(self): - lExpected = [] - lExpected.append((3,4)) - lExpected.append((11,4)) - lExpected.append((18,4)) - lExpected.append((27,0)) - - lActual = [] - for iLine, lLine in enumerate(oFile.get_lines()): - for iItem, oItem in enumerate(lLine.objects): - if isinstance(oItem, architecture_body.of_keyword): - lActual.append((iLine, iItem)) - - self.assertEqual(lExpected, lActual) - - def test_architecture_entity_name(self): - lExpected = [] - lExpected.append((3,6)) - lExpected.append((11,6)) - lExpected.append((18,6)) - lExpected.append((28,0)) - - lActual = [] - for iLine, lLine in enumerate(oFile.get_lines()): - for iItem, oItem in enumerate(lLine.objects): - if isinstance(oItem, architecture_body.entity_name): - lActual.append((iLine, iItem)) - - self.assertEqual(lExpected, lActual) - - def test_architecture_is_keyword(self): - lExpected = [] - lExpected.append((3,8)) - lExpected.append((11,8)) - lExpected.append((18,8)) - lExpected.append((29,0)) - - lActual = [] - for iLine, lLine in enumerate(oFile.get_lines()): - for iItem, oItem in enumerate(lLine.objects): - if isinstance(oItem, architecture_body.is_keyword): - lActual.append((iLine, iItem)) - - self.assertEqual(lExpected, lActual) - - def test_architecture_begin_keyword(self): - lExpected = [] - lExpected.append((5,0)) - lExpected.append((13,0)) - lExpected.append((20,0)) - lExpected.append((30,0)) - - lActual = [] - for iLine, lLine in enumerate(oFile.get_lines()): - for iItem, oItem in enumerate(lLine.objects): - if isinstance(oItem, architecture_body.begin_keyword): - lActual.append((iLine, iItem)) - - self.assertEqual(lExpected, lActual)