From 41c87f9cffc2d18bcb5d311ccf8c6e316e820a85 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 2 Apr 2023 15:19:31 -0400 Subject: Only check benchmark.py with pylint if matplotlib is present --- scripts/meson.build | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) (limited to 'scripts') diff --git a/scripts/meson.build b/scripts/meson.build index be6f5e8..604db89 100644 --- a/scripts/meson.build +++ b/scripts/meson.build @@ -2,22 +2,38 @@ # SPDX-License-Identifier: 0BSD OR ISC if get_option('strict') and not meson.is_subproject() - flake8 = find_program('flake8', required: get_option('tests')) - pylint = find_program('pylint', required: get_option('tests')) - black = find_program('black', required: get_option('tests')) + simple_scripts = files('benchmark.py') + plot_scripts = files('plot.py') - all_scripts = files('benchmark.py', 'plot.py') - - if is_variable('black') and black.found() + # Check formatting with black + black = find_program('black', required: get_option('tests')) + if black.found() black_opts = ['-l', '79', '-q', '--check'] test('black', black, args: black_opts + all_scripts, suite: 'scripts') endif - if is_variable('flake8') and flake8.found() + # Check for errors with flake8 + flake8 = find_program('flake8', required: get_option('tests')) + if flake8.found() test('flake8', flake8, args: all_scripts, suite: 'scripts') endif - if is_variable('pylint') and pylint.found() - test('pylint', pylint, args: all_scripts, suite: 'scripts') + # Check for errors with pylint + pylint = find_program('pylint', required: get_option('tests')) + if pylint.found() + pymod = import('python') + plot_py = pymod.find_installation( + 'python3', + modules: ['matplotlib'], + required: false, + ) + + all_scripts = simple_scripts + plot_scripts + lint_scripts = simple_scripts + if plot_py.found() + lint_scripts += plot_scripts + endif + + test('pylint', pylint, args: lint_scripts, suite: 'scripts') endif endif -- cgit v1.2.1