Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0826ac8

Browse files
committed
Improve setup of environment values for commands in MSVC's vcregress.pl
The current setup assumes that commands for lz4, zstd and gzip alwaysexist by default if not enforced by a user's environment. However,vcpkg, as one example, installs libraries but no binaries, so thisdefault setup to assume that a command should always be present wouldcause failures. This commit improves the detection of such externalcommands 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 thecurrent PATH, by launching a simple "$command --version" (that should beportable 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 thatwe assume will always exist. Those commands are set up in theenvironment only when using bincheck and taptest. The CI includes allthose commands and I have checked that their setup is correct there. Ihave also tested this change in a MSVC environment where we have none ofthose commands.While on it, remove the references to lz4 from the documentation andvcregress.pl in ~v13. --with-lz4 has been added in v14~ so there is nopoint to have this information in these older branches.Reported-by: Andrew DunstanReviewed-by: Andrew DunstanDiscussion:https://postgr.es/m/14402151-376b-a57a-6d0c-10ad12608e12@dunslane.netBackpatch-through: 10
1 parentc90c165 commit0826ac8

File tree

1 file changed

+39
-4
lines changed

1 file changed

+39
-4
lines changed

‎src/tools/msvc/vcregress.pl

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use File::Copy;
1515
use File::Find ();
1616
use File::Pathqw(rmtree);
17+
use File::Specqw(devnull);
1718

1819
use FindBin;
1920
use lib$FindBin::RealBin;
@@ -30,13 +31,14 @@
3031
do'./src/tools/msvc/config_default.pl';
3132
do'./src/tools/msvc/config.pl'if (-f'src/tools/msvc/config.pl');
3233

34+
my$devnull = File::Spec->devnull;
35+
3336
# These values are defaults that can be overridden by the calling environment
34-
# (see buildenv.pl processing below).
37+
# (see buildenv.pl processing below). We assume that the ones listed here
38+
# always exist by default. Other values may optionally be set for bincheck
39+
# or taptest, see set_command_env() below.
3540
# c.f. src/Makefile.global.in and configure.ac
36-
$ENV{GZIP_PROGRAM} ||='gzip';
37-
$ENV{LZ4} ||='lz4';
3841
$ENV{TAR} ||='tar';
39-
$ENV{ZSTD} ||='zstd';
4042

4143
# buildenv.pl is for specifying the build environment settings
4244
# it should contain lines like:
@@ -119,6 +121,34 @@
119121

120122
########################################################################
121123

124+
# Helper function for set_command_env, to set one environment command.
125+
subset_single_env
126+
{
127+
my$envname =shift;
128+
my$envdefault =shift;
129+
130+
# If a command is defined by the environment, just use it.
131+
returnif (defined($ENV{$envname}));
132+
133+
# Nothing is defined, so attempt to assign a default. The command
134+
# may not be in the current environment, hence check if it can be
135+
# executed.
136+
my$rc =system("$envdefault --version >$devnull 2>&1");
137+
138+
# Set the environment to the default if it exists, else leave it.
139+
$ENV{$envname} =$envdefaultif$rc == 0;
140+
return;
141+
}
142+
143+
# Set environment values for various command types. These can be used
144+
# in the TAP tests.
145+
subset_command_env
146+
{
147+
set_single_env('GZIP_PROGRAM','gzip');
148+
set_single_env('LZ4','lz4');
149+
set_single_env('ZSTD','zstd');
150+
}
151+
122152
subinstallcheck_internal
123153
{
124154
my ($schedule,@EXTRA_REGRESS_OPTS) =@_;
@@ -276,6 +306,8 @@ sub bincheck
276306
{
277307
InstallTemp();
278308

309+
set_command_env();
310+
279311
my$mstat = 0;
280312

281313
# Find out all the existing TAP tests by looking for t/ directories
@@ -310,6 +342,9 @@ sub taptest
310342
push(@args,"$topdir/$dir");
311343

312344
InstallTemp();
345+
346+
set_command_env();
347+
313348
my$status = tap_check(@args);
314349
exit$statusif$status;
315350
return;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp