diff options
author | David Robillard <d@drobilla.net> | 2025-01-10 11:38:03 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2025-01-10 11:38:03 -0500 |
commit | 69b8b8b5cf7b3376931edea6e83d93d8dd9287ab (patch) | |
tree | a81c60e3433d903ed7ddb3f919da31bf4bf0851d /test/lint | |
parent | d52a4a17282c6cb1f2c72b3c6994e37e8897e7a9 (diff) | |
download | serd-69b8b8b5cf7b3376931edea6e83d93d8dd9287ab.tar.gz serd-69b8b8b5cf7b3376931edea6e83d93d8dd9287ab.tar.bz2 serd-69b8b8b5cf7b3376931edea6e83d93d8dd9287ab.zip |
This allows for better analysis, and adds a cache to improve checking times,
especially on repeated runs.
Diffstat (limited to 'test/lint')
-rw-r--r-- | test/lint/meson.build | 131 |
1 files changed, 131 insertions, 0 deletions
diff --git a/test/lint/meson.build b/test/lint/meson.build new file mode 100644 index 00000000..b89af7d7 --- /dev/null +++ b/test/lint/meson.build @@ -0,0 +1,131 @@ +# Copyright 2020-2023 David Robillard <d@drobilla.net> +# SPDX-License-Identifier: 0BSD OR ISC + +plot_script_paths = [ + '../../scripts/serd_bench.py', +] + +simple_script_paths = [ + '../../scripts/check_formatting.py', + '../serd_test_util/__init__.py', + '../run_suite.py', + '../test_quiet.py', + '../test_stdin.py', + '../test_write_error.py', +] + +ttl_metadata_file_paths = [ + '../../serd.ttl', + '../extra/abbreviate/manifest.ttl', + '../extra/bad/manifest.ttl', + '../extra/big/manifest.ttl', + '../extra/full/manifest.ttl', + '../extra/good/manifest.ttl', + '../extra/lax/manifest.ttl', + '../extra/perfect/manifest.ttl', + '../extra/prefix/manifest.ttl', + '../extra/pretty/manifest.ttl', + '../extra/qualify/manifest.ttl', + '../extra/root/manifest.ttl', +] + +plot_scripts = files(plot_script_paths) +simple_scripts = files(simple_script_paths) +python_script_paths = simple_script_paths + plot_script_paths +python_scripts = plot_scripts + simple_scripts + +all_sources = sources + unit_test_sources + files('../../src/serdi.c') + +# Check licensing metadata +reuse = find_program('reuse', required: false) +if reuse.found() + test( + 'REUSE', + reuse, + args: ['--root', serd_src_root, 'lint'], + suite: 'data', + ) +endif + +# Check code formatting +clang_format = find_program('clang-format', required: false) +if clang_format.found() + test( + 'format', + clang_format, + args: ['--Werror', '--dry-run'] + c_headers + all_sources, + suite: 'code', + ) +endif + +# Check script formatting +black = find_program('black', required: false) +if black.found() + black_opts = ['--check', '-q', '-l', '79'] + foreach script_path : python_script_paths + script = files(script_path) + name = script_path.substring(3).underscorify() + test(name, black, args: black_opts + [script], suite: 'scripts') + endforeach +endif + +# Check scripts for errors with flake8 +flake8 = find_program('flake8', required: false) +if flake8.found() + test('flake8', flake8, args: python_scripts, suite: 'scripts') +endif + +# Check scripts for errors with pylint +pylint = find_program('pylint', required: false) +if pylint.found() + pymod = import('python') + plot_py = pymod.find_installation( + 'python3', + modules: ['matplotlib'], + required: false, + ) + + pylint_args = ['--disable', 'bad-option-value'] + simple_scripts + if plot_py.found() + pylint_args += plot_scripts + endif + + test('pylint', pylint, args: pylint_args, suite: 'scripts') +endif + +# Check Turtle formatting with serdi +foreach ttl_file_path : ttl_metadata_file_paths + test( + ttl_file_path.substring(3).underscorify(), + check_formatting_py, + args: [files(ttl_file_path), serdi, '-o', 'turtle'], + suite: 'data', + ) +endforeach + +if not meson.is_subproject() + # Check release metadata + autoship = find_program('autoship', required: false) + if autoship.found() + test('autoship', autoship, args: ['test', serd_src_root], suite: 'data') + endif + + # Check code with cppcheck + cppcheck = find_program('cppcheck', required: false) + if cppcheck.found() + compdb_path = join_paths(serd_build_root, 'compile_commands.json') + suppress_path = join_paths(serd_src_root, '.suppress.cppcheck') + test( + 'cppcheck', + cppcheck, + args: [ + '--enable=warning,style,performance,portability', + '--error-exitcode=1', + '--project=' + compdb_path, + '--suppressions-list=' + suppress_path, + '-q', + ], + suite: 'code', + ) + endif +endif |