From 69d3e316da32091af15e9494239a0e1a9dfd6ba5 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 30 Apr 2023 18:01:18 -0400 Subject: Replace strict option with new meson warning level --- test/meson.build | 115 +++++++++++++++++++++++++++++++------------------------ 1 file changed, 64 insertions(+), 51 deletions(-) (limited to 'test/meson.build') diff --git a/test/meson.build b/test/meson.build index 630fb0d..b6cf111 100644 --- a/test/meson.build +++ b/test/meson.build @@ -5,51 +5,53 @@ # Data # ######## -# Check for spelling errors -codespell = find_program('codespell', required: get_option('tests')) -if codespell.found() - ignore = [ - lv2_source_root / 'doc' / 'style' / 'pygments.css', - lv2_source_root / 'lv2specgen' / 'DTD', - lv2_source_root / 'schemas.lv2' / 'doap.ttl', - ] - - test( - 'codespell', - codespell, - args: [ - '-d', - '-q', '3', - '-S', ','.join(ignore), - lv2_source_root / 'doc', - lv2_source_root / 'lv2', - lv2_source_root / 'lv2specgen', - lv2_source_root / 'plugins', - lv2_source_root / 'schemas.lv2', - ], - suite: 'data', - ) -endif +if get_option('lint') + # Check for spelling errors + codespell = find_program('codespell', required: get_option('tests')) + if codespell.found() + ignore = [ + lv2_source_root / 'doc' / 'style' / 'pygments.css', + lv2_source_root / 'lv2specgen' / 'DTD', + lv2_source_root / 'schemas.lv2' / 'doap.ttl', + ] + + test( + 'codespell', + codespell, + args: [ + '-d', + '-q', '3', + '-S', ','.join(ignore), + lv2_source_root / 'doc', + lv2_source_root / 'lv2', + lv2_source_root / 'lv2specgen', + lv2_source_root / 'plugins', + lv2_source_root / 'schemas.lv2', + ], + suite: 'data', + ) + endif -# Check that specification data is strictly formatted -serdi = find_program('serdi', required: get_option('tests')) -native_build = not meson.is_cross_build() and host_machine.system() != 'windows' -if serdi.found() and native_build - lv2_check_syntax = files(lv2_source_root / 'scripts' / 'lv2_check_syntax.py') + # Check that specification data is strictly formatted + serdi = find_program('serdi', required: get_option('tests')) + native_build = not meson.is_cross_build() and host_machine.system() != 'windows' + if serdi.found() and native_build + lv2_check_syntax = files(lv2_source_root / 'scripts' / 'lv2_check_syntax.py') - test('syntax', - lv2_check_syntax, - args: ['--serdi', serdi.full_path()] + spec_files + schema_data, - suite: 'data') -endif + test('syntax', + lv2_check_syntax, + args: ['--serdi', serdi.full_path()] + spec_files + schema_data, + suite: 'data') + endif -# Check that specification data validates -sord_validate = find_program('sord_validate', required: get_option('tests')) -if sord_validate.found() - test('valid', - sord_validate, - args: spec_files + schema_data, - suite: 'data') + # Check that specification data validates + sord_validate = find_program('sord_validate', required: get_option('tests')) + if sord_validate.found() + test('valid', + sord_validate, + args: spec_files + schema_data, + suite: 'data') + endif endif ######## @@ -82,11 +84,7 @@ endif # Python # ########## -if get_option('strict') - flake8 = find_program('flake8', required: get_option('tests')) - pylint = find_program('pylint', required: get_option('tests')) - black = find_program('black', required: get_option('tests')) - +if get_option('lint') # Scripts that don't pass with pylint lax_python_scripts = files( '../lv2specgen/lv2docgen.py', @@ -98,17 +96,32 @@ if get_option('strict') all_python_scripts = lax_python_scripts + strict_python_scripts - if is_variable('black') and black.found() + # Check script formatting + black = find_program('black', required: get_option('tests')) + if black.found() black_opts = ['-l', '79', '-q', '--check'] test('black', black, args: black_opts + all_python_scripts, suite: 'scripts') endif - if is_variable('flake8') and flake8.found() + # Check scripts for errors with flake8 + flake8 = find_program('flake8', required: get_option('tests')) + if flake8.found() test('flake8', flake8, args: all_python_scripts, suite: 'scripts') endif - if is_variable('pylint') and pylint.found() - test('pylint', pylint, args: strict_python_scripts, suite: 'scripts') + # Check scripts for errors with pylint + pylint = find_program('pylint', required: get_option('tests')) + if pylint.found() + pymod = import('python') + lint_py = pymod.find_installation( + 'python3', + modules: ['pygments', 'rdflib'], + required: false, + ) + + if lint_py.found() + test('pylint', pylint, args: strict_python_scripts, suite: 'scripts') + endif endif endif -- cgit v1.2.1