Skip to content

Commit 8e6b111

Browse files
committed
add cli test
1 parent ecba564 commit 8e6b111

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

test/cli/project-suppressions.py

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

0 commit comments

Comments
 (0)