Skip to content

Commit

Permalink
possibility to execute tests related to major versions by meson
Browse files Browse the repository at this point in the history
  • Loading branch information
okbob committed Nov 29, 2024
1 parent 334fdfd commit c337b49
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 20 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -965,6 +965,13 @@ or compile by self:
1. copy `plpgsql_check.dll` to `PostgreSQL\14\lib`
2. copy `plpgsql_check.control` and `plpgsql_check--2.1.sql` to `PostgreSQL\14\share\extension`

## Meson build

1. `meson setup build`
2. `cd build`
3. `ninja`
4. `sudo ninja install`

## Checked on

* gcc on Linux (against all supported PostgreSQL)
Expand Down
63 changes: 43 additions & 20 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,23 @@ includedir_server = run_command(pg_config, '--includedir-server', check: true).s
pkglibdir = run_command(pg_config, '--pkglibdir', check: true).stdout().strip()
sharedir = run_command(pg_config, '--sharedir', check: true).stdout().strip()

versionstring = run_command(pg_config, '--version', check: true).stdout().strip()
pg_version = versionstring.split(' ')[1]

if pg_version.endswith('devel')
pg_version_arr = [pg_version.split('devel')[0], '0']
elif pg_version.contains('beta')
pg_version_arr = [pg_version.split('beta')[0], '0']
elif pg_version.contains('rc')
pg_version_arr = [pg_version.split('rc')[0], '0']
else
pg_version_arr = pg_version.split('.')
endif

pg_version_major = pg_version_arr[0].to_int()
pg_version_minor = pg_version_arr[1].to_int()
pg_version_num = (pg_version_major * 10000) + pg_version_minor

plpgsql_check_sources = files(
'src/assign.c',
'src/cursors_leaks.c',
Expand All @@ -27,28 +44,34 @@ plpgsql_check_sources = files(
'src/tracer.c',
)

shared_module('plpgsql_check', plpgsql_check_sources,
include_directories: [includedir_server],
install: true,
install_dir: pkglibdir,
name_prefix: '',
)
shared_module(
'plpgsql_check',
plpgsql_check_sources,
include_directories: [includedir_server],
install: true,
install_dir: pkglibdir,
name_prefix: '',
)

install_data('plpgsql_check.control',
'plpgsql_check--2.7.sql',
install_dir: sharedir / 'extension',
)
install_data(
'plpgsql_check.control',
'plpgsql_check--2.7.sql',
install_dir: sharedir / 'extension',
)

pg_regress = find_program('pg_regress',
dirs: [pkglibdir / 'pgxs/src/test/regress']
)
pg_regress = find_program(
'pg_regress',
dirs: [pkglibdir / 'pgxs/src/test/regress']
)

regress_tests = ['plpgsql_check_active', 'plpgsql_check_passive']
regress_tests = ['plpgsql_check_active',
'plpgsql_check_passive',
'plpgsql_check_active-' + pg_version_major.to_string(),
'plpgsql_check_passive-' + pg_version_major.to_string()]

test('regress',
pg_regress,
args: ['--bindir', bindir,
'--inputdir', meson.current_source_dir(),
] + regress_tests,
)

pg_regress,
args: ['--bindir', bindir,
'--inputdir', meson.current_source_dir(),
] + regress_tests,
)

0 comments on commit c337b49

Please sign in to comment.