@@ -954,8 +954,11 @@ def test_unused_function_include(tmpdir):
954954 __test_unused_function_include (tmpdir , [])
955955
956956
957+ # TODO: test with clang-tidy
958+ # TODO: test with --addon
959+ # TODO: test with FileSettings
957960# TODO: test with multiple files
958- def __test_showtime (tmp_path , showtime , exp_len , exp_last , extra_args = None ):
961+ def __test_showtime (tmp_path , showtime , exp_res , exp_last , extra_args = None ):
959962 test_file = tmp_path / 'test.cpp'
960963 with open (test_file , 'wt' ) as f :
961964 f .write (
@@ -979,62 +982,65 @@ def __test_showtime(tmp_path, showtime, exp_len, exp_last, extra_args=None):
979982 exitcode , stdout , stderr = cppcheck (args )
980983 assert exitcode == 0
981984 lines = stdout .splitlines ()
985+ exp_len = exp_res
986+ if exp_res :
987+ exp_len += 1 # empty line at the beginning - only added when individual results exist
982988 if 'cppcheck internal API usage' in stdout :
983989 exp_len += 1
990+ exp_len += 1 # last line
984991 assert len (lines ) == exp_len
985- idx_last = exp_len - 1
986- if idx_last :
992+ if exp_res :
987993 assert lines [0 ] == ''
988- for i in range (1 , idx_last ):
994+ for i in range (1 , exp_res ):
989995 assert 'avg.' in lines [i ]
990- assert lines [idx_last ].startswith (exp_last )
996+ assert lines [exp_len - 1 ].startswith (exp_last )
991997 assert stderr == ''
992998
993999
9941000def test_showtime_top5_file (tmp_path ):
995- __test_showtime (tmp_path , 'top5_file' , 7 , 'Check time: ' )
1001+ __test_showtime (tmp_path , 'top5_file' , 5 , 'Check time: ' )
9961002
9971003
9981004# TODO: remove extra args when --executor=process works works
9991005def test_showtime_top5_summary (tmp_path ):
1000- __test_showtime (tmp_path , 'top5_summary' , 7 , 'Overall time: ' , ['-j1' ])
1006+ __test_showtime (tmp_path , 'top5_summary' , 5 , 'Overall time: ' , ['-j1' ])
10011007
10021008
10031009# TODO: remove when --executor=process works works
10041010def test_showtime_top5_summary_j_thread (tmp_path ):
1005- __test_showtime (tmp_path , 'top5_summary' , 7 , 'Overall time: ' , ['-j2' , '--executor=thread' ])
1011+ __test_showtime (tmp_path , 'top5_summary' , 5 , 'Overall time: ' , ['-j2' , '--executor=thread' ])
10061012
10071013
10081014# TODO: remove override when fixed
10091015@pytest .mark .skipif (sys .platform == 'win32' , reason = "requires ProcessExecutor" )
10101016@pytest .mark .xfail (strict = True ) # TODO: need to transfer the timer results to parent process - see #4452
10111017def test_showtime_top5_summary_j_process (tmp_path ):
1012- __test_showtime (tmp_path , 'top5_summary' , 7 , 'Overall time: ' , ['-j2' , '--executor=process' ])
1018+ __test_showtime (tmp_path , 'top5_summary' , 5 , 'Overall time: ' , ['-j2' , '--executor=process' ])
10131019
10141020
10151021def test_showtime_file (tmp_path ):
1016- __test_showtime (tmp_path , 'file' , 79 , 'Check time: ' )
1022+ __test_showtime (tmp_path , 'file' , 77 , 'Check time: ' )
10171023
10181024
10191025# TODO: remove extra args when --executor=process works works
10201026def test_showtime_summary (tmp_path ):
1021- __test_showtime (tmp_path , 'summary' , 79 , 'Overall time: ' , ['-j1' ])
1027+ __test_showtime (tmp_path , 'summary' , 77 , 'Overall time: ' , ['-j1' ])
10221028
10231029
10241030# TODO: remove when --executor=process works works
10251031def test_showtime_summary_j_thread (tmp_path ):
1026- __test_showtime (tmp_path , 'summary' , 79 , 'Overall time: ' , ['-j2' , '--executor=thread' ])
1032+ __test_showtime (tmp_path , 'summary' , 77 , 'Overall time: ' , ['-j2' , '--executor=thread' ])
10271033
10281034
10291035# TODO: remove override when fixed
10301036@pytest .mark .skipif (sys .platform == 'win32' , reason = "requires ProcessExecutor" )
10311037@pytest .mark .xfail (strict = True ) # TODO: need to transfer the timer results to parent process - see #4452
10321038def test_showtime_summary_j_process (tmp_path ):
1033- __test_showtime (tmp_path , 'summary' , 79 , 'Overall time: ' , ['-j2' , '--executor=process' ])
1039+ __test_showtime (tmp_path , 'summary' , 77 , 'Overall time: ' , ['-j2' , '--executor=process' ])
10341040
10351041
10361042def test_showtime_file_total (tmp_path ):
1037- __test_showtime (tmp_path , 'file-total' , 1 , 'Check time: ' )
1043+ __test_showtime (tmp_path , 'file-total' , 0 , 'Check time: ' )
10381044
10391045
10401046def test_missing_addon (tmpdir ):
0 commit comments