summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@gnome.org>2017-08-02 13:14:29 +0100
committerEmmanuele Bassi <ebassi@gnome.org>2017-08-02 13:14:29 +0100
commit5e669da4a655868d74833a6e3cc89a803f430aad (patch)
tree6f3397f1db23c7b1fc5a27f952c70e9f5aed8e28
parent5571ecd6a82b3d56c4a107f2c2bda0c14d67cb6f (diff)
downloadgdk-pixbuf-5e669da4a655868d74833a6e3cc89a803f430aad.tar.gz
meson: Support installed tests
We want to be able to run the gdk-pixbuf tests after installing them in a known system location, especially when running CI.
-rw-r--r--gdk-pixbuf/meson.build2
-rw-r--r--meson.build2
-rw-r--r--tests/gen-installed-test.py21
-rw-r--r--tests/meson.build49
4 files changed, 72 insertions, 2 deletions
diff --git a/gdk-pixbuf/meson.build b/gdk-pixbuf/meson.build
index 1ec8e106f..c52728220 100644
--- a/gdk-pixbuf/meson.build
+++ b/gdk-pixbuf/meson.build
@@ -34,7 +34,7 @@ gdk_pixbuf_cflags = [
'-DBUILT_MODULES_DIR="@0@"'.format(meson.current_build_dir()),
]
-gdk_pixbuf_api_path = join_paths('gdk-pixbuf-@0@'.format(gdk_pixbuf_api_version), 'gdk-pixbuf')
+gdk_pixbuf_api_path = join_paths(gdk_pixbuf_api_name, 'gdk-pixbuf')
gdkpixbuf_features_conf = configuration_data()
gdkpixbuf_features_conf.set('GDK_PIXBUF_MAJOR', gdk_pixbuf_version_major)
diff --git a/meson.build b/meson.build
index 77757bea7..b0be82acf 100644
--- a/meson.build
+++ b/meson.build
@@ -23,6 +23,8 @@ gdk_pixbuf_version_micro = version_arr[2].to_int()
gdk_pixbuf_api_version = '2.0'
gdk_pixbuf_binary_version = '2.10.0'
+gdk_pixbuf_api_name = '@0@-@1@'.format(meson.project_name(), gdk_pixbuf_api_version)
+
if gdk_pixbuf_version_minor.is_odd()
gdk_pixbuf_interface_age = 0
else
diff --git a/tests/gen-installed-test.py b/tests/gen-installed-test.py
new file mode 100644
index 000000000..745abf339
--- /dev/null
+++ b/tests/gen-installed-test.py
@@ -0,0 +1,21 @@
+#!/usr/bin/env python3
+
+import sys
+import os
+import argparse
+
+def write_template(filename, data):
+ with open(filename, 'w') as f:
+ f.write(data)
+
+def build_template(bindir, binname):
+ return "[Test]\nType=session\nExec={}\n".format(os.path.join(bindir, binname))
+
+argparser = argparse.ArgumentParser(description='Generate installed-test data.')
+argparser.add_argument('--testbindir', metavar='dir', help='Installed test directory')
+argparser.add_argument('--testbin', metavar='name', help='Installed test name')
+argparser.add_argument('output', help='Output file')
+
+args = argparser.parse_args()
+
+write_template(args.output, build_template(args.testbindir, args.testbin))
diff --git a/tests/meson.build b/tests/meson.build
index 91e2f8863..50d4b1d19 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -58,7 +58,40 @@ installed_tests = [
[ 'pixbuf-area-updated' ],
]
+test_data = [
+ 'test-image.png',
+ 'test-animation.gif',
+ '1_partyanimsm2.gif',
+ 'test-animation.ani',
+ 'icc-profile.jpeg',
+ 'icc-profile.png',
+ 'dpi.jpeg',
+ 'dpi.png',
+ 'dpi.tiff',
+ 'premature-end.png',
+ 'premature-end.jpg',
+ 'bug143608-comment.jpg',
+ 'bug725582-testrotate.jpg',
+ 'bug725582-testrotate.png',
+ 'cve-2015-4491.bmp',
+ 'large.png',
+ 'large.jpg',
+ 'bug775218.jpg',
+ 'test-image.pixdata',
+ 'test-image-rle.pixdata',
+ 'bug775693.pixdata',
+ 'aero.gif',
+]
+
+gen_installed_test = find_program('gen-installed-test.py')
+
+installed_test_bindir = join_paths(gdk_pixbuf_libexecdir, 'installed-tests', gdk_pixbuf_api_name)
+installed_test_datadir = join_paths(gdk_pixbuf_datadir, 'installed-tests', gdk_pixbuf_api_name)
+
+install_data(test_data, install_dir: installed_test_bindir)
+
test_deps = gdk_pixbuf_deps + [ gdkpixbuf_dep ]
+
foreach t: installed_tests
test_name = t[0]
test_sources = [ test_name + '.c', 'test-common.c' ]
@@ -67,9 +100,23 @@ foreach t: installed_tests
test_sources += [ resources_c, resources_h ]
endif
+ custom_target(test_name + '.test',
+ output: test_name + '.test',
+ command: [
+ gen_installed_test,
+ '--testbindir=@0@'.format(installed_test_bindir),
+ '--testbin=@0@'.format(test_name),
+ '@OUTPUT@',
+ ],
+ install: true,
+ install_dir: installed_test_datadir)
+
test_bin = executable(test_name, test_sources,
dependencies: test_deps,
- include_directories: [ root_inc, include_directories('../gdk-pixbuf') ],
+ include_directories: [
+ root_inc,
+ include_directories('../gdk-pixbuf')
+ ],
c_args: common_cflags)
test(test_name, test_bin,