|
| 1 | + |
| 2 | +# python -m pytest project-suppressions.py |
| 3 | + |
| 4 | +from testutils import create_gui_project_file, assert_cppcheck |
| 5 | + |
| 6 | +def test_cli_and_project_suppressions(tmp_path): |
| 7 | + # Uninitvar suppressed in project file |
| 8 | + suppressions = [{ 'id': 'uninitvar' }] |
| 9 | + project_path = tmp_path / 'project.cppcheck' |
| 10 | + create_gui_project_file(project_path, root_path=str(tmp_path), suppressions=suppressions) |
| 11 | + |
| 12 | + # Uninitvar suppressed on command line before import |
| 13 | + args = ['--suppress=uninitvar', f'--project={project_path}'] |
| 14 | + out_exp = [ |
| 15 | + "cppcheck: error: suppression 'uninitvar' already exists", |
| 16 | + f"cppcheck: error: failed to load project '{project_path}'. An error occurred." |
| 17 | + ] |
| 18 | + assert_cppcheck(args, ec_exp=1, out_exp=out_exp) |
| 19 | + |
| 20 | +def test_multiple_cli_and_project_suppressions(tmp_path): |
| 21 | + # Uninitvar and unreadVariable suppressed in project file |
| 22 | + suppressions = [{ 'id': 'uninitvar' }, { 'id': 'unreadVariable' },] |
| 23 | + project_path = tmp_path / 'project.cppcheck' |
| 24 | + create_gui_project_file(project_path, root_path=str(tmp_path), suppressions=suppressions) |
| 25 | + |
| 26 | + # Uninitvar and unreadVariable suppressed on command line before import |
| 27 | + args = ['--suppress=uninitvar', '--suppress=unreadVariable', f'--project={project_path}'] |
| 28 | + out_exp = [ |
| 29 | + "cppcheck: error: suppression 'uninitvar' already exists", |
| 30 | + "cppcheck: error: suppression 'unreadVariable' already exists", |
| 31 | + f"cppcheck: error: failed to load project '{project_path}'. An error occurred." |
| 32 | + ] |
| 33 | + assert_cppcheck(args, ec_exp=1, out_exp=out_exp) |
0 commit comments