meson: add test wrapper

Allow us to run the tests using 'meson test'.

Needed for https://gitlab.freedesktop.org/gstreamer/gst-ci/issues/46
This commit is contained in:
Guillaume Desmottes 2020-01-07 14:06:39 +05:30
parent accd10dfea
commit 28e3e3199c
2 changed files with 22 additions and 4 deletions

View file

@ -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)

View file

@ -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)