[1/2] test: py: Replace environment array with environment object
diff mbox series

Message ID 20241105014949.32244-2-laurent.pinchart@ideasonboard.com
State Accepted
Commit b3eba172130d1bbde882ddd0aeb32f1b3c1689ab
Headers show
Series
  • test: py: Fix unit test error with ASan
Related show

Commit Message

Laurent Pinchart Nov. 5, 2024, 1:49 a.m. UTC
The environment for pyunittests is stored in an array. Meson provides an
environment object, which makes handling of multi-value environment
variables easier and increases code clarity. Switch to using the
environment object.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 test/py/meson.build | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Kieran Bingham Nov. 5, 2024, 10:14 a.m. UTC | #1
Quoting Laurent Pinchart (2024-11-05 01:49:48)
> The environment for pyunittests is stored in an array. Meson provides an
> environment object, which makes handling of multi-value environment
> variables easier and increases code clarity. Switch to using the
> environment object.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  test/py/meson.build | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/test/py/meson.build b/test/py/meson.build
> index 0b679d31ff34..481bb481c110 100644
> --- a/test/py/meson.build
> +++ b/test/py/meson.build
> @@ -13,15 +13,19 @@ if asan_runtime_missing
>      subdir_done()
>  endif
>  
> +py_env = environment()
> +
>  pymod = import('python')
>  py3 = pymod.find_installation('python3')
>  
>  pypathdir = meson.project_build_root() / 'src' / 'py'
> -py_env = ['PYTHONPATH=' + pypathdir]
> +py_env.append('PYTHONPATH', pypathdir)
>  
>  if asan_enabled
> +    py_env.append('LD_PRELOAD', asan_runtime)
> +
>      # Disable leak detection as the Python interpreter is full of leaks.
> -    py_env += ['LD_PRELOAD=' + asan_runtime, 'ASAN_OPTIONS=detect_leaks=0']
> +    py_env.append('ASAN_OPTIONS', 'detect_leaks=0')
>  endif

That looks cleaner:


Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

>  
>  test('pyunittests',
> -- 
> Regards,
> 
> Laurent Pinchart
>

Patch
diff mbox series

diff --git a/test/py/meson.build b/test/py/meson.build
index 0b679d31ff34..481bb481c110 100644
--- a/test/py/meson.build
+++ b/test/py/meson.build
@@ -13,15 +13,19 @@  if asan_runtime_missing
     subdir_done()
 endif
 
+py_env = environment()
+
 pymod = import('python')
 py3 = pymod.find_installation('python3')
 
 pypathdir = meson.project_build_root() / 'src' / 'py'
-py_env = ['PYTHONPATH=' + pypathdir]
+py_env.append('PYTHONPATH', pypathdir)
 
 if asan_enabled
+    py_env.append('LD_PRELOAD', asan_runtime)
+
     # Disable leak detection as the Python interpreter is full of leaks.
-    py_env += ['LD_PRELOAD=' + asan_runtime, 'ASAN_OPTIONS=detect_leaks=0']
+    py_env.append('ASAN_OPTIONS', 'detect_leaks=0')
 endif
 
 test('pyunittests',