Improve setup of environment values for commands in MSVC's vcregress.pl
authorMichael Paquier <michael@paquier.xyz>
Wed, 11 May 2022 01:21:52 +0000 (10:21 +0900)
committerMichael Paquier <michael@paquier.xyz>
Wed, 11 May 2022 01:21:52 +0000 (10:21 +0900)
commit0826ac89ac18ab05b9991cfbba72351a502ef12c
tree1cbd297f0207a3bac64782f17f96f4d09f055b52
parentc90c16591c438e4146b1d4b9e4539f80b58845ba
Improve setup of environment values for commands in MSVC's vcregress.pl

The current setup assumes that commands for lz4, zstd and gzip always
exist by default if not enforced by a user's environment.  However,
vcpkg, as one example, installs libraries but no binaries, so this
default setup to assume that a command should always be present would
cause failures.  This commit improves the detection of such external
commands as follows:
* If a ENV value is available, trust the environment/user and use it.
* If a ENV value is not available, check its execution by looking in the
current PATH, by launching a simple "$command --version" (that should be
portable enough).
** On execution failure, ignore ENV{command}.
** On execution success, set ENV{command} = "$command".

Note that this new rule applies to gzip, lz4 and zstd but not tar that
we assume will always exist.  Those commands are set up in the
environment only when using bincheck and taptest.  The CI includes all
those commands and I have checked that their setup is correct there.  I
have also tested this change in a MSVC environment where we have none of
those commands.

While on it, remove the references to lz4 from the documentation and
vcregress.pl in ~v13.  --with-lz4 has been added in v14~ so there is no
point to have this information in these older branches.

Reported-by: Andrew Dunstan
Reviewed-by: Andrew Dunstan
Discussion: https://postgr.es/m/14402151-376b-a57a-6d0c-10ad12608e12@dunslane.net
Backpatch-through: 10
src/tools/msvc/vcregress.pl