git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 4/8] meson: detect missing tests at configure time

From
Toon Claes <toon@iotcl.com>
Date
Dec 13, 2024, 09:58 UTC
Message-ID
<87bjxfj44o.fsf@iotcl.com>
In-Reply-To
<20241211-pks-meson-ci-v1-4-28d18b494374@pks.im>
Patrick Steinhardt <ps@pks.im> writes:
Show 39 quoted lines
> It is quite easy for the list of integration tests to go out-of-sync
> without anybody noticing. Introduce a new configure-time check that
> verifies that all tests are wired up properly.
>
> Signed-off-by: Patrick Steinhardt <ps@pks.im>
> ---
>  t/meson.build | 36 ++++++++++++++++++++++++++++++++++++
>  1 file changed, 36 insertions(+)
>
> diff --git a/t/meson.build b/t/meson.build
> index 9e676e69363ed6311426500d98fe281e30d26bcb..f1fbc6ae179079f4d5d86f9a60956fad84d0495c 100644
> --- a/t/meson.build
> +++ b/t/meson.build
> @@ -1092,6 +1092,42 @@ integration_tests = [
>    't9903-bash-prompt.sh',
>  ]
>  
> +# Sanity check that we are not missing any tests present in 't/'. This check
> +# only runs once at configure time and is thus best-effort, only. It is
> +# sufficient to catch missing test suites in our CI though.
> +foreach glob, tests : {
> +  't[0-9][0-9][0-9][0-9]-*.sh': integration_tests,
> +  'unit-tests/t-*.c': unit_test_programs,
> +  'unit-tests/u-*.c': clar_test_suites,
> +}
> +  actual_tests = run_command(shell, '-c', 'ls ' + glob,
> +    check: true,
> +    env: script_environment,
> +  ).stdout().strip().split('\n')
> +
> +  if tests != actual_tests
> +    missing_tests = [ ]
> +    foreach actual_test : actual_tests
> +      if actual_test not in tests
> +        missing_tests += actual_test
> +      endif
> +    endforeach
> +    if missing_tests.length() > 0
> +      error('Missing tests:\n\n - ' + '\n - '.join(missing_tests))
This gives nice output:
    $ touch t/unit-tests/u-bar.c t/unit-tests/u-foo.c
    $ meson setup builddir --reconfigure
    The Meson build system
    Version: 1.4.1
    [snip]
    Configuring update.sample using configuration
    Configuring exclude using configuration
    t/meson.build:1116:6: ERROR: Problem encountered: Missing tests:
     - unit-tests/u-bar.c
     - unit-tests/u-foo.c
    A full log can be found at git/builddir/meson-logs/meson-log.txt

But I think the error message is a little bit confusing. It sounds like the test file is missing, but it's the configuration of the test that is missing.

Now I've realized it hard to write a good error message here. But I would suggest something like "Tests files found, but not configured".

Show 10 quoted lines
> +    endif
> +
> +    superfluous_tests = [ ]
> +    foreach integration_test : tests
> +      if integration_test not in actual_tests
> +        superfluous_tests += integration_test
> +      endif
> +    endforeach
> +    if superfluous_tests.length() > 0
> +      error('Superfluous tests:\n\n - ' + '\n - '.join(superfluous_tests))

Also here I would suggest different error message, maybe something like "Tests configured, but file not found"

-- 
Toon
Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 7 of 36 in “ci: wire up support for Meson”
  1. 0/8 ci: wire up support for MesonPatrick Steinhardt, Dec 11, 2024
  2. 1/8 ci/lib: support custom output directories when creating test artifactsPatrick Steinhardt, Dec 11, 2024
  3. karthik nayakDec 12, 2024
  4. Patrick SteinhardtDec 13, 2024
  5. 2/8 Makefile: drop -DSUPPRESS_ANNOTATED_LEAKSPatrick Steinhardt, Dec 11, 2024
  6. 4/8 meson: detect missing tests at configure timePatrick Steinhardt, Dec 11, 2024
  7. Toon ClaesDec 13, 2024
  8. Patrick SteinhardtDec 13, 2024
  9. 3/8 t/unit-tests: rename clar-based unit tests to have a common prefixPatrick Steinhardt, Dec 11, 2024
  10. karthik nayakDec 12, 2024
  11. Patrick SteinhardtDec 13, 2024
  12. 5/8 Makefile: detect missing Meson testsPatrick Steinhardt, Dec 11, 2024
  13. 6/8 t: fix out-of-tree tests for some git-p4 testsPatrick Steinhardt, Dec 11, 2024
  14. karthik nayakDec 12, 2024
  15. Patrick SteinhardtDec 13, 2024
  16. Toon ClaesDec 13, 2024
  17. Patrick SteinhardtDec 13, 2024
  18. 7/8 t: introduce compatibility options to clar-based testsPatrick Steinhardt, Dec 11, 2024
  19. Toon ClaesDec 13, 2024
  20. 8/8 ci: wire up Meson buildsPatrick Steinhardt, Dec 11, 2024
  21. Toon ClaesDec 13, 2024
  22. Patrick SteinhardtDec 13, 2024
  23. 0/8 ci: wire up support for MesonPatrick Steinhardt, Dec 13, 2024
  24. 1/8 ci/lib: support custom output directories when creating test artifactsPatrick Steinhardt, Dec 13, 2024
  25. 2/8 Makefile: drop -DSUPPRESS_ANNOTATED_LEAKSPatrick Steinhardt, Dec 13, 2024
  26. 3/8 t/unit-tests: rename clar-based unit tests to have a common prefixPatrick Steinhardt, Dec 13, 2024
  27. 4/8 meson: detect missing tests at configure timePatrick Steinhardt, Dec 13, 2024
  28. 5/8 Makefile: detect missing Meson testsPatrick Steinhardt, Dec 13, 2024
  29. 6/8 t: fix out-of-tree tests for some git-p4 testsPatrick Steinhardt, Dec 13, 2024
  30. 7/8 t: introduce compatibility options to clar-based testsPatrick Steinhardt, Dec 13, 2024
  31. Junio C HamanoDec 13, 2024
  32. 8/8 ci: wire up Meson buildsPatrick Steinhardt, Dec 13, 2024
  33. ci: allow github-actions print test failures againJunio C Hamano, Jul 16, 2025
  34. Patrick SteinhardtJul 17, 2025
  35. Toon ClaesDec 16, 2024
  36. Junio C HamanoDec 16, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.