Skip to content

Commit 3cbd136

Browse files
committed
added environment variable TEST_CPPCHECK_INJECT_J to inject -j into the cppcheck invocation of Python tests
1 parent bb6fe1f commit 3cbd136

13 files changed

+82
-159
lines changed

.github/workflows/CI-unixish.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ jobs:
6767
run: |
6868
cd test/cli
6969
python3 -m pytest -Werror --strict-markers -vv
70+
TEST_CPPCHECK_INJECT_J="2" python3 -m pytest -Werror --strict-markers -vv
7071
cd ../../..
7172
ln -s cppcheck 'cpp check'
7273
cd 'cpp check/test/cli'

.github/workflows/CI-windows.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,6 @@ jobs:
116116
copy .\bin\cppcheck-core.dll .\cppcheck-core.dll || exit /b !errorlevel!
117117
cd test/cli || exit /b !errorlevel!
118118
python -m pytest -Werror --strict-markers -vv || exit /b !errorlevel!
119+
set TEST_CPPCHECK_INJECT_J=2
120+
python -m pytest -Werror --strict-markers -vv || exit /b !errorlevel!
121+
set TEST_CPPCHECK_INJECT_J=

.github/workflows/asan.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ jobs:
8282
pwd=$(pwd)
8383
cd test/cli
8484
TEST_CPPCHECK_EXE_LOOKUP_PATH="$pwd/cmake.output" python3 -m pytest -Werror --strict-markers -vv
85+
TEST_CPPCHECK_EXE_LOOKUP_PATH="$pwd/cmake.output" TEST_CPPCHECK_INJECT_J="2" python3 -m pytest -Werror --strict-markers -vv
8586
8687
- name: Generate dependencies
8788
if: false

.github/workflows/tsan.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,4 @@ jobs:
8585
pwd=$(pwd)
8686
cd test/cli
8787
TEST_CPPCHECK_EXE_LOOKUP_PATH="$pwd/cmake.output" python3 -m pytest -Werror --strict-markers -vv
88+
TEST_CPPCHECK_EXE_LOOKUP_PATH="$pwd/cmake.output" TEST_CPPCHECK_INJECT_J="2" python3 -m pytest -Werror --strict-markers -vv

.github/workflows/ubsan.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,4 @@ jobs:
8585
pwd=$(pwd)
8686
cd test/cli
8787
TEST_CPPCHECK_EXE_LOOKUP_PATH="$pwd/cmake.output" python3 -m pytest -Werror --strict-markers -vv
88+
TEST_CPPCHECK_EXE_LOOKUP_PATH="$pwd/cmake.output" TEST_CPPCHECK_INJECT_J="2" python3 -m pytest -Werror --strict-markers -vv

test/cli/helloworld_test.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -223,16 +223,8 @@ def test_checkers_report():
223223
assert 'Yes CheckAutoVariables::assignFunctionArg' in data
224224

225225

226-
def __test_missing_include_system(use_j):
226+
def test_missing_include_system(): # #11283
227227
args = ['--enable=missingInclude', '--suppress=zerodiv', '--template=simple', 'helloworld']
228-
if use_j:
229-
args.insert(0, '-j2')
230228

231229
_, _, stderr = cppcheck(args)
232230
assert stderr.replace('\\', '/') == 'helloworld/main.c:1:0: information: Include file: <stdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results. [missingIncludeSystem]\n'
233-
234-
def test_missing_include_system():
235-
__test_missing_include_system(False)
236-
237-
def test_missing_include_system_j(): #11283
238-
__test_missing_include_system(True)

test/cli/inline-suppress_test.py

Lines changed: 15 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -26,37 +26,25 @@ def __create_unused_function_compile_commands(tmpdir):
2626
return compile_commands
2727

2828

29-
def __test1(use_j):
29+
def test1():
3030
args = [
3131
'-q',
3232
'--template=simple',
3333
'--inline-suppr',
3434
'proj-inline-suppress'
3535
]
36-
if use_j:
37-
args.append('-j2')
3836
ret, stdout, stderr = cppcheck(args, cwd=__script_dir)
3937
assert stderr == ''
4038
assert stdout == ''
4139
assert ret == 0, stdout
4240

4341

44-
def test1():
45-
__test1(False)
46-
47-
48-
def test1_j():
49-
__test1(True)
50-
51-
52-
def __test2(use_j):
42+
def test2():
5343
args = [
5444
'-q',
5545
'--template=simple',
5646
'proj-inline-suppress'
5747
]
58-
if use_j:
59-
args.append('-j2')
6048
ret, stdout, stderr = cppcheck(args, cwd=__script_dir)
6149
lines = stderr.splitlines()
6250
assert lines == [
@@ -66,15 +54,7 @@ def __test2(use_j):
6654
assert ret == 0, stdout
6755

6856

69-
def test2():
70-
__test2(False)
71-
72-
73-
def test2_j():
74-
__test2(True)
75-
76-
77-
def __test_unmatched_suppression(use_j):
57+
def test_unmatched_suppression():
7858
args = [
7959
'-q',
8060
'--template=simple',
@@ -84,8 +64,6 @@ def __test_unmatched_suppression(use_j):
8464
'--error-exitcode=1',
8565
'{}2.c'.format(__proj_inline_suppres_path)
8666
]
87-
if use_j:
88-
args.append('-j2')
8967
ret, stdout, stderr = cppcheck(args, cwd=__script_dir)
9068
lines = stderr.splitlines()
9169
assert lines == [
@@ -95,15 +73,7 @@ def __test_unmatched_suppression(use_j):
9573
assert ret == 1, stdout
9674

9775

98-
def test_unmatched_suppression():
99-
__test_unmatched_suppression(False)
100-
101-
102-
def test_unmatched_suppression_j():
103-
__test_unmatched_suppression(True)
104-
105-
106-
def __test_unmatched_suppression_path_with_extra_stuff(use_j):
76+
def test_unmatched_suppression_path_with_extra_stuff():
10777
args = [
10878
'-q',
10979
'--template=simple',
@@ -113,8 +83,6 @@ def __test_unmatched_suppression_path_with_extra_stuff(use_j):
11383
'--error-exitcode=1',
11484
'{}2.c'.format(__proj_inline_suppres_path)
11585
]
116-
if use_j:
117-
args.append('-j2')
11886
ret, stdout, stderr = cppcheck(args, cwd=__script_dir)
11987
lines = stderr.splitlines()
12088
assert lines == [
@@ -124,22 +92,12 @@ def __test_unmatched_suppression_path_with_extra_stuff(use_j):
12492
assert ret == 1, stdout
12593

12694

127-
def test_unmatched_suppression_path_with_extra_stuff():
128-
__test_unmatched_suppression_path_with_extra_stuff(False)
129-
130-
131-
def test_unmatched_suppression_path_with_extra_stuff_j():
132-
__test_unmatched_suppression_path_with_extra_stuff(True)
133-
134-
135-
def __test_backwards_compatibility(use_j):
95+
def test_backwards_compatibility():
13696
args = [
13797
'-q',
13898
'--template=simple',
13999
'{}3.cpp'.format(__proj_inline_suppres_path)
140100
]
141-
if use_j:
142-
args.append('-j2')
143101
ret, stdout, stderr = cppcheck(args, cwd=__script_dir)
144102
lines = stderr.splitlines()
145103
assert lines == [
@@ -154,23 +112,13 @@ def __test_backwards_compatibility(use_j):
154112
'--inline-suppr',
155113
'{}3.cpp'.format(__proj_inline_suppres_path)
156114
]
157-
if use_j:
158-
args.append('-j2')
159115
ret, stdout, stderr = cppcheck(args, cwd=__script_dir)
160116
lines = stderr.splitlines()
161117
assert lines == []
162118
assert stdout == ''
163119
assert ret == 0, stdout
164120

165121

166-
def test_backwards_compatibility():
167-
__test_backwards_compatibility(False)
168-
169-
170-
def test_backwards_compatibility_j():
171-
__test_backwards_compatibility(True)
172-
173-
174122
def __test_compile_commands_unused_function(tmpdir, use_j):
175123
compdb_file = __create_unused_function_compile_commands(tmpdir)
176124
args = [
@@ -182,6 +130,8 @@ def __test_compile_commands_unused_function(tmpdir, use_j):
182130
]
183131
if use_j:
184132
args.append('-j2')
133+
else:
134+
args.append('-j1')
185135
ret, stdout, stderr = cppcheck(args)
186136
proj_path_sep = os.path.join(__script_dir, 'proj-inline-suppress-unusedFunction') + os.path.sep
187137
lines = stderr.splitlines()
@@ -213,6 +163,8 @@ def __test_compile_commands_unused_function_suppression(tmpdir, use_j):
213163
]
214164
if use_j:
215165
args.append('-j2')
166+
else:
167+
args.append('-j1')
216168
ret, stdout, stderr = cppcheck(args)
217169
lines = stderr.splitlines()
218170
assert lines == []
@@ -229,7 +181,7 @@ def test_compile_commands_unused_function_suppression_j(tmpdir):
229181
__test_compile_commands_unused_function_suppression(tmpdir, True)
230182

231183

232-
def __test_unmatched_suppression_ifdef(use_j):
184+
def test_unmatched_suppression_ifdef():
233185
args = [
234186
'-q',
235187
'--template=simple',
@@ -239,24 +191,14 @@ def __test_unmatched_suppression_ifdef(use_j):
239191
'-DNO_ZERO_DIV',
240192
'trac5704/trac5704a.c'
241193
]
242-
if use_j:
243-
args.append('-j2')
244194
ret, stdout, stderr = cppcheck(args, cwd=__script_dir)
245195
lines = stderr.splitlines()
246196
assert lines == []
247197
assert stdout == ''
248198
assert ret == 0, stdout
249199

250200

251-
def test_unmatched_suppression_ifdef():
252-
__test_unmatched_suppression_ifdef(False)
253-
254-
255-
def test_unmatched_suppression_ifdef_j():
256-
__test_unmatched_suppression_ifdef(True)
257-
258-
259-
def __test_unmatched_suppression_ifdef_0(use_j):
201+
def test_unmatched_suppression_ifdef_0():
260202
args = [
261203
'-q',
262204
'--template=simple',
@@ -265,24 +207,14 @@ def __test_unmatched_suppression_ifdef_0(use_j):
265207
'--inline-suppr',
266208
'trac5704/trac5704b.c'
267209
]
268-
if use_j:
269-
args.append('-j2')
270210
ret, stdout, stderr = cppcheck(args, cwd=__script_dir)
271211
lines = stderr.splitlines()
272212
assert lines == []
273213
assert stdout == ''
274214
assert ret == 0, stdout
275215

276216

277-
def test_unmatched_suppression_ifdef_0():
278-
__test_unmatched_suppression_ifdef_0(False)
279-
280-
281-
def test_unmatched_suppression_ifdef_0_j():
282-
__test_unmatched_suppression_ifdef_0(True)
283-
284-
285-
def __test_build_dir(tmpdir, use_j):
217+
def test_build_dir(tmpdir):
286218
args = [
287219
'-q',
288220
'--template=simple',
@@ -291,8 +223,6 @@ def __test_build_dir(tmpdir, use_j):
291223
'--inline-suppr',
292224
'{}4.c'.format(__proj_inline_suppres_path)
293225
]
294-
if use_j:
295-
args.append('-j2')
296226

297227
ret, stdout, stderr = cppcheck(args, cwd=__script_dir)
298228
lines = stderr.splitlines()
@@ -307,14 +237,6 @@ def __test_build_dir(tmpdir, use_j):
307237
assert ret == 0, stdout
308238

309239

310-
def test_build_dir(tmpdir):
311-
__test_build_dir(tmpdir, False)
312-
313-
314-
def test_build_dir_j(tmpdir):
315-
__test_build_dir(tmpdir, True)
316-
317-
318240
def __test_build_dir_unused_template(tmpdir, use_j):
319241
args = [
320242
'-q',
@@ -326,6 +248,8 @@ def __test_build_dir_unused_template(tmpdir, use_j):
326248
]
327249
if use_j:
328250
args.append('-j2')
251+
else:
252+
args.append('-j1')
329253

330254
ret, stdout, stderr = cppcheck(args, cwd=__script_dir)
331255
lines = stderr.splitlines()
@@ -343,7 +267,7 @@ def test_build_dir_unused_template_j(tmpdir):
343267
__test_build_dir_unused_template(tmpdir, True)
344268

345269

346-
def __test_suppress_unmatched_inline_suppression(use_j): # 11172
270+
def test_suppress_unmatched_inline_suppression(): # 11172
347271
args = [
348272
'-q',
349273
'--template=simple',
@@ -353,18 +277,8 @@ def __test_suppress_unmatched_inline_suppression(use_j): # 11172
353277
'--inline-suppr',
354278
'{}2.c'.format(__proj_inline_suppres_path)
355279
]
356-
if use_j:
357-
args.append('-j2')
358280
ret, stdout, stderr = cppcheck(args, cwd=__script_dir)
359281
lines = stderr.splitlines()
360282
assert lines == []
361283
assert stdout == ''
362284
assert ret == 0, stdout
363-
364-
365-
def test_suppress_unmatched_inline_suppression():
366-
__test_suppress_unmatched_inline_suppression(False)
367-
368-
369-
def test_suppress_unmatched_inline_suppression_j():
370-
__test_suppress_unmatched_inline_suppression(True)

test/cli/more-projects_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ def test_project_file_order(tmpdir):
420420
</paths>
421421
</project>""".format(test_file_c, test_file_d, test_file_b, test_file_a))
422422

423-
args = ['--project={}'.format(project_file)]
423+
args = ['--project={}'.format(project_file), '-j1']
424424

425425
exitcode, stdout, stderr = cppcheck(args)
426426
assert exitcode == 0
@@ -494,7 +494,7 @@ def test_project_file_duplicate_2(tmpdir):
494494
</paths>
495495
</project>""".format(test_file_c, test_file_a, test_file_b, tmpdir, test_file_b, test_file_c, test_file_a, tmpdir))
496496

497-
args = ['--project={}'.format(project_file)]
497+
args = ['--project={}'.format(project_file), '-j1']
498498

499499
exitcode, stdout, stderr = cppcheck(args)
500500
assert exitcode == 0

0 commit comments

Comments
 (0)