33
44import os
55import json
6+ import sys
7+ import pytest
68from 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):
111113def 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