From e924e290910fafeaf1ed0539edbe2d3c87f23ac4 Mon Sep 17 00:00:00 2001 From: Jeremiah Leary Date: Sat, 16 Oct 2021 20:35:44 -0500 Subject: [PATCH 1/2] Updates for issue #636 Adding severity to output of --json argument. 1) Added test to expose the issue 2) Updated code to output severity --- vsg/rule_list.py | 1 + vsg/tests/vsg/json-expected.json | 34 ++++++++++++++++++++++++++++++++ vsg/tests/vsg/test_main.py | 12 +++++++++++ 3 files changed, 47 insertions(+) create mode 100644 vsg/tests/vsg/json-expected.json 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..ea860d0a 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 JUnit XML file for comparison + lExpected = [] + utils.read_file(os.path.join(os.path.dirname(__file__),'json-expected.json'), lExpected) + # Read in the actual JUnit XML 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): From 385a8c84baeb20c14b5c2dc986eec87bd715af2d Mon Sep 17 00:00:00 2001 From: Jeremiah Leary Date: Tue, 19 Oct 2021 05:55:54 -0500 Subject: [PATCH 2/2] Updates for issue #636 Fixing comments in test. --- vsg/tests/vsg/test_main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vsg/tests/vsg/test_main.py b/vsg/tests/vsg/test_main.py index ea860d0a..101e9e80 100644 --- a/vsg/tests/vsg/test_main.py +++ b/vsg/tests/vsg/test_main.py @@ -397,10 +397,10 @@ class testMain(unittest.TestCase): self.assertTrue(os.path.isfile('deleteme.json')) - # Read in the expected JUnit XML file for comparison + # 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 JUnit XML file for comparison + # Read in the actual JSON file for comparison lActual = [] utils.read_file(os.path.join('deleteme.json'), lActual)