Gimp/libgimp/tests/meson.build
Jehan 62ab8e2604 libgimp, libgimpcolor: make real unit test of old (compiled but unused) …
… test-color-parser.c file.

The file libgimpcolor/test-color-parser.c was compiled but never actually called
by the build. Now that we have a nice infrastructure to test libgimp API, I am
moving it there with the new format. Doing this also allowed me to discover some
bugs in CSS parsing, as well as discover Python binding was failing here (cf.
the few previous commits).

Only one test is disabled so far, the one where 4 digits are used per channel in
hexadecimal notation: "#64649595eded". This format simply doesn't appear
anywhere in the spec, and also the result values in the samples listing don't
even fit. So far, I'm just unsure what to do with it, if we want to keep this
support (of some kind of higher precision hex notation, but not specified, so is
it even used by anyone?) or not.

All the other tests just work in both C and Python!
2024-04-20 12:39:52 +02:00

65 lines
2.5 KiB
Meson

# 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',
'palette',
'selection-float'
]
# 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