diff mbox series

[1/4] t/unit-tests: handle dashes in test suite filenames

Message ID 20250116104911.77405-2-kuforiji98@gmail.com (mailing list archive)
State Superseded
Headers show
Series t/unit-tests: convert unit-tests to use clar | expand

Commit Message

Seyi Kuforiji Jan. 16, 2025, 10:49 a.m. UTC
Adapt script to translate dashes (`-`) in test suite filenames to
underscores (`_`) to ensure proper extraction of test function names.
`generate-clar-decls.sh` does not pick up dashes in filenames such as
`u-mem-pool.c`, which prevents the scripts from being run. This will be
used by subsequent commits which follows the same construct.

Mentored-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Seyi Kuforiji <kuforiji98@gmail.com>
---
 t/unit-tests/generate-clar-decls.sh | 1 +
 1 file changed, 1 insertion(+)

Comments

Patrick Steinhardt Jan. 16, 2025, 1:12 p.m. UTC | #1
On Thu, Jan 16, 2025 at 11:49:08AM +0100, Seyi Kuforiji wrote:
> Adapt script to translate dashes (`-`) in test suite filenames to
> underscores (`_`) to ensure proper extraction of test function names.
> `generate-clar-decls.sh` does not pick up dashes in filenames such as
> `u-mem-pool.c`, which prevents the scripts from being run. This will be
> used by subsequent commits which follows the same construct.

Nit: it would be nice to provide a bit more context. What might not be
immediately be obvious is that the script extracts function signatures
that match a specific pattern derived from the unit test file's name,
so pointing that out would likely help.

Also note that "u-mem-pool.c" is not a script, so saying that these are
getting run as scripts is misleading. I'd rather say something like
"which prevents the unit tests declared in those suites from being
executed".

The change itself looks good to me!

Patrick
diff mbox series

Patch

diff --git a/t/unit-tests/generate-clar-decls.sh b/t/unit-tests/generate-clar-decls.sh
index 3b315c64b3..abf6a2ea2a 100755
--- a/t/unit-tests/generate-clar-decls.sh
+++ b/t/unit-tests/generate-clar-decls.sh
@@ -14,6 +14,7 @@  do
 	suite_name=$(basename "$suite")
 	suite_name=${suite_name%.c}
 	suite_name=${suite_name#u-}
+	suite_name=$(echo "$suite_name" | tr '-' '_')
 	sed -ne "s/^\(void test_${suite_name}__[a-zA-Z_0-9][a-zA-Z_0-9]*(void)\)$/extern \1;/p" "$suite" ||
 	exit 1
 done >"$OUTPUT"