gimp/libgimp/tests/meson.build

69 lines
2.6 KiB
Meson
Raw Normal View History

# XXX: we have a bunch of (manually run?) tests inside libgimp/test/.
# These should either be deleted or transformed into real unit tests.
if not meson.can_run_host_binaries()
warning('libgimp unit testing disabled in cross-building or similar environments.')
subdir_done()
endif
tests = [
'color-parser',
app, libgimp*, pdb, plug-ins: review and enhance MR !1549. - Fix annotations for gimp_export_options_get_image() to make it actually introspectable with the GimpImage being both input and output. Even though the logic doesn't change much (the input image may be overriden or not), it doesn't matter for introspection because images are handled centrally by libgimp and therefore must not be freed. Actually deleting the image from the central list of images though remains a manual action depending on code logic, not some automatic action to be handled by binding engines. - Add G_GNUC_WARN_UNUSED_RESULT to gimp_export_options_get_image() because ignoring the returned value is rarely a good idea (as you usually want to delete the image). - Remove gimp_export_options_new(): we don't need this constructor because at this point, the best is to tell plug-in developers to just pass NULL everywhere. This leaves us free to create a more useful default constructor if needed, in the future. Main description for GimpExportOptions has also been updated to say this. - Add a data_destroy callback for the user data passed in gimp_export_procedure_set_capabilities(). - Fixing annotations of 'export_options' object from pdb/pdb.pl: input args would actually be (nullable) and would not transfer ownership (calling code must still free the object). Return value's ownership on the other hand is fully transfered. - Add C and Python unit testing for GimpExportOptions and gimp_export_options_get_image() in particular. - Fix or improve various details. Note that I have also considered for a long time changing the signature of gimp_export_options_get_image() to return a boolean indicating whether `image` had been replaced (hence needed deletion) or not. This also meant getting rid of the GimpExportReturn enum. Right now it would work because there are no third case, but I was considering the future possibility that for instance we got some impossible conversion for some future capability. I'm not sure it would ever happen; and for sure, this is not desirable because it implies an export failure a bit late in the workflow. But just in case, let's keep the enum return value. It does not even make the using code that much more complicated (well just a value comparison instead of a simple boolean test).
2024-08-17 21:06:27 +08:00
'export-options',
'image',
'palette',
2024-08-02 18:12:39 +08:00
'selection-float',
'unit',
]
# Unit testing environment is based on gimp_run_env with additional environment
# variables and added temporary test plug-ins. Assignment is a deep copy, so
# test_env here is a new object.
# See: https://github.com/mesonbuild/meson/issues/13045
test_env=gimp_run_env
test_env.append('GIMP_TESTING_PLUGINDIRS', meson.project_build_root() / 'libgimp/tests/c-tests/')
test_env.set('GIMP_TESTING_ABS_TOP_SRCDIR', meson.project_source_root())
run_python_test = find_program('./libgimp-run-python-test.sh')
run_c_test = find_program('./libgimp-run-c-test.sh')
cat = find_program('cat')
foreach test_name : tests
basename = 'test-' + test_name
py_test = meson.current_source_dir() / basename + '.py'
test(test_name, run_python_test,
args: [ gimp_exe.full_path(), py_test ],
env: test_env,
suite: ['libgimp', 'python3'],
timeout: 60)
c_test_name = basename + '.c'
c_test = custom_target(c_test_name,
input: [ 'c-test-header.c', c_test_name ],
output: c_test_name,
command: [cat, '@INPUT@'],
capture: true,
install: false)
c_test_exe = executable(basename,
c_test,
dependencies: [ libgimp_dep, pango ],
install: false)
# Same ugly trick as in plug-ins/common/meson.build to detect plug-ins in a
# non-installed build directory.
custom_target(basename + '.dummy',
input: [ c_test_exe ],
output: [ basename + '.dummy' ],
command: [ python, meson.project_source_root() / '.gitlab/cp-plug-in-subfolder.py',
c_test_exe, meson.current_build_dir() / 'c-tests' / basename,
'@OUTPUT@' ],
build_by_default: true,
install: false)
plugin_executables += [meson.current_build_dir() / 'c-tests' / basename / fs.name(c_test_exe.full_path())]
test(test_name, run_c_test,
args: [ gimp_exe.full_path(), meson.current_source_dir() / c_test_name, basename ],
env: test_env,
suite: ['libgimp', 'C'],
timeout: 60)
endforeach