From 6688a89700af997b5adaa55f349c8db53a86290b Mon Sep 17 00:00:00 2001 From: Andres Freund Date: Wed, 18 Oct 2023 17:51:21 -0700 Subject: [PATCH v3 3/3] WIP: meson: nitpick mode + test checking indentation Author: Reviewed-by: Discussion: https://postgr.es/m/ Backpatch: --- meson.build | 17 +++++++++++++++-- meson_options.txt | 3 +++ .cirrus.tasks.yml | 1 + 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/meson.build b/meson.build index 70f6b680c2c..86a5d0995a1 100644 --- a/meson.build +++ b/meson.build @@ -44,6 +44,7 @@ cc = meson.get_compiler('c') not_found_dep = dependency('', required: false) thread_dep = dependency('threads') auto_features = get_option('auto_features') +nitpick_mode = get_option('nitpick') @@ -3025,9 +3026,10 @@ run_target('install-test-files', # use a combination of a locally built and the source tree's typededefs.list # file (see src/tools/pgindent/meson.build) for reindenting. That ensures # newly added typedefs are indented correctly. -indent_base_cmd = [perl, files('src/tools/pgindent/pgindent'), +indent_base_args = [files('src/tools/pgindent/pgindent'), '--indent', pg_bsd_indent.full_path(), - '--sourcetree=@SOURCE_ROOT@'] + '--sourcetree=@0@'.format(meson.current_source_dir())] +indent_base_cmd = [perl, indent_base_args] indent_depend = [pg_bsd_indent] if typedefs_supported @@ -3364,6 +3366,17 @@ if meson.version().version_compare('>=0.57') endif +# If we were asked to be nitpicky, add a test that fails if sources aren't +# properly indented +if nitpick_mode + test('indent-check', + perl, args: [indent_base_args, '--silent-diff', '.'], + depends: indent_depend, + suite: 'source', + priority: 10) +endif + + ############################################################### # Pseudo targets diff --git a/meson_options.txt b/meson_options.txt index d2f95cfec36..90cb2177a44 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -52,6 +52,9 @@ option('atomics', type: 'boolean', value: true, option('spinlocks', type: 'boolean', value: true, description: 'Use spinlocks') +option('nitpick', type: 'boolean', value: false, + description: 'annoy the hell out of you, committers ought to enable this') + # Compilation options diff --git a/.cirrus.tasks.yml b/.cirrus.tasks.yml index e137769850d..5dd29bed4cb 100644 --- a/.cirrus.tasks.yml +++ b/.cirrus.tasks.yml @@ -358,6 +358,7 @@ task: meson setup \ --buildtype=debug \ -Dcassert=true \ + -Dnitpick=true \ ${LINUX_MESON_FEATURES} \ -DPG_TEST_EXTRA="$PG_TEST_EXTRA" \ build -- 2.38.0