Bug fix: rotate plugin
[geeqie.git] / meson.build
index e888e07..fbe227e 100644 (file)
@@ -34,6 +34,7 @@
 # [gq_]htmldir  /usr/local/share/doc/geeqie/html    *   help files
 # gq_localedir  /usr/locale/share/locale
 # mandir1       /usr/local/share/man/man1               man page
+# completionsdir /usr/local/share/bash-completion/completions bash command line completions
 # podir         project_root/po
 
 # * See meson_options.txt file
@@ -134,7 +135,7 @@ helpdir = join_paths(prefix, gq_helpdir)
 htmldir = join_paths(prefix, gq_htmldir)
 icondir = join_paths(datadir, 'pixmaps')
 mandir1 = join_paths(datadir, 'man', 'man1')
-
+completionsdir = join_paths(datadir, 'bash-completion', 'completions')
 podir = join_paths(meson.project_source_root(), 'po')
 scriptsdir = join_paths(meson.project_source_root(), 'scripts')
 
@@ -199,6 +200,13 @@ else
     summary({'execinfo' : ['stacktrace supported:', false]}, section : 'Debugging', bool_yn : true)
 endif
 
+conf_data.set('ENABLE_UNIT_TESTS', 0)
+option = get_option('unit_tests')
+if not option.disabled()
+    conf_data.set('ENABLE_UNIT_TESTS', 1)
+    # Summary is handled below, where the test() itself is defined.
+endif
+
 conf_data.set('HAVE_ARCHIVE', 0)
 libarchive_dep = []
 req_version = '>=3.4.0'
@@ -610,12 +618,30 @@ ui_sources = []
 subdir('po')
 subdir('plugins')
 
+conditional_unit_test_deps = []
+if conf_data.get('ENABLE_UNIT_TESTS', 0) == 1
+    system_gtest_dep = dependency('gtest', main : false, required : false)
+    system_gmock_dep = dependency('gmock', required : false)
+    if system_gtest_dep.found() and system_gmock_dep.found()
+        conditional_unit_test_deps += system_gtest_dep
+        conditional_unit_test_deps += system_gmock_dep
+    else
+        # Use the subproject gtest as a fallback.
+        gtest_subproj = subproject('gtest')
+        conditional_unit_test_deps += gtest_subproj.get_variable('gtest_dep')
+        conditional_unit_test_deps += gtest_subproj.get_variable('gmock_dep')
+    endif
+endif
+
 # Generate the executable
 subdir('src')
 
 # Generate the help files
 subdir('doc')
 
+# Generate the command line auto-complete file
+subdir('auto-complete')
+
 # Install other project files
 if running_from_git
     cmd = [find_program('gen_changelog.sh'), meson.current_source_dir(), meson.current_build_dir()]
@@ -654,11 +680,13 @@ i18n.merge_file(
 
 configure_file(input: 'geeqie.spec.in', output: 'geeqie.spec', configuration: conf_data)
 
+isolate_test_sh = find_program('isolate-test.sh', dirs : scriptsdir, required : true)
+
 # Basic test of the executable
-# is_parallel false is to avoid problems with images tests
 xvfb = find_program('xvfb-run', required : false)
 if xvfb.found()
-    test('Basic test', xvfb, args: ['--auto-servernum', geeqie_exe, '--version'], is_parallel : false, timeout: 100)
+    test_cmd = [xvfb.full_path(), '--auto-servernum', geeqie_exe.full_path(), '--version']
+    test('Basic test', isolate_test_sh, args: test_cmd, timeout: 100, suite: 'functional')
     summary({'xvfb' : ['Test runs:', true]}, section : 'Testing', bool_yn : true)
 else
     summary({'xvfb' : ['Test runs:', false]}, section : 'Testing', bool_yn : true)
@@ -683,15 +711,12 @@ if option.enabled()
         sources = sources_list.stdout().strip().split('\n')
 
         foreach image : sources
-            image_path = '@0@'.format(image)
-            path_array = image_path.split('/')
+            path_array = image.split('/')
             image_name = path_array[path_array.length() - 1]
 
-            if image_name.startswith('fail')
-                test('Image_ ' + image_name, image_test_sh, args: [geeqie_exe, image], is_parallel : false, should_fail : true, timeout: 100)
-            else
-                test('Image_ ' + image_name, image_test_sh, args: [geeqie_exe, image], is_parallel : false, timeout: 100)
-            endif
+            should_fail = image_name.startswith('fail')
+            test_cmd = [image_test_sh.full_path(), geeqie_exe.full_path(), image]
+            test('Image_ ' + image_name, isolate_test_sh, args: test_cmd, should_fail : should_fail, timeout: 100, suite: ['functional', 'image'])
         endforeach
         summary({'Image tests' : ['Test runs:', true]}, section : 'Testing', bool_yn : true)
     else
@@ -706,18 +731,13 @@ 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', 'origin/master', '--name-only', '--diff-filter=d', './src/*.cc', './src/pan-view/*.cc', './src/view-file/*.cc', 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)
+
+        foreach source_file : main_sources + pan_view_sources + view_file_sources
+            if fs.name(source_file).endswith('.cc')
+                source_file_name = fs.name(source_file)
                 config_file = join_paths(meson.project_source_root(), '.clang-tidy')
 
-                test('Code Correctness_ ' + modified_file_name, clang_tidy_exe, args : ['-p', './build', '-quiet', '--config-file', config_file,  modified_file_full_path], timeout : 100)
+                test('Code Correctness_ ' + source_file_name, clang_tidy_exe, args : ['-p', './build', '-quiet', '--config-file', config_file,  source_file], timeout : 100, suite : 'analysis')
             endif
         endforeach
 
@@ -729,13 +749,71 @@ else
     summary({'Code Correctness' : ['Test runs:', false]}, section : 'Testing', bool_yn : true)
 endif
 
+# Single value enum checks
+enum_check_sh = find_program('enum-check.sh', dirs : scriptsdir, required : true)
+if enum_check_sh.found()
+    foreach source_file : main_sources + pan_view_sources + view_file_sources
+        source_file_name = fs.name(source_file)
+        test('Single Value enum_ ' + source_file_name, enum_check_sh, args : [source_file], timeout : 100, suite : 'analysis')
+    endforeach
+
+    summary({'Single Value enum' : ['Test runs:', true]}, section : 'Testing', bool_yn : true)
+else
+    summary({'Single Value enum' : ['Test runs:', false]}, section : 'Testing', bool_yn : true)
+endif
+
+# Debug statement checks
+debug_check_sh = find_program('debug-check.sh', dirs : scriptsdir, required : true)
+if debug_check_sh.found()
+    foreach source_file : main_sources + pan_view_sources + view_file_sources
+        source_file_name = fs.name(source_file)
+        if (source_file_name != 'debug.h')
+            test('Debug Statements_ ' + source_file_name, debug_check_sh, args : [source_file], timeout : 100, suite : 'analysis')
+        endif
+    endforeach
+
+    summary({'Debug Statements' : ['Test runs:', true]}, section : 'Testing', bool_yn : true)
+else
+    summary({'Debug Statements' : ['Test runs:', false]}, section : 'Testing', bool_yn : true)
+endif
+
+# Temporary comments checks
+tmp_comments_check_sh = find_program('temporary-comments-check.sh', dirs : scriptsdir, required : true)
+if tmp_comments_check_sh.found()
+    foreach source_file : main_sources + pan_view_sources + view_file_sources
+        source_file_name = fs.name(source_file)
+        if (source_file_name != 'debug.h')
+            test('Temporary Comments_ ' + source_file_name, tmp_comments_check_sh, args : [source_file], timeout : 100, suite : 'analysis')
+        endif
+    endforeach
+
+    summary({'Temporary Comments' : ['Test runs:', true]}, section : 'Testing', bool_yn : true)
+else
+    summary({'Temporary Comments' : ['Test runs:', false]}, section : 'Testing', bool_yn : true)
+endif
+
+# Untranslated text checks
+untranslated_text_sh = find_program('untranslated-text.sh', dirs : scriptsdir, required : true)
+if untranslated_text_sh.found()
+        foreach source_file : main_sources + pan_view_sources + view_file_sources
+               if fs.name(source_file).endswith('.cc')
+                       source_file_name = fs.name(source_file)
+                       test('Untranslated Text_ ' + source_file_name, untranslated_text_sh, args : [source_file], timeout : 200, suite : 'analysis')
+               endif
+       endforeach
+
+       summary({'Untranslated Text' : ['Test runs:', true]}, section : 'Testing', bool_yn : true)
+else
+       summary({'Untranslated Text' : ['Test runs:', false]}, section : 'Testing', bool_yn : true)
+endif
+
 # Lua test
 option = get_option('lua')
 if not option.disabled()
     if lua_dep.found()
         if xvfb.found()
             lua_test_sh = find_program('lua-test.sh', dirs : scriptsdir, required : true)
-            test('Lua test', lua_test_sh, args: [geeqie_exe], is_parallel : false, timeout: 100)
+            test('Lua test', isolate_test_sh, args: [lua_test_sh.full_path(), geeqie_exe.full_path()], timeout: 100, suite : 'analysis')
 
             summary({'lua' : ['Test runs:', true]}, section : 'Testing', bool_yn : true)
         else
@@ -750,6 +828,14 @@ endif
 
 # Ancillary files test
 test_ancillary_files_sh = find_program('test-ancillary-files.sh', dirs : scriptsdir, required : true)
-test('Ancillary files', test_ancillary_files_sh, args: [meson.current_source_dir()], timeout: 100)
+test('Ancillary files', test_ancillary_files_sh, args: [meson.current_source_dir()], timeout: 100, suite : 'analysis')
 
 summary({'Ancillary files' : ['Test runs:', true]}, section : 'Testing', bool_yn : true)
+
+# Unit tests
+if conf_data.get('ENABLE_UNIT_TESTS', 0) == 1
+    test('Unit tests', isolate_test_sh, args: [geeqie_exe.full_path(), '--run-unit-tests'], suite : 'unit')
+    summary({'unit_tests' : ['Tests run:', true]}, section : 'Testing', bool_yn : true)
+else
+    summary({'unit_tests' : ['Tests run:', false]}, section : 'Testing', bool_yn : true)
+endif