@@ -4657,4 +4657,94 @@ 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+ '--suppress=id0:test1.c' ,
4683+ str (tmp_path )
4684+ ]
4685+
4686+ exitcode , stdout , stderr = cppcheck (args )
4687+ assert exitcode == 0
4688+ # sort the lines since the order is not fixed
4689+ stdout_exp = [
4690+ 'writeToPipe - 4 - id0:test1.c;0;1;0;' ,
4691+ 'handleRead - 4 - id0:test1.c;0;1;0;' ,
4692+ 'writeToPipe - 5 - 0' ,
4693+ 'handleRead - 5 - 0' ,
4694+ 'writeToPipe - 5 - 0' ,
4695+ 'handleRead - 5 - 0' ,
4696+ 'writeToPipe - 5 - 0' ,
4697+ 'handleRead - 5 - 0'
4698+ ]
4699+ stdout_exp .sort ()
4700+ stdout_lines = stdout .splitlines ()
4701+ stdout_lines .sort ()
4702+ assert stdout_lines == stdout_exp
4703+ assert stderr .splitlines () == []
4704+
4705+
4706+ @pytest .mark .skipif (sys .platform == 'win32' , reason = "requires ProcessExecutor" )
4707+ def test_ipc_inline_suppressions (tmp_path ):
4708+ test1_file = tmp_path / 'test1.c'
4709+ with open (test1_file , "w" ) as f :
4710+ f .write ('void f() {} // cppcheck-suppress id1' )
4711+
4712+ test2_file = tmp_path / 'test2.c'
4713+ with open (test2_file , "w" ) as f :
4714+ f .write ('void f() {} // cppcheck-suppress id2' )
4715+
4716+ test3_file = tmp_path / 'test3.c'
4717+ with open (test3_file , "w" ) as f :
4718+ f .write ('void f() {} // cppcheck-suppress id3' )
4719+
4720+ args = [
4721+ '-q' ,
4722+ '--debug-ipc' ,
4723+ '-j2' ,
4724+ '--executor=process' ,
4725+ '--inline-suppr' ,
4726+ str (tmp_path )
4727+ ]
4728+
4729+ exitcode , stdout , stderr = cppcheck (args )
4730+ assert exitcode == 0
4731+ # sort the lines since the order is not fixed
4732+ stdout_exp = [
4733+ f'writeToPipe - 3 - id1:{ test1_file } :1;13;1;0;' ,
4734+ f'handleRead - 3 - id1:{ test1_file } :1;13;1;0;' ,
4735+ 'writeToPipe - 5 - 0' ,
4736+ 'handleRead - 5 - 0' ,
4737+ f'writeToPipe - 3 - id2:{ test2_file } :1;13;1;0;' ,
4738+ f'handleRead - 3 - id2:{ test2_file } :1;13;1;0;' ,
4739+ 'writeToPipe - 5 - 0' ,
4740+ 'handleRead - 5 - 0' ,
4741+ f'writeToPipe - 3 - id3:{ test3_file } :1;13;1;0;' ,
4742+ f'handleRead - 3 - id3:{ test3_file } :1;13;1;0;' ,
4743+ 'writeToPipe - 5 - 0' ,
4744+ 'handleRead - 5 - 0'
4745+ ]
4746+ stdout_exp .sort ()
4747+ stdout_lines = stdout .splitlines ()
4748+ stdout_lines .sort ()
4749+ assert stdout_lines == stdout_exp
46604750 assert stderr .splitlines () == []
0 commit comments