Skip to content

Commit

Permalink
Add test to catch error of using Polyspace checker together with othe…
Browse files Browse the repository at this point in the history
…r checkers
  • Loading branch information
JokeWaumans committed Nov 25, 2024
1 parent feb643e commit 575d372
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 1 deletion.
43 changes: 43 additions & 0 deletions tests/test_in/config_example_polyspace_error.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
sphinx:
enabled: true
min: 0
max: 0
exclude:
- RemovedInSphinx\d+Warning
- 'WARNING: toctree'
doxygen:
enabled: false
junit:
enabled: false
xmlrunner:
enabled: false
coverity:
enabled: false
robot:
enabled: false
polyspace:
enabled: true
run-time check:
- color: red
min: 0
max: 0
- color: orange
min: 0
max: 10
global variable:
- color: red
min: 0
max: 0
- color: orange
min: 0
max: 10
defect:
- information: 'impact: high'
min: 0
max: 0
- information: 'impact: medium'
min: 0
max: 10
- information: 'impact: low'
min: 0
max: 30
15 changes: 14 additions & 1 deletion tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from unittest.mock import patch

from mlx.warnings import warnings_wrapper, WarningsConfigError, Finding
from mlx.warnings import exceptions, warnings_wrapper, WarningsConfigError, Finding

TEST_IN_DIR = Path(__file__).parent / 'test_in'
TEST_OUT_DIR = Path(__file__).parent / 'test_out'
Expand Down Expand Up @@ -380,3 +380,16 @@ def test_cq_description_format(self, path_cwd_mock):
self.assertIn("WARNING: Unrecognized classification 'min'", output)
self.assertEqual(2, retval)
self.assertTrue(filecmp.cmp(out_file, ref_file), '{} differs from {}'.format(out_file, ref_file))

@patch('pathlib.Path.cwd')
def test_polyspace_error(self, path_cwd_mock):
config_file = str(TEST_IN_DIR / 'config_example_polyspace_error.yml')
cq_file = str(TEST_IN_DIR / 'test.json')
with self.assertRaises(exceptions.WarningsConfigError) as context:
warnings_wrapper([
'--code-quality', cq_file,
'--config', config_file,
'tests/test_in/mixed_warnings.txt',
])
self.assertEqual(str(context.exception), 'Polyspace checker cannot be combined with other warnings checkers')

0 comments on commit 575d372

Please sign in to comment.