Commit 7ea81c25 authored by Debarshi Ray's avatar Debarshi Ray

tests: Add a harness for unit tests

The actual tests will be added in subsequent commits.

GNOME/gnome-photos!80
parent af396b42
......@@ -147,6 +147,7 @@ help/Makefile
subprojects/libgd/Makefile
src/Makefile
tests/Makefile
tests/unit/Makefile
po/Makefile.in
])
AC_OUTPUT
......@@ -23,12 +23,15 @@ photos_namespace = 'org.gnome.Photos'
photos_buildtype = get_option('buildtype')
photos_installed_tests_enabled = get_option('installed_tests')
photos_installed_tests_template_tap = files('template-tap.test.in')
gnome = import('gnome')
i18n = import('i18n')
source_root = meson.current_source_dir()
po_dir = join_paths(source_root, 'po')
src_inc = include_directories('src')
top_inc = include_directories('.')
photos_commit_id = ''
......
[Test]
Type=session
Exec=@installed_tests_dir@/@program@ --tap
Output=TAP
include $(top_srcdir)/glib-tap.mk
SUBDIRS = unit
dogtail_tests = \
basic.py \
$(NULL)
......
subdir('unit')
test_name = 'basic.py'
if photos_installed_tests_enabled
......
include $(top_srcdir)/glib-tap.mk
TESTS_ENVIRONMENT += \
GSETTINGS_BACKEND=memory \
$(NULL)
dist_test_data = \
$(NULL)
test_programs = \
$(NULL)
AM_CFLAGS = \
$(WARN_CFLAGS) \
$(NULL)
AM_LDFLAGS = \
$(WARN_LDFLAGS) \
$(NULL)
-include $(top_srcdir)/git.mk
# Not entirely random of course, but at least it changes over time
meson_minor_version = meson.version().split('.').get(1).to_int()
photos_minor_version = meson.project_version().split('.').get(1).to_int()
random_number = meson_minor_version + photos_minor_version
test_env = environment()
test_env.set('G_DEBUG', 'gc-friendly')
test_env.set('G_TEST_BUILDDIR', meson.current_build_dir())
test_env.set('G_TEST_SRCDIR', meson.current_source_dir())
test_env.set('GSETTINGS_BACKEND', 'memory')
test_env.set('MALLOC_CHECK_', '2')
test_env.set('MALLOC_PERTURB_', '@0@'.format(random_number % 256))
tests = {
}
test_data = [
]
foreach test_name, extra_args: tests
cflags = extra_args.get('c_args', [])
deps = extra_args.get('dependencies', [])
extra_sources = extra_args.get('extra_sources', [])
install = photos_installed_tests_enabled and extra_args.get('install', true)
is_parallel = extra_args.get('is_parallel', true)
source = extra_args.get('source', test_name + '.c')
suite = extra_args.get('suite', [])
if install
test_conf = configuration_data()
test_conf.set('installed_tests_dir', photos_installed_test_execdir)
test_conf.set('program', test_name)
configure_file(
input: photos_installed_tests_template_tap,
output: test_name + '.test',
configuration: test_conf,
install: true,
install_dir: photos_installed_test_metadir,
)
endif
exe = executable(
test_name,
[source, extra_sources],
include_directories: [src_inc, top_inc],
dependencies: deps,
c_args: cflags,
install: install,
install_dir: photos_installed_test_execdir,
install_rpath: photos_libdir,
)
timeout = suite.contains('slow') ? 120 : 30
test(
test_name,
exe,
env: test_env,
timeout: timeout,
suite: suite,
args: ['--tap'],
is_parallel: is_parallel,
)
endforeach
if photos_installed_tests_enabled
install_data(test_data, install_dir: photos_installed_test_execdir)
endif
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment