diff options
Diffstat (limited to 'test/meson.build')
-rw-r--r-- | test/meson.build | 196 |
1 files changed, 115 insertions, 81 deletions
diff --git a/test/meson.build b/test/meson.build index e6178dc..4790a48 100644 --- a/test/meson.build +++ b/test/meson.build @@ -1,55 +1,65 @@ # Copyright 2022 David Robillard <d@drobilla.net> -# SPDX-License-Identifier: CC0-1.0 OR ISC +# SPDX-License-Identifier: 0BSD OR ISC ######## # 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', - ] +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 + 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'), + version: '>= 0.31.5', + ) + 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 ######## @@ -57,36 +67,36 @@ endif ######## # Check that all the headers compile cleanly in C -test('c', - executable( - 'test_build_c', - files('test_build.c'), - c_args: c_suppressions, - dependencies: lv2_dep, - ), - suite: 'build') +test( + 'c', + executable( + 'test_build_c', + files('test_build.c'), + c_args: c_suppressions, + dependencies: [lv2_dep], + ), + suite: 'build', +) # Check that all the headers compile cleanly in C++ if is_variable('cpp') - test('cpp', - executable( - 'test_build_cpp', - files('test_build.cpp'), - cpp_args: cpp_suppressions, - dependencies: lv2_dep, - ), - suite: 'build') + test( + 'cpp', + executable( + 'test_build_cpp', + files('cpp/test_build.cpp'), + cpp_args: cpp_suppressions, + dependencies: [lv2_dep], + ), + suite: 'build', + ) 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,20 +108,46 @@ 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') + 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 +################### +# Header Warnings # +################### + +subdir('headers') + ############## # Unit Tests # ############## @@ -122,17 +158,15 @@ test_names = [ ] # Build and run tests -if not get_option('tests').disabled() - foreach test_name : test_names - test( +foreach test_name : test_names + test( + test_name, + executable( test_name, - executable( - test_name, - files('test_@0@.c'.format(test_name)), - c_args: c_suppressions, - dependencies: lv2_dep, - ), - suite: 'unit', - ) - endforeach -endif + files('test_@0@.c'.format(test_name)), + c_args: c_suppressions, + dependencies: [lv2_dep], + ), + suite: 'unit', + ) +endforeach |