summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorErnestas Kulik <ernestask@gnome.org>2018-05-17 13:28:13 +0300
committerCarlos Soriano <csoriano1618@gmail.com>2018-05-18 14:05:53 +0000
commitcfa26f0cfe827e84d4ae0501e80fa65b190ff0ee (patch)
tree98071f74fe0ffcf79302a8861f0cfe6d848d492b /test
parent2e331b6c80d90e72a86218ad232adeb5ffc05966 (diff)
downloadnautilus-cfa26f0cfe827e84d4ae0501e80fa65b190ff0ee.tar.gz
build: Set a couple env vars when running tests
This will save some time/thinking when running tests manually. G_TEST_BUILDDIR and G_TEST_SRCDIR will be useful if g_test_build_filename() is ever used, since our primary build mode is outside the source directory, which would break the function.
Diffstat (limited to 'test')
-rw-r--r--test/automated/display/meson.build15
-rw-r--r--test/automated/displayless/meson.build10
-rw-r--r--test/meson.build19
3 files changed, 42 insertions, 2 deletions
diff --git a/test/automated/display/meson.build b/test/automated/display/meson.build
index 1edd7b60d..171730e43 100644
--- a/test/automated/display/meson.build
+++ b/test/automated/display/meson.build
@@ -1,3 +1,8 @@
+test_env += [
+ 'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()),
+ 'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir())
+]
+
tests = [
['test-nautilus-search-engine', [
'test-nautilus-search-engine.c'
@@ -8,5 +13,13 @@ tests = [
]
foreach t: tests
- test(t[0], executable(t[0], t[1], dependencies: libnautilus_dep))
+ test(
+ t[0],
+ executable(t[0], t[1], dependencies: libnautilus_dep),
+ env: [
+ test_env,
+ 'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()),
+ 'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir())
+ ]
+ )
endforeach
diff --git a/test/automated/displayless/meson.build b/test/automated/displayless/meson.build
index cd7573417..0c3a3e13d 100644
--- a/test/automated/displayless/meson.build
+++ b/test/automated/displayless/meson.build
@@ -11,5 +11,13 @@ tests = [
]
foreach t: tests
- test(t[0], executable(t[0], t[1], dependencies: libnautilus_dep))
+ test(
+ t[0],
+ executable(t[0], t[1], dependencies: libnautilus_dep),
+ env: [
+ test_env,
+ 'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()),
+ 'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir())
+ ]
+ )
endforeach
diff --git a/test/meson.build b/test/meson.build
index 6fd5e6005..815705509 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -1,2 +1,21 @@
+# When adding new tests, it is useful to set some environment variables.
+# You can do it like so:
+#
+# test(
+# name,
+# executable,
+# env: [
+# test_env,
+# 'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()),
+# 'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir())
+# ]
+# )
+#
+# G_TEST_BUILDDIR and G_TEST_SRCDIR cannot be preset, since
+# the test sources are scattered.
+test_env = [
+ 'GSETTINGS_SCHEMA_DIR=@0@'.format(join_paths(meson.build_root(), 'data'))
+]
+
subdir('automated')
subdir('interactive')