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

[PATCH] meson: use test_environment conditionally.

From
Sam James <sam@gentoo.org>
Date
Mar 14, 2025, 18:02 UTC
Message-ID
<310a34bace801d288e369c6a01a8d04ffc4c3c06.1741975367.git.sam@gentoo.org>

test_environment is only defined with -Dtests, so use it conditionally and define a stub environment() instead, to avoid erroring out:

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

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

Do the same for 'netrc' in contrib/ as it uses the same pattern. --- Not sure if we can do better here somehow or not (with a disabler?)

 contrib/credential/netrc/meson.build | 8 ++++++--
 contrib/subtree/meson.build          | 8 ++++++--
 2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/contrib/credential/netrc/meson.build b/contrib/credential/netrc/meson.build
index a990dbb86d..6d815d01c4 100644
--- a/contrib/credential/netrc/meson.build
+++ b/contrib/credential/netrc/meson.build
@@ -7,8 +7,12 @@ 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())
+else
+  credential_netrc_testenv = environment()
+fi
 
 test('t-git-credential-netrc',
   shell,
diff --git a/contrib/subtree/meson.build b/contrib/subtree/meson.build
index 9c72b23625..d18f188216 100644
--- a/contrib/subtree/meson.build
+++ b/contrib/subtree/meson.build
@@ -12,8 +12,12 @@ 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())
+else
+  subtree_test_environment = environment()
+endif
 
 test('t7900-subtree', shell,
   args: [ 't7900-subtree.sh' ],
-- 
2.48.1
Next: Patrick Steinhardt
Message 1 of 2 in “meson: use test_environment conditionally.”
  1. meson: use test_environment conditionally.Sam James, Mar 14, 2025
  2. Patrick SteinhardtMar 19, 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.