diff --git a/vsg/rule_list.py b/vsg/rule_list.py index 93defc73..468fcbb6 100644 --- a/vsg/rule_list.py +++ b/vsg/rule_list.py @@ -354,6 +354,7 @@ class rule_list(): dTemp = {} dTemp['rule'] = oRule.unique_id dTemp['linenumber'] = oViolation.get_line_number() + dTemp['severity'] = oRule.severity.name dTemp['solution'] = oViolation.get_solution() dReturn['violations'].append(dTemp) return dReturn diff --git a/vsg/tests/vsg/json-expected.json b/vsg/tests/vsg/json-expected.json new file mode 100644 index 00000000..d16538be --- /dev/null +++ b/vsg/tests/vsg/json-expected.json @@ -0,0 +1,34 @@ +{ + "files": [ + { + "file_path": "vsg/tests/vsg/entity2.vhd", + "violations": [ + { + "rule": "port_008", + "linenumber": 8, + "severity": "Error", + "solution": "Change the number of spaces after the *out* keyword to three spaces." + } + ] + }, + { + "file_path": "vsg/tests/vsg/entity_architecture.fixed.vhd", + "violations": [] + }, + { + "file_path": "vsg/tests/vsg/entity_architecture.vhd", + "violations": [] + }, + { + "file_path": "vsg/tests/vsg/entity1.vhd", + "violations": [ + { + "rule": "port_007", + "linenumber": 7, + "severity": "Error", + "solution": "Change the number of spaces after the *in* keyword to four spaces." + } + ] + } + ] +} diff --git a/vsg/tests/vsg/test_main.py b/vsg/tests/vsg/test_main.py index 089c8de8..101e9e80 100644 --- a/vsg/tests/vsg/test_main.py +++ b/vsg/tests/vsg/test_main.py @@ -397,6 +397,18 @@ class testMain(unittest.TestCase): self.assertTrue(os.path.isfile('deleteme.json')) + # Read in the expected JSON file for comparison + lExpected = [] + utils.read_file(os.path.join(os.path.dirname(__file__),'json-expected.json'), lExpected) + # Read in the actual JSON file for comparison + lActual = [] + utils.read_file(os.path.join('deleteme.json'), lActual) + + self.assertEqual(len(lExpected), len(lActual)) + + for sActual, sExpected in zip(lActual, lExpected): + self.assertEqual(sActual, sExpected) + @mock.patch('sys.stdout') def test_backup_file(self, mock_stdout):