From 41c3445f41764acffa34cfc2ab10efccd8f0cfeb Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 29 Sep 2024 10:52:48 -0400 Subject: Fix whitespace and add clang-format test --- .clang-format | 4 ++-- include/raul/Semaphore.hpp | 2 +- test/meson.build | 29 +++++++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/.clang-format b/.clang-format index 9b91735..55ba656 100644 --- a/.clang-format +++ b/.clang-format @@ -1,10 +1,10 @@ -# Copyright 2021-2022 David Robillard +# Copyright 2021-2024 David Robillard # SPDX-License-Identifier: 0BSD OR GPL-3.0-or-later --- AlignConsecutiveAssignments: true AlignConsecutiveDeclarations: true -AlignEscapedNewlinesLeft: true +AlignEscapedNewlines: Left BasedOnStyle: Mozilla BraceWrapping: AfterNamespace: false diff --git a/include/raul/Semaphore.hpp b/include/raul/Semaphore.hpp index 75d0a62..c9ce024 100644 --- a/include/raul/Semaphore.hpp +++ b/include/raul/Semaphore.hpp @@ -252,7 +252,7 @@ Semaphore::timed_wait(const std::chrono::duration& wait) const auto now(chr::seconds(time.tv_sec) + chr::nanoseconds(time.tv_nsec)); const auto end(now + wait); - const chr::seconds end_sec(chr::duration_cast(end)); + const chr::seconds end_sec(chr::duration_cast(end)); const chr::nanoseconds end_nsec(end - end_sec); const timespec ts_end = {static_cast(end_sec.count()), diff --git a/test/meson.build b/test/meson.build index e319a9d..599e53e 100644 --- a/test/meson.build +++ b/test/meson.build @@ -1,6 +1,24 @@ # Copyright 2019-2022 David Robillard # SPDX-License-Identifier: 0BSD OR GPL-3.0-or-later +######## +# Lint # +######## + +test_sources = files( + 'headers/test_headers.cpp', + 'array_test.cpp', + 'build_test.cpp', + 'double_buffer_test.cpp', + 'maid_test.cpp', + 'path_test.cpp', + 'ringbuffer_test.cpp', + 'sem_test.cpp', + 'socket_test.cpp', + 'symbol_test.cpp', + 'thread_test.cpp', +) + if get_option('lint') if not meson.is_subproject() # Check release metadata @@ -25,6 +43,17 @@ if get_option('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'] + headers + test_sources, + suite: 'code', + ) + endif endif ################### -- cgit v1.2.1