Skip to content

Commit 61ff650

Browse files
tristan957hackorum
authored andcommitted
Add pgindent test to check if codebase is correctly formatted
Should be useful for developers and committers to test code as they develop, commit, or prepare patches.
1 parent 3418322 commit 61ff650

4 files changed

Lines changed: 57 additions & 1 deletion

File tree

src/meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ subdir('pl')
1414
subdir('interfaces')
1515

1616
subdir('tools/pg_bsd_indent')
17-
17+
subdir('tools/pgindent')
1818

1919
### Generate a Makefile.global that's complete enough for PGXS to work.
2020
#

src/tools/pgindent/Makefile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#-------------------------------------------------------------------------
2+
#
3+
# src/tools/pgindent/Makefile
4+
#
5+
# Copyright (c) 2024, PostgreSQL Global Development Group
6+
#
7+
#-------------------------------------------------------------------------
8+
9+
subdir = src/tools/pgindent
10+
top_builddir = ../../..
11+
include $(top_builddir)/src/Makefile.global
12+
13+
clean distclean:
14+
rm -rf log/ tmp_check/
15+
16+
# Provide this alternate test name to allow testing pgindent without building
17+
# all of the surrounding Postgres installation.
18+
.PHONY: test
19+
20+
pg_bsd_indent:
21+
$(MAKE) -C ../pg_bsd_indent pg_bsd_indent
22+
23+
test: pg_bsd_indent
24+
$(prove_installcheck)

src/tools/pgindent/meson.build

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
tests += {
2+
'name': 'pgindent',
3+
'sd': meson.current_source_dir(),
4+
'bd': meson.current_build_dir(),
5+
'tap': {
6+
'args': [
7+
pg_bsd_indent.path(),
8+
],
9+
'tests': [
10+
't/001_pgindent.pl',
11+
],
12+
},
13+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Copyright (c) 2024, PostgreSQL Global Development Group
2+
#
3+
# Check that all C code is formatted with pgindent
4+
#
5+
6+
use strict;
7+
use warnings FATAL => 'all';
8+
use Test::More;
9+
use PostgreSQL::Test::Utils qw(command_ok);
10+
11+
if (!$ENV{PG_TEST_EXTRA} || $ENV{PG_TEST_EXTRA} !~ /\bpgindent\b/)
12+
{
13+
plan skip_all => "test pgindent not enabled in PG_TEST_EXTRA";
14+
}
15+
16+
my $pg_bsd_indent = $ARGV[0];
17+
command_ok(["./pgindent", "--indent=$pg_bsd_indent", "--check", "--diff"]);
18+
19+
done_testing();

0 commit comments

Comments
 (0)