@@ -30,7 +30,7 @@ def __create_compile_commands(dir, entries):
30
30
return compile_commands
31
31
32
32
33
- def __test_addon_suppress_inline ( extra_args ):
33
+ def test_addon_suppress_inline ( ):
34
34
args = [
35
35
'-q' ,
36
36
'--addon=misra' ,
@@ -41,35 +41,14 @@ def __test_addon_suppress_inline(extra_args):
41
41
'whole-program/whole1.c' ,
42
42
'whole-program/whole2.c'
43
43
]
44
- args += extra_args
45
44
ret , stdout , stderr = cppcheck (args , cwd = __script_dir )
46
45
lines = stderr .splitlines ()
47
46
assert lines == []
48
47
assert stdout == ''
49
48
assert ret == 0 , stdout
50
49
51
50
52
- def test_addon_suppress_inline ():
53
- __test_addon_suppress_inline (['-j1' ])
54
-
55
-
56
- def test_addon_suppress_inline_j ():
57
- __test_addon_suppress_inline (['-j2' ])
58
-
59
-
60
- def test_addon_suppress_inline_builddir (tmpdir ):
61
- build_dir = os .path .join (tmpdir , 'b1' )
62
- os .mkdir (build_dir )
63
- __test_addon_suppress_inline (['-j1' , '--cppcheck-build-dir={}' .format (build_dir )])
64
-
65
-
66
- def test_addon_suppress_inline_builddir_j (tmpdir ):
67
- build_dir = os .path .join (tmpdir , 'b1' )
68
- os .mkdir (build_dir )
69
- __test_addon_suppress_inline (['-j2' , '--cppcheck-build-dir={}' .format (build_dir )])
70
-
71
-
72
- def __test_addon_suppress_inline_project (tmpdir , extra_args ):
51
+ def test_addon_suppress_inline_project (tmpdir ):
73
52
compile_db = __create_compile_commands (tmpdir , [
74
53
os .path .join (__script_dir , 'whole-program' , 'whole1.c' ),
75
54
os .path .join (__script_dir , 'whole-program' , 'whole2.c' )
@@ -84,35 +63,14 @@ def __test_addon_suppress_inline_project(tmpdir, extra_args):
84
63
'--error-exitcode=1' ,
85
64
'--project={}' .format (compile_db )
86
65
]
87
- args += extra_args
88
66
ret , stdout , stderr = cppcheck (args , cwd = __script_dir )
89
67
lines = stderr .splitlines ()
90
68
assert lines == []
91
69
assert stdout == ''
92
70
assert ret == 0 , stdout
93
71
94
72
95
- def test_addon_suppress_inline_project (tmpdir ):
96
- __test_addon_suppress_inline_project (tmpdir , ['-j1' ])
97
-
98
-
99
- def test_addon_suppress_inline_project_j (tmpdir ):
100
- __test_addon_suppress_inline_project (tmpdir , ['-j2' ])
101
-
102
-
103
- def test_addon_suppress_inline_project_builddir (tmpdir ):
104
- build_dir = os .path .join (tmpdir , 'b1' )
105
- os .mkdir (build_dir )
106
- __test_addon_suppress_inline_project (tmpdir , ['-j1' , '--cppcheck-build-dir={}' .format (build_dir )])
107
-
108
-
109
- def test_addon_suppress_inline_project_builddir_j (tmpdir ):
110
- build_dir = os .path .join (tmpdir , 'b1' )
111
- os .mkdir (build_dir )
112
- __test_addon_suppress_inline_project (tmpdir , ['-j2' , '--cppcheck-build-dir={}' .format (build_dir )])
113
-
114
-
115
- def __test_suppress_inline (extra_args ):
73
+ def test_suppress_inline ():
116
74
args = [
117
75
'-q' ,
118
76
'--template=simple' ,
@@ -123,36 +81,14 @@ def __test_suppress_inline(extra_args):
123
81
'whole-program/odr2.cpp'
124
82
]
125
83
126
- args += extra_args
127
-
128
84
ret , stdout , stderr = cppcheck (args , cwd = __script_dir )
129
85
lines = stderr .splitlines ()
130
86
assert lines == []
131
87
assert stdout == ''
132
88
assert ret == 0 , stdout
133
89
134
90
135
- def test_suppress_inline ():
136
- __test_suppress_inline (['-j1' ])
137
-
138
-
139
- def test_suppress_inline_j ():
140
- __test_suppress_inline (['-j2' ])
141
-
142
-
143
- def test_suppress_inline_builddir (tmpdir ):
144
- build_dir = os .path .join (tmpdir , 'b1' )
145
- os .mkdir (build_dir )
146
- __test_suppress_inline (['-j1' , '--cppcheck-build-dir={}' .format (build_dir )])
147
-
148
-
149
- def test_suppress_inline_builddir_j (tmpdir ):
150
- build_dir = os .path .join (tmpdir , 'b1' )
151
- os .mkdir (build_dir )
152
- __test_suppress_inline (['-j2' , '--cppcheck-build-dir={}' .format (build_dir )])
153
-
154
-
155
- def __test_suppress_inline_project (tmpdir , extra_args ):
91
+ def test_suppress_inline_project (tmpdir ):
156
92
compile_db = __create_compile_commands (tmpdir , [
157
93
os .path .join (__script_dir , 'whole-program' , 'odr1.cpp' ),
158
94
os .path .join (__script_dir , 'whole-program' , 'odr2.cpp' )
@@ -167,33 +103,13 @@ def __test_suppress_inline_project(tmpdir, extra_args):
167
103
'--project={}' .format (compile_db )
168
104
]
169
105
170
- args += extra_args
171
-
172
106
ret , stdout , stderr = cppcheck (args , cwd = __script_dir )
173
107
lines = stderr .splitlines ()
174
108
assert lines == []
175
109
assert stdout == ''
176
110
assert ret == 0 , stdout
177
111
178
112
179
- def test_suppress_inline_project (tmpdir ):
180
- __test_suppress_inline_project (tmpdir , ['-j1' ])
181
-
182
-
183
- def test_suppress_inline_project_j (tmpdir ):
184
- __test_suppress_inline_project (tmpdir , ['-j2' ])
185
-
186
-
187
- def test_suppress_inline_project_builddir (tmpdir ):
188
- build_dir = os .path .join (tmpdir , 'b1' )
189
- os .mkdir (build_dir )
190
- __test_suppress_inline_project (tmpdir , ['-j1' , '--cppcheck-build-dir={}' .format (build_dir )])
191
-
192
- def test_suppress_inline_project_builddir_j (tmpdir ):
193
- build_dir = os .path .join (tmpdir , 'b1' )
194
- os .mkdir (build_dir )
195
- __test_suppress_inline_project (tmpdir , ['-j2' , '--cppcheck-build-dir={}' .format (build_dir )])
196
-
197
113
@pytest .mark .parametrize ("builddir" , (False ,True ))
198
114
def test_addon_rerun (tmp_path , builddir ):
199
115
"""Rerun analysis and ensure that misra CTU works; with and without build dir"""
@@ -229,6 +145,7 @@ def test_addon_builddir_use_ctuinfo(tmp_path):
229
145
_ , _ , stderr = cppcheck (args , cwd = __script_dir )
230
146
assert 'misra-c2012-5.8' not in stderr
231
147
148
+
232
149
@pytest .mark .parametrize ("builddir" , (False ,True ))
233
150
def test_addon_no_artifacts (tmp_path , builddir ):
234
151
"""Test that there are no artifacts left after analysis"""
@@ -294,6 +211,7 @@ def test_checkclass_builddir_j(tmpdir):
294
211
os .mkdir (build_dir )
295
212
__test_checkclass (['-j2' , '--cppcheck-build-dir={}' .format (build_dir )])
296
213
214
+
297
215
def __test_checkclass_project (tmpdir , extra_args ):
298
216
odr_file_1 = os .path .join (__script_dir , 'whole-program' , 'odr1.cpp' )
299
217
@@ -341,6 +259,7 @@ def test_checkclass_project_builddir_j(tmpdir):
341
259
os .mkdir (build_dir )
342
260
__test_checkclass_project (tmpdir , ['-j2' , '--cppcheck-build-dir={}' .format (build_dir )])
343
261
262
+
344
263
def __test_nullpointer_file0 (extra_args ):
345
264
args = [
346
265
'-q' ,
@@ -361,13 +280,16 @@ def __test_nullpointer_file0(extra_args):
361
280
assert stdout == ''
362
281
assert file0 == 'whole-program/nullpointer1.cpp' , stderr
363
282
283
+
364
284
def test_nullpointer_file0 ():
365
285
__test_nullpointer_file0 (['-j1' ])
366
286
287
+
367
288
@pytest .mark .xfail (strict = True ) # no CTU without builddir
368
289
def test_nullpointer_file0_j ():
369
290
__test_nullpointer_file0 (['-j2' , '--no-cppcheck-build-dir' ])
370
291
292
+
371
293
def test_nullpointer_file0_builddir_j (tmpdir ):
372
294
build_dir = os .path .join (tmpdir , 'b1' )
373
295
os .mkdir (build_dir )
0 commit comments