diff options
author | Laurent Bigonville <bigon@bigon.be> | 2020-03-20 12:59:11 +0100 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2020-03-20 16:30:52 +0000 |
commit | 1572d92bb69de7632841bf17f3cb81534881c3c6 (patch) | |
tree | 6fedee476829d567413db9f9a4f30126c3aaa753 | |
parent | 7e3e1f1dec3cf8a365843f9a51933b450180faf5 (diff) | |
download | colord-1572d92bb69de7632841bf17f3cb81534881c3c6.tar.gz |
tests: Make the build reproductible
Fixes: #106
-rw-r--r-- | lib/colord/cd-test-shared.c | 17 | ||||
-rw-r--r-- | lib/colord/meson.build | 15 | ||||
-rw-r--r-- | lib/colorhug/meson.build | 5 | ||||
-rw-r--r-- | meson.build | 2 |
4 files changed, 16 insertions, 23 deletions
diff --git a/lib/colord/cd-test-shared.c b/lib/colord/cd-test-shared.c index c3b9d23..1706b0a 100644 --- a/lib/colord/cd-test-shared.c +++ b/lib/colord/cd-test-shared.c @@ -41,7 +41,7 @@ cd_test_get_filename (const gchar *filename) { gchar *tmp; char full_tmp[PATH_MAX]; - g_autofree gchar *path = NULL; + const gchar *testdatadir; /* running in the installed system */ if (g_getenv ("INSTALLED_TESTS") != NULL) { @@ -51,11 +51,16 @@ cd_test_get_filename (const gchar *filename) filename, NULL); } - path = g_build_filename (TESTDATADIR, filename, NULL); - tmp = realpath (path, full_tmp); - if (tmp == NULL) - return NULL; - return g_strdup (full_tmp); + /* self tests are running */ + testdatadir = g_getenv ("TESTDATADIR"); + if (testdatadir != NULL) { + g_autofree gchar *path = NULL; + path = g_build_filename (testdatadir, filename, NULL); + tmp = realpath (path, full_tmp); + if (tmp != NULL) + return g_strdup (full_tmp); + } + return NULL; } static GMainLoop *_test_loop = NULL; diff --git a/lib/colord/meson.build b/lib/colord/meson.build index 61f0518..dbb3d19 100644 --- a/lib/colord/meson.build +++ b/lib/colord/meson.build @@ -232,7 +232,8 @@ configure_file( endif if get_option('tests') - testdatadir = join_paths(meson.source_root(), 'data', 'tests') + testdatadir = environment({'TESTDATADIR' : join_paths(meson.source_root(), 'data', 'tests')}) + e = executable( 'colord-test-private', sources : [ @@ -249,14 +250,10 @@ if get_option('tests') lcms, ], link_with : colordprivate, - c_args : [ - cargs, - '-DTESTDATADIR="' + testdatadir + '"', - ], install : get_option('installed_tests'), install_dir : join_paths(libexecdir, 'installed-tests', 'colord'), ) - test('colord-test-private', e) + test('colord-test-private', e, env : testdatadir) e = executable( 'colord-test-daemon', sources : [ @@ -273,12 +270,8 @@ if get_option('tests') lcms, ], link_with : colord, - c_args : [ - cargs, - '-DTESTDATADIR="' + testdatadir + '"', - ], install : get_option('installed_tests'), install_dir : join_paths(libexecdir, 'installed-tests', 'colord'), ) - test('colord-test-daemon', e) + test('colord-test-daemon', e, env : testdatadir) endif diff --git a/lib/colorhug/meson.build b/lib/colorhug/meson.build index 03aefb7..9526ea4 100644 --- a/lib/colorhug/meson.build +++ b/lib/colorhug/meson.build @@ -109,7 +109,6 @@ libcolorhug_gir = gnome.generate_gir(colorhug, ) if get_option('tests') - testdatadir = join_paths(meson.source_root(), 'data', 'tests') e = executable( 'ch-self-test', sources : [ @@ -129,10 +128,6 @@ if get_option('tests') colordprivate, colorhug, ], - c_args : [ - cargs, - '-DTESTDATADIR="' + testdatadir + '"', - ], ) test('colorhug-self-test', e) endif diff --git a/meson.build b/meson.build index b4f17ad..916eadb 100644 --- a/meson.build +++ b/meson.build @@ -1,7 +1,7 @@ project('colord', 'c', version : '1.4.5', license : 'LGPL-2.1+', - meson_version : '>=0.46.0', + meson_version : '>=0.52.0', default_options : ['c_std=c99'] ) |