@@ -954,9 +954,8 @@ def test_unused_function_include(tmpdir):
954954 __test_unused_function_include (tmpdir , [])
955955
956956
957- # TODO: test with clang-tidy
958957# TODO: test with multiple files
959- def __test_showtime (tmp_path , showtime , exp_res , exp_last , use_compdb = False , use_addons = False , extra_args = None ):
958+ def __test_showtime (tmp_path , showtime , exp_res , exp_last , use_compdb = False , use_addons = False , use_clang_tidy = False , extra_args = None ):
960959 test_file = tmp_path / 'test.cpp' # the use of C++ is intentional
961960 with open (test_file , 'wt' ) as f :
962961 f .write (
@@ -976,6 +975,14 @@ def __test_showtime(tmp_path, showtime, exp_res, exp_last, use_compdb=False, use
976975 if use_addons :
977976 args += ['--addon=misra' , '--addon=misc' ]
978977
978+ if use_clang_tidy :
979+ args += ['--clang-tidy' ]
980+ args += ['--suppress=clang-tidy-misc-use-internal-linkage' ]
981+ args += ['--suppress=clang-tidy-google-readability-casting' ]
982+ args += ['--suppress=clang-tidy-modernize-avoid-c-style-cast' ]
983+ args += ['--suppress=clang-tidy-hicpp-use-nullptr' ]
984+ args += ['--suppress=clang-tidy-modernize-use-nullptr' ]
985+
979986 if use_compdb :
980987 compdb_file = tmp_path / 'compile_commands.json'
981988 create_compile_commands (compdb_file , [test_file ])
@@ -995,6 +1002,7 @@ def __test_showtime(tmp_path, showtime, exp_res, exp_last, use_compdb=False, use
9951002 exp_len += 1
9961003 if use_addons :
9971004 exp_len += 1 # TODO: should have individual entries for each addon and whole program analysis
1005+ # TODO: add entry for clang-tidy analysis
9981006 exp_len += 1 # last line
9991007 assert len (lines ) == exp_len
10001008 for i in range (1 , exp_res ):
@@ -1053,12 +1061,12 @@ def test_showtime_top5_summary_compdb_j_process(tmp_path):
10531061 __test_showtime (tmp_path , 'top5_summary' , 5 , 'Overall time: ' , use_compdb = True , extra_args = ['-j2' , '--executor=process' ])
10541062
10551063
1056- def __test_showtime_file (tmp_path , use_compdb = False , use_addons = False ):
1064+ def __test_showtime_file (tmp_path , use_compdb = False , use_addons = False , use_clang_tidy = False ):
10571065 exp_res = 79
10581066 # project analysis does not call Preprocessor::getConfig()
10591067 if use_compdb :
10601068 exp_res -= 1
1061- __test_showtime (tmp_path , 'file' , exp_res , 'Check time: ' , use_compdb = use_compdb , use_addons = use_addons )
1069+ __test_showtime (tmp_path , 'file' , exp_res , 'Check time: ' , use_compdb = use_compdb , use_addons = use_addons , use_clang_tidy = use_clang_tidy )
10621070
10631071
10641072def test_showtime_file (tmp_path ):
@@ -1077,13 +1085,21 @@ def test_showtime_file_addon_compdb(tmp_path):
10771085 __test_showtime_file (tmp_path , use_addons = True , use_compdb = True )
10781086
10791087
1088+ def test_showtime_file_clang_tidy (tmp_path ):
1089+ __test_showtime_file (tmp_path , use_clang_tidy = True )
1090+
1091+
1092+ def test_showtime_file_clang_tidy_compdb (tmp_path ):
1093+ __test_showtime_file (tmp_path , use_clang_tidy = True , use_compdb = True )
1094+
1095+
10801096# TODO: remove extra args when --executor=process works
1081- def __test_showtime_summary (tmp_path , use_compdb = False , use_addons = False ):
1097+ def __test_showtime_summary (tmp_path , use_compdb = False , use_addons = False , use_clang_tidy = False ):
10821098 exp_res = 79
10831099 # project analysis does not call Preprocessor::getConfig()
10841100 if use_compdb :
10851101 exp_res -= 1
1086- __test_showtime (tmp_path , 'summary' , exp_res , 'Overall time: ' , use_compdb = use_compdb , use_addons = use_addons , extra_args = ['-j1' ])
1102+ __test_showtime (tmp_path , 'summary' , exp_res , 'Overall time: ' , use_compdb = use_compdb , use_addons = use_addons , use_clang_tidy = use_clang_tidy , extra_args = ['-j1' ])
10871103
10881104
10891105def test_showtime_summary (tmp_path ):
@@ -1102,6 +1118,14 @@ def test_showtime_summary_addon_compdb(tmp_path):
11021118 __test_showtime_summary (tmp_path , use_addons = True , use_compdb = True )
11031119
11041120
1121+ def test_showtime_summary_clang_tidy (tmp_path ):
1122+ __test_showtime_summary (tmp_path , use_clang_tidy = True )
1123+
1124+
1125+ def test_showtime_summary_clang_tidy_compdb (tmp_path ):
1126+ __test_showtime_summary (tmp_path , use_clang_tidy = True , use_compdb = True )
1127+
1128+
11051129# TODO: remove when --executor=process works
11061130def test_showtime_summary_j_thread (tmp_path ):
11071131 __test_showtime (tmp_path , 'summary' , 79 , 'Overall time: ' , extra_args = ['-j2' , '--executor=thread' ])
0 commit comments