On Sat, Nov 30, 2024 at 11:16:30AM +0100, Thomas Huth wrote:
On 29/11/2024 18.31, Daniel P. Berrangé wrote:
Put the 'which' function into shared code.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
tests/functional/qemu_test/__init__.py | 2 +-
tests/functional/qemu_test/cmd.py | 10 ++++++++++
tests/functional/test_acpi_bits.py | 13 +------------
tests/functional/test_ppc64_hv.py | 13 +------------
4 files changed, 13 insertions(+), 25 deletions(-)
None of the callers really seem to be interested in the location of the
command, only whether it is available in the $PATH or not ... so could we
maybe rather drop this function and use the has_cmd() function everywhere
instead?
Hmm, thinking about it twice - has_cmd() uses the "which" program
internally, but AFAIK this program is optional in Linux installations
nowadays ... so maybe it's still a good idea to move our Python which() to
cmd.py, but has_cmd() should maybe rather be changed to use it, too?
This reminds me I meant to ask about 'has_cmd' - it looks rather
over-engineered to me to be trying to invoke the command with
args.
Perhaps there was some reason to check support for individual
args in the past, but none of the current tests need that AFAICT.
So if anything I'd be looking to delete 'has_cmd' and 'has_cmds'
entirely, and rely only on the pure python 'which'.