+
+isolate_test_sh = find_program('isolate-test.sh', dirs : scriptsdir, required : true)
+
+# Basic test of the executable
+xvfb = find_program('xvfb-run', required : false)
+if xvfb.found()
+ 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)
+endif
+
+# The tests are run on GitHub with all options disabled, and then
+# Image tests use option unit_tests as a flag so that normal users do not
+# download the test image database.
+
+# Image checks
+option = get_option('unit_tests')
+if option.enabled()
+ if xvfb.found()
+ get_test_images_sh = find_program('get-test-images.sh', dirs : scriptsdir, required : true)
+ image_test_sh = find_program('image-test.sh', dirs : scriptsdir, required : true)
+
+ images_dir = join_paths(meson.current_build_dir(), 'test-images.p')
+
+ message('Downloading test images')
+ sources_list = run_command(get_test_images_sh, images_dir, 'https://github.com/caclark/geeqie-test.git', check: true)
+
+ sources = sources_list.stdout().strip().split('\n')
+
+ foreach image : sources
+ path_array = image.split('/')
+ image_name = path_array[path_array.length() - 1]
+
+ 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
+ summary({'Image tests' : ['Test runs:', false]}, section : 'Testing', bool_yn : true)
+ endif
+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)
+
+ foreach source_file : code_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_ ' + source_file_name, clang_tidy_exe, args : ['-p', './build', '-quiet', '--config-file', config_file, source_file], timeout : 100, suite : 'analysis')
+ 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
+
+# Single value enum checks
+enum_check_sh = find_program('enum-check.sh', dirs : scriptsdir, required : true)
+if enum_check_sh.found()
+ foreach source_file : code_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 : code_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 : code_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
+
+# GTK4 migration regression checks
+gtk4_migration_check_sh = find_program('gtk4-migration-regression-check.sh', dirs : scriptsdir, required : true)
+if gtk4_migration_check_sh.found()
+ compat_cc = join_paths(meson.project_source_root(), 'src', 'compat.cc')
+ compat_h = join_paths(meson.project_source_root(), 'src', 'compat.h')
+ foreach source_file : code_sources
+ source_file_name = fs.name(source_file)
+ if (source_file_name != 'debug.h')
+ test('GTK4 migration_ ' + source_file_name, gtk4_migration_check_sh, args : [source_file, compat_cc, compat_h], timeout : 100, suite : 'analysis')
+ endif
+ endforeach
+
+ summary({'GTK4 migration' : ['Test runs:', true]}, section : 'Testing', bool_yn : true)
+else
+ summary({'GTK4 migration' : ['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 : code_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', 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
+ summary({'lua' : ['Test runs:', false]}, section : 'Testing', bool_yn : true)
+ endif
+ else
+ summary({'lua' : ['Test runs:', false]}, section : 'Testing', bool_yn : true)
+ endif
+else
+ summary({'lua' : ['Test runs:', false]}, section : 'Testing', bool_yn : true)
+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, 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