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')) nunit_console = find_program('nunit-console', 'nunitlite-runner', required: get_option('tests'))
if nunit_console.found() 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' nunit_version = '3.10.1'
get_nunit_res = run_command(nuget, 'get', get_nunit_res = run_command(nuget, 'get',
'--builddir=NUnit', '--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']) nunit_dep = dependency('mono-nunit', required: false, version: ['>=2.6', '< 2.7'])
if not nunit_dep.found() if not nunit_dep.found()
if get_nunit_res.returncode() != 0 if get_nunit_res.returncode() != 0
message('Failed to get NUnit: ' + get_nunit_res.stderr()) message('Failed to get NUnit: ' + get_nunit_res.stderr())
else else
foreach path: get_nunit_res.stdout().split() foreach path: get_nunit_res.stdout().split()
testsenv.prepend('MONO_PATH', nunit_mono_path += [join_paths(meson.build_root(), path.strip('-r:'), '..')]
join_paths(meson.build_root(), path.strip('-r:'), '..'))
endforeach endforeach
nunit_dep = declare_dependency(link_args: get_nunit_res.stdout().split(), nunit_dep = declare_dependency(link_args: get_nunit_res.stdout().split(),
version: nunit_version) version: nunit_version)
endif endif
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() if nunit_dep.found()
foreach test: [ foreach test: [
# 'PipelineTests', # 'PipelineTests',
@ -34,7 +45,7 @@ if nunit_console.found()
lib = shared_library(test, test + '.cs', 'TestBase.cs', lib = shared_library(test, test + '.cs', 'TestBase.cs',
cs_args: ['-nowarn:169', '-nowarn:108', '-nowarn:114'], cs_args: ['-nowarn:169', '-nowarn:108', '-nowarn:114'],
dependencies: [gst_sharp_dep, nunit_dep]) 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 endforeach
endif endif
else else

View file

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