From ede25c5d2e6af05fdecd9a7c39a5c77d6d9c5764 Mon Sep 17 00:00:00 2001 From: Heikki Linnakangas Date: Mon, 14 Jul 2025 21:22:19 +0300 Subject: [PATCH] Fix code coverage build --- .../communicator/src/worker_process/callbacks.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/pgxn/neon/communicator/src/worker_process/callbacks.rs b/pgxn/neon/communicator/src/worker_process/callbacks.rs index 6af3fa7afe..86c69508e5 100644 --- a/pgxn/neon/communicator/src/worker_process/callbacks.rs +++ b/pgxn/neon/communicator/src/worker_process/callbacks.rs @@ -4,12 +4,25 @@ //! These are called from the communicator threads! Careful what you do, most Postgres functions are //! not safe to call in that context. +#[cfg(not(test))] unsafe extern "C" { pub fn callback_set_my_latch_unsafe(); - pub fn callback_get_lfc_metrics_unsafe() -> LfcMetrics; } +// Compile unit tests with dummy versions of the functions. Unit tests +// cannot call back into the C code. (As of this writing, no unit tests +// even exists in the communicator package, but the code coverage build +// still builds these and tries to link with the external C code.) +#[cfg(test)] +unsafe fn callback_set_my_latch_unsafe() { + panic!("not usable in unit tests"); +} +#[cfg(test)] +unsafe fn callback_get_lfc_metrics_unsafe() -> LfcMetrics { + panic!("not usable in unit tests"); +} + // safe wrappers pub(super) fn callback_set_my_latch() {