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 subprocess
import sys import sys
command, meson_build_dir, meson_current_source_dir, meson_build_root, target, ext, exclude = sys.argv[ command, meson_build_dir, meson_current_source_dir, meson_build_root, target, exclude = sys.argv[
1:] 1:7]
cargo_target_dir = os.path.join(meson_build_dir, 'target') 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': if command == 'build':
# cargo build # cargo build
ext = sys.argv[7]
cargo_cmd = ['cargo', 'build', '--manifest-path', cargo_cmd = ['cargo', 'build', '--manifest-path',
os.path.join(meson_current_source_dir, 'Cargo.toml'), os.path.join(meson_current_source_dir, 'Cargo.toml'),
'--workspace'] '--workspace']
if target == 'release': if target == 'release':
cargo_cmd.append('--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: else:
print("Unknown command:", command) print("Unknown command:", command)
sys.exit(1) sys.exit(1)

View file

@ -80,6 +80,8 @@ foreach d: deps
endif endif
endforeach endforeach
exclude = ','.join(exclude)
# Always build the target so we don't have to list all source files as input # Always build the target so we don't have to list all source files as input
rs_plugins = custom_target('gst-plugins-rs', rs_plugins = custom_target('gst-plugins-rs',
build_by_default: true, build_by_default: true,
@ -94,10 +96,20 @@ rs_plugins = custom_target('gst-plugins-rs',
meson.current_source_dir(), meson.current_source_dir(),
meson.build_root(), meson.build_root(),
target, target,
ext, exclude,
','.join(exclude)]) ext])
# FIXME: raises a warning as the target has multiple outputs and meson will use # 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 # only the first one. All the plugins have the same basedir, hence
# GST_PLUGIN_PATH will include them all, so that's ok. # GST_PLUGIN_PATH will include them all, so that's ok.
plugins = [rs_plugins] plugins = [rs_plugins]
test('tests',
cargo_wrapper,
args: ['test',
meson.current_build_dir(),
meson.current_source_dir(),
meson.build_root(),
target,
exclude],
timeout: 600)