[libgweather/ebassi/test-style-format: 1/4] tests: Add coding style check




commit 48a2912cb9d7381bda4eadf439de43adb6700fdd
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Mon Jan 17 11:22:52 2022 +0000

    tests: Add coding style check
    
    Since we're going to run it on our CI pipeline, we might as well do this
    in the test suite. This should allow people to catch coding style issues
    before opening a merge request. And by "people" I really mean "me".

 libgweather/meson.build | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)
---
diff --git a/libgweather/meson.build b/libgweather/meson.build
index b5d0b4d4..f573d452 100644
--- a/libgweather/meson.build
+++ b/libgweather/meson.build
@@ -150,7 +150,6 @@ gweather_enum_types = gnome.mkenums('gweather-enum-types',
 install_headers(gweather_headers + ['gweather.h'], subdir: header_subdir)
 
 gweather_c_sources = [
-  gweather_enum_types,
   'gweather.c',
   'gweather-info.c',
   'gweather-location.c',
@@ -166,10 +165,15 @@ gweather_priv_sources = [
   'weather-moon.c',
 ]
 
-introspection_sources = gweather_c_sources + gweather_headers
+introspection_sources = [
+  gweather_enum_types,
+  gweather_c_sources,
+  gweather_headers,
+]
 
 libgweather_static = static_library('gweather',
   sources: [
+    gweather_enum_types,
     gweather_c_sources,
     gweather_priv_sources,
   ],
@@ -180,7 +184,8 @@ libgweather_static = static_library('gweather',
   ],
 )
 
-libgweather_static_dep = declare_dependency(sources: gweather_c_sources,
+libgweather_static_dep = declare_dependency(
+  sources: gweather_enum_types,
   include_directories: [
     include_directories('.'),
     include_directories('..'),
@@ -277,4 +282,13 @@ pkgconfig.generate(
 if get_option('tests')
   subdir('tests')
   subdir('tools')
+
+  clang_format = find_program('clang-format', required: false)
+  if clang_format.found()
+    test('style-format', clang_format,
+      args: ['--dry-run', '--Werror', gweather_c_sources],
+      workdir: meson.current_source_dir(),
+      suite: ['lint'],
+    )
+  endif
 endif


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]