From a96d07d3610e27abe5fcae72f3b75d639aff57ec Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 6 Oct 2024 13:35:49 -0400 Subject: Add clang-format lint test --- test/headers/meson.build | 4 +++- test/meson.build | 37 +++++++++++++++++++++---------------- 2 files changed, 24 insertions(+), 17 deletions(-) (limited to 'test') diff --git a/test/headers/meson.build b/test/headers/meson.build index 3796d7f..2e18a44 100644 --- a/test/headers/meson.build +++ b/test/headers/meson.build @@ -37,11 +37,13 @@ endif header_c_suppressions = cc.get_supported_arguments(header_c_suppressions) +test_headers_source = files('test_headers.c') + test( 'headers', executable( 'test_headers', - files('test_headers.c'), + test_headers_source, c_args: header_c_suppressions, dependencies: [sratom_dep], ), diff --git a/test/meson.build b/test/meson.build index 75ccc6d..337f26d 100644 --- a/test/meson.build +++ b/test/meson.build @@ -11,29 +11,27 @@ subdir('headers') # Unit Tests # ############## -unit_tests = [ +test_sratom_source = files('test_sratom.c') + +test( 'sratom', -] - -foreach unit : unit_tests - test( - unit, - executable( - 'test_@0@'.format(unit), - files('test_@0@.c'.format(unit)), - c_args: c_suppressions, - dependencies: [sratom_dep, serd_dep, sord_dep], - include_directories: include_directories('../src'), - ), - suite: 'unit', - ) -endforeach + executable( + 'test_sratom', + test_sratom_source, + c_args: c_suppressions, + dependencies: [sratom_dep, serd_dep, sord_dep], + include_directories: include_directories('../src'), + ), + suite: 'unit', +) ######## # Lint # ######## if get_option('lint') + all_sources = sources + test_sratom_source + test_headers_source + if not meson.is_subproject() # Check release metadata autoship = find_program('autoship', required: false) @@ -48,4 +46,11 @@ if get_option('lint') reuse_args = ['--root', sratom_src_root, 'lint'] test('REUSE', reuse, args: reuse_args, suite: 'data') endif + + # Check code formatting + clang_format = find_program('clang-format', required: false) + if clang_format.found() + clang_format_args = ['--Werror', '--dry-run'] + c_headers + all_sources + test('format', clang_format, args: clang_format_args, suite: 'code') + endif endif -- cgit v1.2.1