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

[PATCH v2 3/5] meson: respect 'tests' build option in contrib

From
Patrick Steinhardt <ps@pks.im>
Date
Mar 31, 2025, 08:33 UTC
Message-ID
<20250331-b4-pks-collect-build-fixes-v2-3-6b06136808f3@pks.im>
In-Reply-To
<20250331-b4-pks-collect-build-fixes-v2-0-6b06136808f3@pks.im>

Both the "netrc" credential helper and git-subtree(1) from "contrib/" carry a couple of tests with them. These tests get wired up in Meson unconditionally even in the case where `-Dtests=false`. As those tests depend on the `test_enviroment` variable, which only gets defined in case `-Dtests=true`, the result is an error:

``` $ meson setup -Dtests=false -Dcontrib=subtree build [...]

contrib/subtree/meson.build:15:27: ERROR: Unknown variable "test_environment". ```

Fix the issue by not defining these tests at all in case the "tests" option is set to `false`.

Reported-by: Sam James <sam@gentoo.org>
Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 contrib/credential/netrc/meson.build | 22 ++++++++++++----------
 contrib/subtree/meson.build          | 20 +++++++++++---------
 2 files changed, 23 insertions(+), 19 deletions(-)
diff --git a/contrib/credential/netrc/meson.build b/contrib/credential/netrc/meson.build
index a990dbb86da..3d74547c8ae 100644
--- a/contrib/credential/netrc/meson.build
+++ b/contrib/credential/netrc/meson.build
@@ -7,14 +7,16 @@ credential_netrc = custom_target(
   install_dir: get_option('libexecdir') / 'git-core',
 )
 
-credential_netrc_testenv = test_environment
-credential_netrc_testenv.set('CREDENTIAL_NETRC_PATH', credential_netrc.full_path())
+if get_option('tests')
+  credential_netrc_testenv = test_environment
+  credential_netrc_testenv.set('CREDENTIAL_NETRC_PATH', credential_netrc.full_path())
 
-test('t-git-credential-netrc',
-  shell,
-  args: [ meson.current_source_dir() / 't-git-credential-netrc.sh' ],
-  workdir: meson.current_source_dir(),
-  env: credential_netrc_testenv,
-  depends: test_dependencies + bin_wrappers + [credential_netrc],
-  timeout: 0,
-)
+  test('t-git-credential-netrc',
+    shell,
+    args: [ meson.current_source_dir() / 't-git-credential-netrc.sh' ],
+    workdir: meson.current_source_dir(),
+    env: credential_netrc_testenv,
+    depends: test_dependencies + bin_wrappers + [credential_netrc],
+    timeout: 0,
+  )
+endif
diff --git a/contrib/subtree/meson.build b/contrib/subtree/meson.build
index 9c72b236259..63714166a61 100644
--- a/contrib/subtree/meson.build
+++ b/contrib/subtree/meson.build
@@ -12,16 +12,18 @@ git_subtree = custom_target(
   install_dir: get_option('libexecdir') / 'git-core',
 )
 
-subtree_test_environment = test_environment
-subtree_test_environment.prepend('PATH', meson.current_build_dir())
+if get_option('tests')
+  subtree_test_environment = test_environment
+  subtree_test_environment.prepend('PATH', meson.current_build_dir())
 
-test('t7900-subtree', shell,
-  args: [ 't7900-subtree.sh' ],
-  env: subtree_test_environment,
-  workdir: meson.current_source_dir() / 't',
-  depends: test_dependencies + bin_wrappers + [ git_subtree ],
-  timeout: 0,
-)
+  test('t7900-subtree', shell,
+    args: [ 't7900-subtree.sh' ],
+    env: subtree_test_environment,
+    workdir: meson.current_source_dir() / 't',
+    depends: test_dependencies + bin_wrappers + [ git_subtree ],
+    timeout: 0,
+  )
+endif
 
 if get_option('docs').contains('man')
   subtree_xml = custom_target(
-- 
2.49.0.604.gff1f9ca942.dirty
Previous: Toon ClaesNext: Johannes Schindelin
Message 16 of 22 in “Collection of build fixes”
  1. 0/4 Collection of build fixesPatrick Steinhardt, Mar 28, 2025
  2. 1/4 meson: fix handling of '-Dcurl=auto'Patrick Steinhardt, Mar 28, 2025
  3. 2/4 gitweb: fix generation of "gitweb.js"Patrick Steinhardt, Mar 28, 2025
  4. 3/4 meson: require Perl when building docsPatrick Steinhardt, Mar 28, 2025
  5. Junio C HamanoMar 29, 2025
  6. Patrick SteinhardtMar 31, 2025
  7. 4/4 meson: respect 'tests' build option in contribPatrick Steinhardt, Mar 28, 2025
  8. Sam JamesMar 28, 2025
  9. 0/5 Collection of build fixesPatrick Steinhardt, Mar 31, 2025
  10. 1/5 meson: fix handling of '-Dcurl=auto'Patrick Steinhardt, Mar 31, 2025
  11. Karthik NayakApr 3, 2025
  12. 2/5 gitweb: fix generation of "gitweb.js"Patrick Steinhardt, Mar 31, 2025
  13. Johannes SchindelinApr 1, 2025
  14. Patrick SteinhardtApr 2, 2025
  15. Toon ClaesApr 1, 2025
  16. 3/5 meson: respect 'tests' build option in contribPatrick Steinhardt, Mar 31, 2025
  17. Johannes SchindelinApr 1, 2025
  18. 5/5 ci: use Visual Studio for win+meson job on GitHub WorkflowsPatrick Steinhardt, Mar 31, 2025
  19. 4/5 meson: distinguish build and target host binariesPatrick Steinhardt, Mar 31, 2025
  20. Karthik NayakApr 3, 2025
  21. Johannes SchindelinApr 1, 2025
  22. Karthik NayakApr 3, 2025

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.