Include clang-tidy check
[geeqie.git] / meson.build
index b584a8b..96ce460 100644 (file)
@@ -728,3 +728,30 @@ if option.enabled()
 else
     summary({'Image tests' : ['Test runs:', false]}, section : 'Testing', bool_yn : true)
 endif
+
+# Code correctness checks
+if running_from_git
+    clang_tidy_exe = find_program('clang-tidy', required : false)
+    if clang_tidy_exe.found()
+        git_exe = find_program('git', required : true)
+        modified_file_list = run_command(git_exe, 'diff', '--name-only', check: true)
+        modified_files = modified_file_list.stdout().strip().split('\n')
+
+        foreach modified_file : modified_files
+            if modified_file.endswith('.cc')
+                modified_file_path = '@0@'.format(modified_file)
+                path_array = modified_file_path.split('/')
+                modified_file_name = path_array[path_array.length() - 1]
+                modified_file_full_path = join_paths(meson.project_source_root(), modified_file)
+
+                test('Code Correctness_ ' + modified_file_name, clang_tidy_exe, args : ['-p', './build', '-quiet', modified_file_full_path], timeout : 100)
+            endif
+        endforeach
+
+        summary({'Code Correctness' : ['Test runs:', true]}, section : 'Testing', bool_yn : true)
+    else
+        summary({'Code Correctness' : ['Test runs:', false]}, section : 'Testing', bool_yn : true)
+    endif
+else
+    summary({'Code Correctness' : ['Test runs:', false]}, section : 'Testing', bool_yn : true)
+endif