@@ -4657,4 +4657,95 @@ def test_ipc(tmp_path):
46574657 'writeToPipe - 5 - 0' ,
46584658 'handleRead - 5 - 0'
46594659 ]
4660+ assert stderr .splitlines () == []
4661+
4662+
4663+ @pytest .mark .skipif (sys .platform == 'win32' , reason = "requires ProcessExecutor" )
4664+ def test_ipc_suppressions (tmp_path ):
4665+ test1_file = tmp_path / 'test1.c'
4666+ with open (test1_file , "w" ) as f :
4667+ f .write ('void f() {}' )
4668+
4669+ test2_file = tmp_path / 'test2.c'
4670+ with open (test2_file , "w" ) as f :
4671+ f .write ('void f() {}' )
4672+
4673+ test3_file = tmp_path / 'test3.c'
4674+ with open (test3_file , "w" ) as f :
4675+ f .write ('void f() {}' )
4676+
4677+ args = [
4678+ '-q' ,
4679+ '--debug-ipc' ,
4680+ '-j2' ,
4681+ '--executor=process' ,
4682+ '--inline-suppr' ,
4683+ '--suppress=id0:test1.c' ,
4684+ str (tmp_path )
4685+ ]
4686+
4687+ exitcode , stdout , stderr = cppcheck (args )
4688+ assert exitcode == 0
4689+ # sort the lines since the order is not fixed
4690+ stdout_exp = [
4691+ 'writeToPipe - 4 - id0:test1.c;0;1;0;' ,
4692+ 'handleRead - 4 - id0:test1.c;0;1;0;' ,
4693+ 'writeToPipe - 5 - 0' ,
4694+ 'handleRead - 5 - 0' ,
4695+ 'writeToPipe - 5 - 0' ,
4696+ 'handleRead - 5 - 0' ,
4697+ 'writeToPipe - 5 - 0' ,
4698+ 'handleRead - 5 - 0'
4699+ ]
4700+ stdout_exp .sort ()
4701+ stdout_lines = stdout .splitlines ()
4702+ stdout_lines .sort ()
4703+ assert stdout_lines == stdout_exp
4704+ assert stderr .splitlines () == []
4705+
4706+
4707+ @pytest .mark .skipif (sys .platform == 'win32' , reason = "requires ProcessExecutor" )
4708+ def test_ipc_inline_suppressions (tmp_path ):
4709+ test1_file = tmp_path / 'test1.c'
4710+ with open (test1_file , "w" ) as f :
4711+ f .write ('void f() {} // cppcheck-suppress id1' )
4712+
4713+ test2_file = tmp_path / 'test2.c'
4714+ with open (test2_file , "w" ) as f :
4715+ f .write ('void f() {} // cppcheck-suppress id2' )
4716+
4717+ test3_file = tmp_path / 'test3.c'
4718+ with open (test3_file , "w" ) as f :
4719+ f .write ('void f() {} // cppcheck-suppress id3' )
4720+
4721+ args = [
4722+ '-q' ,
4723+ '--debug-ipc' ,
4724+ '-j2' ,
4725+ '--executor=process' ,
4726+ '--inline-suppr' ,
4727+ str (tmp_path )
4728+ ]
4729+
4730+ exitcode , stdout , stderr = cppcheck (args )
4731+ assert exitcode == 0
4732+ # sort the lines since the order is not fixed
4733+ stdout_exp = [
4734+ f'writeToPipe - 3 - id1:{ test1_file } :1;13;1;0;' ,
4735+ f'handleRead - 3 - id1:{ test1_file } :1;13;1;0;' ,
4736+ 'writeToPipe - 5 - 0' ,
4737+ 'handleRead - 5 - 0' ,
4738+ f'writeToPipe - 3 - id2:{ test2_file } :1;13;1;0;' ,
4739+ f'handleRead - 3 - id2:{ test2_file } :1;13;1;0;' ,
4740+ 'writeToPipe - 5 - 0' ,
4741+ 'handleRead - 5 - 0' ,
4742+ f'writeToPipe - 3 - id3:{ test3_file } :1;13;1;0;' ,
4743+ f'handleRead - 3 - id3:{ test3_file } :1;13;1;0;' ,
4744+ 'writeToPipe - 5 - 0' ,
4745+ 'handleRead - 5 - 0'
4746+ ]
4747+ stdout_exp .sort ()
4748+ stdout_lines = stdout .splitlines ()
4749+ stdout_lines .sort ()
4750+ assert stdout_lines == stdout_exp
46604751 assert stderr .splitlines () == []
0 commit comments