meson: Fix test failures on the CI around nunit-runner

environment().prepend() does not stack. None of the operations on that
object stack. This is documented in the Meson reference manual. Also
avoid overriding previously-set operations because that will cause
a warning in a future version of Meson.

Also, we do not need to manually construct MONO_PATH values. We can
pass an array and have Meson construct it for us.
This commit is contained in:
Nirbheek Chauhan 2019-04-13 12:13:48 +05:30
parent 3d8806999b
commit 23117379bc
2 changed files with 21 additions and 13 deletions

View file

@ -1,6 +1,10 @@
nunit_console = find_program('nunit-console', 'nunitlite-runner', required: get_option('tests'))
if nunit_console.found()
nunit_tests_env = environment()
# FIXME: port this to macOS and Windows
nunit_tests_env.prepend('LD_LIBRARY_PATH', testsenv_ld_library_path)
nunit_version = '3.10.1'
get_nunit_res = run_command(nuget, 'get',
'--builddir=NUnit',
@ -12,20 +16,27 @@ if nunit_console.found()
)
nunit_mono_path = []
nunit_dep = dependency('mono-nunit', required: false, version: ['>=2.6', '< 2.7'])
if not nunit_dep.found()
if get_nunit_res.returncode() != 0
message('Failed to get NUnit: ' + get_nunit_res.stderr())
else
foreach path: get_nunit_res.stdout().split()
testsenv.prepend('MONO_PATH',
join_paths(meson.build_root(), path.strip('-r:'), '..'))
nunit_mono_path += [join_paths(meson.build_root(), path.strip('-r:'), '..')]
endforeach
nunit_dep = declare_dependency(link_args: get_nunit_res.stdout().split(),
version: nunit_version)
endif
endif
if nunit_mono_path.length() > 0
nunit_tests_env.prepend('MONO_PATH', nunit_mono_path + mono_path)
else
nunit_tests_env.prepend('MONO_PATH', mono_path)
endif
if nunit_dep.found()
foreach test: [
# 'PipelineTests',
@ -34,7 +45,7 @@ if nunit_console.found()
lib = shared_library(test, test + '.cs', 'TestBase.cs',
cs_args: ['-nowarn:169', '-nowarn:108', '-nowarn:114'],
dependencies: [gst_sharp_dep, nunit_dep])
test(test, nunit_console, args: [lib.full_path()], env: testsenv)
test(test, nunit_console, args: [lib.full_path()], env: nunit_tests_env)
endforeach
endif
else

View file

@ -41,13 +41,7 @@ else
required: false)
endif
if host_machine.system() == 'windows'
pathsep = ';'
else
pathsep = ':'
endif
mono_path = gtk_sharp.get_variable('mono_path') + pathsep
mono_path += pathsep + join_paths(meson.current_build_dir(), 'sources')
mono_path = [gtk_sharp.get_variable('mono_path'), join_paths(meson.current_build_dir(), 'sources')]
codegen_dependencies = [gapi_codegen, gapi_fixup, glib_sharp, gio_sharp]
gapi_fixup = gapi_fixup.full_path()
@ -95,15 +89,16 @@ if ges_dep.found()
gst_deps_defs += [
['gst-editing-services', ['gst-editing-services', 'ges_dep'], 'libges'],
]
mono_path += pathsep + join_paths(meson.current_build_dir(), 'ges')
mono_path += [join_paths(meson.current_build_dir(), 'ges')]
endif
testsenv = environment()
testsenv.prepend('MONO_PATH', mono_path)
i = 0
testsenv_ld_library_path = []
foreach dep: gst_deps + [ges_dep]
if dep.type_name() == 'pkgconfig'
testsenv.prepend('LD_LIBRARY_PATH', dep.get_pkgconfig_variable('libdir'))
testsenv_ld_library_path += [dep.get_pkgconfig_variable('libdir')]
else
depdef = gst_deps_defs[i][1]
libname = gst_deps_defs[i].get(2, '')
@ -118,11 +113,13 @@ foreach dep: gst_deps + [ges_dep]
endif
j += 1
endforeach
testsenv.prepend('LD_LIBRARY_PATH', dirname)
testsenv_ld_library_path += [dirname]
endif
endif
i += 1
endforeach
# FIXME: port this to macOS and Windows
testsenv.prepend('LD_LIBRARY_PATH', testsenv_ld_library_path)
subdir('sources')
if ges_dep.found()