I have noticed that under meson many tests don't have dependencies on the build artifacts that they are testing. As an example among many, if you make a source code change in contrib/cube/cube.c (see patch 0001 for a demo) and then run

    make -C contrib/cube check

the test run will reflect the changed code, because the "check" targets typically depend on the "all" targets. But if you do this under meson with

    meson test -C build --suite setup --suite cube

the code will not be rebuilt first, and the test run will not reflect the changed code.

This seems straightforward to fix, see patch 0002. The meson test setup has support for this, but it seems not widely used.

Patch 0003 is another example, this time for a TAP-style test.

Is there any reason this was not done yet?
From 079a7f902177f5e146c004fb7789c9972c86c5ae Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <pe...@eisentraut.org>
Date: Mon, 2 Dec 2024 10:48:37 +0100
Subject: [PATCH v0 1/3] XXX source code modification for test demonstration

---
 contrib/cube/cube.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/contrib/cube/cube.c b/contrib/cube/cube.c
index 1fc447511a1..e3ad25a2a39 100644
--- a/contrib/cube/cube.c
+++ b/contrib/cube/cube.c
@@ -278,7 +278,7 @@ cube_subset(PG_FUNCTION_ARGS)
                if ((dx[i] <= 0) || (dx[i] > DIM(c)))
                        ereport(ERROR,
                                        (errcode(ERRCODE_ARRAY_ELEMENT_ERROR),
-                                        errmsg("Index out of bounds")));
+                                        errmsg("Index out of bounds XXX")));
                result->x[i] = c->x[dx[i] - 1];
                if (!IS_POINT(c))
                        result->x[i + dim] = c->x[dx[i] + DIM(c) - 1];
-- 
2.47.1

From 00b367c86dd14840d8412259f098f09737e73205 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <pe...@eisentraut.org>
Date: Mon, 2 Dec 2024 10:48:37 +0100
Subject: [PATCH v0 2/3] Add test dependency

---
 contrib/cube/meson.build | 1 +
 1 file changed, 1 insertion(+)

diff --git a/contrib/cube/meson.build b/contrib/cube/meson.build
index 21b6f9c43ad..64ba300495d 100644
--- a/contrib/cube/meson.build
+++ b/contrib/cube/meson.build
@@ -53,6 +53,7 @@ tests += {
   'sd': meson.current_source_dir(),
   'bd': meson.current_build_dir(),
   'regress': {
+    'deps': [cube],
     'sql': [
       'cube',
       'cube_sci',
-- 
2.47.1

From 176dc1eb383305025a3de6a895825de36f197678 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <pe...@eisentraut.org>
Date: Mon, 2 Dec 2024 10:48:37 +0100
Subject: [PATCH v0 3/3] Add test dependency for TAP module

---
 src/test/modules/test_json_parser/meson.build | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/test/modules/test_json_parser/meson.build 
b/src/test/modules/test_json_parser/meson.build
index 059a8b71bde..f5a8ea44eed 100644
--- a/src/test/modules/test_json_parser/meson.build
+++ b/src/test/modules/test_json_parser/meson.build
@@ -61,5 +61,8 @@ tests += {
       't/003_test_semantic.pl',
       't/004_test_parser_perf.pl'
     ],
+    'test_kwargs': {
+      'depends': [test_json_parser_incremental, test_json_parser_perf],
+    },
   },
 }
-- 
2.47.1

Reply via email to