Add test to check clang-format

This commit is contained in:
project-repo 2023-02-09 22:40:00 +01:00
commit a222a5a60f
2 changed files with 26 additions and 0 deletions

View file

@ -310,5 +310,6 @@ message('\n'.join(summary))
# Test Suite
test('Clang-format formatting check', find_program('test/clang-format'), args : [ cagebreak_main_file + cagebreak_source_strings + cagebreak_header_strings ], env : [ ''.join('MESONCURRENTCONFIGDIR=', meson.current_source_dir()) ], suite: 'basic')
test('Arguments', find_program('test/arguments'), args : [ meson.project_version() ], env : [ ''.join('MESONCURRENTCONFIGDIR=', meson.current_source_dir()) ], suite: 'basic')
test('Scan-build static analysis', find_program('test/scan-build'), env : [ ''.join('MESONCURRENTCONFIGDIR=', meson.current_source_dir()) ], suite: 'release')

25
test/clang-format Normal file
View file

@ -0,0 +1,25 @@
#! /bin/sh
readonly declared_deps="${@}"
readonly hardcoded_deps="fuzz/execl_override.c fuzz/fuzz-lib.c fuzz/fuzz-lib.h fuzz/fuzz-parse.c"
readonly deps="${declared_deps} ${hardcoded_deps}"
RESULT=0
set -x
echo $MESONCURRENTCONFIGDIR
for file in ${deps}
do
echo "${file}"
if $(clang-format -Werror --dry-run "$MESONCURRENTCONFIGDIR/${file}")
then
echo " [x] clang-format"
else
RESULT=1
echo " [ ] clang-format"
fi
done
exit "${RESULT}"