Skip to content

Commit 01d932f

Browse files
committed
adjusted some Python test results
1 parent a81599e commit 01d932f

File tree

2 files changed

+62
-18
lines changed

2 files changed

+62
-18
lines changed

test/cli/inline-suppress_test.py

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,6 @@ def test_build_dir_unused_template(tmpdir):
262262
__test_build_dir_unused_template(tmpdir, False)
263263

264264

265-
@pytest.mark.xfail(strict=True)
266265
def test_build_dir_unused_template_j(tmpdir):
267266
__test_build_dir_unused_template(tmpdir, True)
268267

@@ -284,7 +283,7 @@ def test_suppress_unmatched_inline_suppression(): # 11172
284283
assert ret == 0, stdout
285284

286285

287-
# no error as inline suppressions are currently not being propagated back
286+
# TODO: should this error out?
288287
def test_duplicate(tmpdir):
289288
args = [
290289
'-q',
@@ -302,8 +301,8 @@ def test_duplicate(tmpdir):
302301
assert ret == 0, stdout
303302

304303

305-
# no error as inline suppressions are currently not being propagated back
306-
def test_duplicate_cmd(tmpdir):
304+
# no error as inline suppressions ars handled separately
305+
def __test_duplicate_cmd(tmpdir, extra_args):
307306
args = [
308307
'-q',
309308
'--template=simple',
@@ -314,15 +313,29 @@ def test_duplicate_cmd(tmpdir):
314313
'proj-inline-suppress/4.c'
315314
]
316315

316+
args = args + extra_args
317+
317318
ret, stdout, stderr = cppcheck(args, cwd=__script_dir)
318319
lines = stderr.splitlines()
319-
assert lines == []
320+
# this is the suppression provided via the command-line which is unused because only the inline suppression is being matched
321+
assert lines == [
322+
'nofile:0:0: information: Unmatched suppression: unreadVariable [unmatchedSuppression]'
323+
]
320324
assert stdout == ''
321325
assert ret == 0, stdout
322326

323327

324-
# no error as inline suppressions are currently not being propagated back
325-
def test_duplicate_file(tmpdir):
328+
@pytest.mark.xfail(strict=True)
329+
def test_duplicate_cmd(tmpdir):
330+
__test_duplicate_cmd(tmpdir, ['-j1'])
331+
332+
333+
def test_duplicate_cmd_j(tmpdir):
334+
__test_duplicate_cmd(tmpdir, ['-j2'])
335+
336+
337+
# no error as inline suppressions ars handled separately
338+
def __test_duplicate_file(tmpdir, extra_args):
326339
suppr_file = os.path.join(tmpdir, 'suppressions')
327340
with open(suppr_file, 'wt') as f:
328341
f.write('''unreadVariable''')
@@ -337,13 +350,27 @@ def test_duplicate_file(tmpdir):
337350
'proj-inline-suppress/4.c'
338351
]
339352

353+
args = args + extra_args
354+
340355
ret, stdout, stderr = cppcheck(args, cwd=__script_dir)
341356
lines = stderr.splitlines()
342-
assert lines == []
357+
# this is the suppression provided via the suppression file which is unused because only the inline suppression is being matched
358+
assert lines == [
359+
'nofile:0:0: information: Unmatched suppression: unreadVariable [unmatchedSuppression]'
360+
]
343361
assert stdout == ''
344362
assert ret == 0, stdout
345363

346364

365+
@pytest.mark.xfail(strict=True)
366+
def test_duplicate_file(tmpdir):
367+
__test_duplicate_file(tmpdir, ['-j1'])
368+
369+
370+
def test_duplicate_file_j(tmpdir):
371+
__test_duplicate_file(tmpdir, ['-j2'])
372+
373+
347374
# reporting of inline unusedFunction is deferred
348375
def __test_unused_function_unmatched(tmpdir, use_j):
349376
args = [

test/cli/unused_function_test.py

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
import os
55
import json
6+
import sys
7+
import pytest
68
from testutils import cppcheck
79

810
__script_dir = os.path.dirname(os.path.abspath(__file__))
@@ -111,7 +113,12 @@ def test_unused_functions_compdb_j(tmpdir):
111113
def test_unused_functions_builddir(tmpdir):
112114
build_dir = os.path.join(tmpdir, 'b1')
113115
os.mkdir(build_dir)
114-
ret, stdout, stderr = cppcheck(['-q', '--template=simple', '--enable=unusedFunction', '--inline-suppr', '-j1', '--cppcheck-build-dir={}'.format(build_dir), __project_dir])
116+
ret, stdout, stderr = cppcheck(['-q',
117+
'--template=simple',
118+
'--enable=unusedFunction',
119+
'--inline-suppr',
120+
'--cppcheck-build-dir={}'.format(build_dir),
121+
__project_dir])
115122
assert stdout.splitlines() == []
116123
assert stderr.splitlines() == [
117124
"{}3.c:3:0: style: The function 'f3_3' is never used. [unusedFunction]".format(__project_dir_sep)
@@ -120,10 +127,18 @@ def test_unused_functions_builddir(tmpdir):
120127

121128

122129
# TODO: only f3_3 is unused
123-
def test_unused_functions_builddir_j(tmpdir):
130+
@pytest.mark.skipif(sys.platform == 'win32', reason='ProcessExecutor not available on Windows')
131+
def test_unused_functions_builddir_j_process(tmpdir):
124132
build_dir = os.path.join(tmpdir, 'b1')
125133
os.mkdir(build_dir)
126-
ret, stdout, stderr = cppcheck(['-q', '--template=simple', '--enable=unusedFunction', '--inline-suppr', '-j2', '--cppcheck-build-dir={}'.format(build_dir), __project_dir])
134+
ret, stdout, stderr = cppcheck(['-q',
135+
'--template=simple',
136+
'--enable=unusedFunction',
137+
'--inline-suppr',
138+
'-j2',
139+
'--executor=process',
140+
'--cppcheck-build-dir={}'.format(build_dir),
141+
__project_dir])
127142
assert stdout.splitlines() == []
128143
assert stderr.splitlines() == [
129144
"{}1.c:4:0: style: The function 'f1' is never used. [unusedFunction]".format(__project_dir_sep),
@@ -142,8 +157,7 @@ def test_unused_functions_builddir_project(tmpdir):
142157
'--enable=unusedFunction',
143158
'--inline-suppr',
144159
'--project={}'.format(os.path.join(__project_dir, 'unusedFunction.cppcheck')),
145-
'--cppcheck-build-dir={}'.format(build_dir),
146-
'-j1'])
160+
'--cppcheck-build-dir={}'.format(build_dir)])
147161
assert stdout.splitlines() == []
148162
assert stderr.splitlines() == [
149163
"{}3.c:3:0: style: The function 'f3_3' is never used. [unusedFunction]".format(__project_dir_sep)
@@ -152,7 +166,8 @@ def test_unused_functions_builddir_project(tmpdir):
152166

153167

154168
# TODO: only f3_3 is unused
155-
def test_unused_functions_builddir_project_j(tmpdir):
169+
@pytest.mark.skipif(sys.platform == 'win32', reason='ProcessExecutor not available on Windows')
170+
def test_unused_functions_builddir_project_j_process(tmpdir):
156171
build_dir = os.path.join(tmpdir, 'b1')
157172
os.mkdir(build_dir)
158173
ret, stdout, stderr = cppcheck(['-q',
@@ -161,7 +176,8 @@ def test_unused_functions_builddir_project_j(tmpdir):
161176
'--inline-suppr',
162177
'--project={}'.format(os.path.join(__project_dir, 'unusedFunction.cppcheck')),
163178
'--cppcheck-build-dir={}'.format(build_dir),
164-
'-j2'])
179+
'-j2',
180+
'--executor=process'])
165181
assert stdout.splitlines() == []
166182
assert stderr.splitlines() == [
167183
"{}1.c:4:0: style: The function 'f1' is never used. [unusedFunction]".format(__project_dir_sep),
@@ -182,7 +198,6 @@ def test_unused_functions_builddir_compdb(tmpdir):
182198
'--inline-suppr',
183199
'--project={}'.format(compdb_file),
184200
'--cppcheck-build-dir={}'.format(build_dir),
185-
'-j1'
186201
])
187202
assert stdout.splitlines() == []
188203
assert stderr.splitlines() == [
@@ -192,7 +207,8 @@ def test_unused_functions_builddir_compdb(tmpdir):
192207

193208

194209
# TODO: only f3_3 is unused
195-
def test_unused_functions_builddir_compdb_j(tmpdir):
210+
@pytest.mark.skipif(sys.platform == 'win32', reason='ProcessExecutor not available on Windows')
211+
def test_unused_functions_builddir_compdb_j_process(tmpdir):
196212
compdb_file = __create_compdb(tmpdir, __project_dir)
197213
build_dir = os.path.join(tmpdir, 'b1')
198214
os.mkdir(build_dir)
@@ -202,7 +218,8 @@ def test_unused_functions_builddir_compdb_j(tmpdir):
202218
'--inline-suppr',
203219
'--project={}'.format(compdb_file),
204220
'--cppcheck-build-dir={}'.format(build_dir),
205-
'-j2'
221+
'-j2',
222+
'--executor=process'
206223
])
207224
assert stdout.splitlines() == []
208225
assert stderr.splitlines() == [

0 commit comments

Comments
 (0)