diff mbox series

[06/12] meson: wire up credential helpers

Message ID 20250218-b4-pks-meson-contrib-v1-6-c3edd292beb8@pks.im (mailing list archive)
State Superseded
Headers show
Series meson: wire up bits and pieces from "contrib/" | expand

Commit Message

Patrick Steinhardt Feb. 18, 2025, 7:45 a.m. UTC
We've got a couple of credential helpers in "contrib/credential", all
of which aren't yet wired up via Meson. Do so.

Note that ideally, we'd also wire up t0303 to be executed with each of
the credential helpers to verify their functionality. Unfortunately
though, none of them pass the test suite right now, so this is left for
a future change.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 contrib/credential/libsecret/meson.build   |  9 +++++++++
 contrib/credential/meson.build             |  3 +++
 contrib/credential/netrc/meson.build       | 20 ++++++++++++++++++++
 contrib/credential/osxkeychain/meson.build |  9 +++++++++
 contrib/credential/wincred/meson.build     |  5 +++++
 contrib/meson.build                        |  2 ++
 meson.build                                |  2 +-
 meson_options.txt                          |  2 ++
 8 files changed, 51 insertions(+), 1 deletion(-)

Comments

M Hickford Feb. 18, 2025, 10:11 a.m. UTC | #1
> Note that ideally, we'd also wire up t0303 to be executed with each of
> the credential helpers to verify their functionality. Unfortunately
> though, none of them pass the test suite right now, so this is left for
> a future change.

Out of curiosity, which tests failed?
Patrick Steinhardt Feb. 18, 2025, 11:13 a.m. UTC | #2
On Tue, Feb 18, 2025 at 10:11:23AM +0000, M Hickford wrote:
> > Note that ideally, we'd also wire up t0303 to be executed with each of
> > the credential helpers to verify their functionality. Unfortunately
> > though, none of them pass the test suite right now, so this is left for
> > a future change.
> 
> Out of curiosity, which tests failed?

Basically all of them. I originally had the patch at the bottom of this
email. With that in place, we re-run t0303 for every configured
credential helper, where `GIT_TEST_CREDENTIAL_HELPER` is set to the
respective credential helper under test. We have to disable parallel
tests there because the test state directories would otherwise conflict
with one another.

Now you can for example:

    $ meson setup build -Dcredential_helpers=libsecret,netrc
    $ meson test -C build t0303-*

And that shows failures like:

    --- expect-stderr	2025-02-18 11:09:33.323668205 +0000
    +++ stderr	2025-02-18 11:09:33.347668278 +0000
    @@ -1,2 +1,4 @@
    +
    +** (process:75536): CRITICAL **: 11:09:33.339: lookup failed: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.secrets was not provided by any .service files
     askpass: Username for 'https://example.com':
     askpass: Password for 'https://askpass-username@example.com':
    error: last command exited with $?=1
    not ok 1 - helper (/home/pks/Development/git/build/contrib/credential/libsecret/git-credential-libsecret) has no existing data

I might be missing how exactly to set all of this up so that things
actually work. Maybe I have to do something specific for each of the
helpers via `GIT_TEST_CREDENTIAL_HELPER_SETUP`. But t0303 isn't wired up
via our Makefiles for any of the helpers, as far as I can see, so I'm
unable to figure out what such a setup would look like.

Any hints would be welcome.

Patrick

--- >8 ---

diff --git a/contrib/credential/libsecret/meson.build b/contrib/credential/libsecret/meson.build
index 0137660fe02..cb5f7280823 100644
--- a/contrib/credential/libsecret/meson.build
+++ b/contrib/credential/libsecret/meson.build
@@ -1,4 +1,4 @@
-executable('git-credential-libsecret',
+credential_helpers += executable('git-credential-libsecret',
   sources: 'git-credential-libsecret.c',
   dependencies: [
     dependency('glib-2.0'),
diff --git a/contrib/credential/meson.build b/contrib/credential/meson.build
index 4216296ae05..f04525b728e 100644
--- a/contrib/credential/meson.build
+++ b/contrib/credential/meson.build
@@ -1,3 +1,20 @@
+credential_helpers = []
+
 foreach helper : get_option('credential_helpers')
   subdir(helper)
 endforeach
+
+foreach helper : credential_helpers
+  helper_test_environment = test_environment
+  helper_test_environment.set('GIT_TEST_CREDENTIAL_HELPER', helper.full_path())
+
+  test('t0303-credential-external-' + fs.stem(helper.full_path()),
+    shell,
+    args: [ meson.project_source_root() / 't/t0303-credential-external.sh' ],
+    workdir: meson.project_source_root() / 't',
+    env: helper_test_environment,
+    depends: test_dependencies + bin_wrappers + helper,
+    timeout: 0,
+    is_parallel: false,
+  )
+endforeach
diff --git a/contrib/credential/netrc/meson.build b/contrib/credential/netrc/meson.build
index a990dbb86da..110eac8f2f8 100644
--- a/contrib/credential/netrc/meson.build
+++ b/contrib/credential/netrc/meson.build
@@ -6,6 +6,7 @@ credential_netrc = custom_target(
   install: true,
   install_dir: get_option('libexecdir') / 'git-core',
 )
+credential_helpers += credential_netrc
 
 credential_netrc_testenv = test_environment
 credential_netrc_testenv.set('CREDENTIAL_NETRC_PATH', credential_netrc.full_path())
diff --git a/contrib/credential/osxkeychain/meson.build b/contrib/credential/osxkeychain/meson.build
index 3c7677f736c..545a8a25b4b 100644
--- a/contrib/credential/osxkeychain/meson.build
+++ b/contrib/credential/osxkeychain/meson.build
@@ -1,4 +1,4 @@
-executable('git-credential-osxkeychain',
+credential_helpers += executable('git-credential-osxkeychain',
   sources: 'git-credential-osxkeychain.c',
   dependencies: [
     dependency('CoreFoundation'),
diff --git a/contrib/credential/wincred/meson.build b/contrib/credential/wincred/meson.build
index 6de23ca17d4..fa669f038fe 100644
--- a/contrib/credential/wincred/meson.build
+++ b/contrib/credential/wincred/meson.build
@@ -1,4 +1,4 @@
-executable('git-credential-wincred',
+credential_helpers += executable('git-credential-wincred',
   sources: 'git-credential-wincred.c',
   install: true,
   install_dir: get_option('libexecdir') / 'git-core',
diff mbox series

Patch

diff --git a/contrib/credential/libsecret/meson.build b/contrib/credential/libsecret/meson.build
new file mode 100644
index 00000000000..0137660fe02
--- /dev/null
+++ b/contrib/credential/libsecret/meson.build
@@ -0,0 +1,9 @@ 
+executable('git-credential-libsecret',
+  sources: 'git-credential-libsecret.c',
+  dependencies: [
+    dependency('glib-2.0'),
+    dependency('libsecret-1'),
+  ],
+  install: true,
+  install_dir: get_option('libexecdir') / 'git-core',
+)
diff --git a/contrib/credential/meson.build b/contrib/credential/meson.build
new file mode 100644
index 00000000000..4216296ae05
--- /dev/null
+++ b/contrib/credential/meson.build
@@ -0,0 +1,3 @@ 
+foreach helper : get_option('credential_helpers')
+  subdir(helper)
+endforeach
diff --git a/contrib/credential/netrc/meson.build b/contrib/credential/netrc/meson.build
new file mode 100644
index 00000000000..a990dbb86da
--- /dev/null
+++ b/contrib/credential/netrc/meson.build
@@ -0,0 +1,20 @@ 
+credential_netrc = custom_target(
+  input: 'git-credential-netrc.perl',
+  output: 'git-credential-netrc',
+  command: generate_perl_command,
+  depends: [git_version_file],
+  install: true,
+  install_dir: get_option('libexecdir') / 'git-core',
+)
+
+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,
+)
diff --git a/contrib/credential/osxkeychain/meson.build b/contrib/credential/osxkeychain/meson.build
new file mode 100644
index 00000000000..3c7677f736c
--- /dev/null
+++ b/contrib/credential/osxkeychain/meson.build
@@ -0,0 +1,9 @@ 
+executable('git-credential-osxkeychain',
+  sources: 'git-credential-osxkeychain.c',
+  dependencies: [
+    dependency('CoreFoundation'),
+    dependency('Security'),
+  ],
+  install: true,
+  install_dir: get_option('libexecdir') / 'git-core',
+)
diff --git a/contrib/credential/wincred/meson.build b/contrib/credential/wincred/meson.build
new file mode 100644
index 00000000000..6de23ca17d4
--- /dev/null
+++ b/contrib/credential/wincred/meson.build
@@ -0,0 +1,5 @@ 
+executable('git-credential-wincred',
+  sources: 'git-credential-wincred.c',
+  install: true,
+  install_dir: get_option('libexecdir') / 'git-core',
+)
diff --git a/contrib/meson.build b/contrib/meson.build
index d74b64a5181..569c23ee768 100644
--- a/contrib/meson.build
+++ b/contrib/meson.build
@@ -1,3 +1,5 @@ 
 foreach feature : get_option('contrib')
   subdir(feature)
 endforeach
+
+subdir('credential')
diff --git a/meson.build b/meson.build
index d77d7b6b603..20159cef83d 100644
--- a/meson.build
+++ b/meson.build
@@ -771,7 +771,7 @@  endif
 # features. It is optional if you want to neither execute tests nor use any of
 # these optional features.
 perl_required = get_option('perl')
-if get_option('tests') or get_option('gitweb').enabled()
+if get_option('tests') or get_option('gitweb').enabled() or 'netrc' in get_option('credential_helpers')
   perl_required = true
 endif
 
diff --git a/meson_options.txt b/meson_options.txt
index 5c12e9055e6..0b0708dd0ed 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -29,6 +29,8 @@  option('version', type: 'string', value: '',
 # Features supported by Git.
 option('contrib', type: 'array', value: [ 'completion' ], choices: [ 'completion', 'subtree' ],
   description: 'Contributed features to include.')
+option('credential_helpers', type: 'array', value: [ ], choices: [ 'libsecret', 'netrc', 'osxkeychain', 'wincred' ],
+  description: 'Contributed features to include.')
 option('curl', type: 'feature', value: 'enabled',
   description: 'Build helpers used to access remotes with the HTTP transport.')
 option('expat', type: 'feature', value: 'enabled',