From 28e3e3199c0c25b6888df34cde0ebb7c2343f5b7 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Tue, 7 Jan 2020 14:06:39 +0530 Subject: [PATCH] meson: add test wrapper Allow us to run the tests using 'meson test'. Needed for https://gitlab.freedesktop.org/gstreamer/gst-ci/issues/46 --- cargo_wrapper.py | 10 ++++++++-- meson.build | 16 ++++++++++++++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/cargo_wrapper.py b/cargo_wrapper.py index 1ffce188..d7221102 100644 --- a/cargo_wrapper.py +++ b/cargo_wrapper.py @@ -7,8 +7,8 @@ import shutil import subprocess import sys -command, meson_build_dir, meson_current_source_dir, meson_build_root, target, ext, exclude = sys.argv[ - 1:] +command, meson_build_dir, meson_current_source_dir, meson_build_root, target, exclude = sys.argv[ + 1:7] cargo_target_dir = os.path.join(meson_build_dir, 'target') @@ -28,11 +28,17 @@ env['PKG_CONFIG_PATH'] = ':'.join(pkg_config_path) if command == 'build': # cargo build + ext = sys.argv[7] cargo_cmd = ['cargo', 'build', '--manifest-path', os.path.join(meson_current_source_dir, 'Cargo.toml'), '--workspace'] if target == 'release': cargo_cmd.append('--release') +elif command == 'test': + # cargo test + cargo_cmd = ['cargo', 'test', '--no-fail-fast', '--color=always', '--manifest-path', + os.path.join(meson_current_source_dir, 'Cargo.toml'), + '--workspace'] else: print("Unknown command:", command) sys.exit(1) diff --git a/meson.build b/meson.build index 12881cd9..4ba11b22 100644 --- a/meson.build +++ b/meson.build @@ -80,6 +80,8 @@ foreach d: deps endif endforeach +exclude = ','.join(exclude) + # Always build the target so we don't have to list all source files as input rs_plugins = custom_target('gst-plugins-rs', build_by_default: true, @@ -94,10 +96,20 @@ rs_plugins = custom_target('gst-plugins-rs', meson.current_source_dir(), meson.build_root(), target, - ext, - ','.join(exclude)]) + exclude, + ext]) # FIXME: raises a warning as the target has multiple outputs and meson will use # only the first one. All the plugins have the same basedir, hence # GST_PLUGIN_PATH will include them all, so that's ok. plugins = [rs_plugins] + +test('tests', + cargo_wrapper, + args: ['test', + meson.current_build_dir(), + meson.current_source_dir(), + meson.build_root(), + target, + exclude], + timeout: 600)