|
14 | 14 | use File::Copy;
|
15 | 15 | use File::Find ();
|
16 | 16 | use File::Path qw(rmtree);
|
| 17 | +use File::Spec qw(devnull); |
17 | 18 |
|
18 | 19 | use FindBin;
|
19 | 20 | use lib $FindBin::RealBin;
|
|
30 | 31 | do './src/tools/msvc/config_default.pl';
|
31 | 32 | do './src/tools/msvc/config.pl' if (-f 'src/tools/msvc/config.pl');
|
32 | 33 |
|
| 34 | +my $devnull = File::Spec->devnull; |
| 35 | + |
33 | 36 | # 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. |
35 | 40 | # c.f. src/Makefile.global.in and configure.ac
|
36 |
| -$ENV{GZIP_PROGRAM} ||= 'gzip'; |
37 |
| -$ENV{LZ4} ||= 'lz4'; |
38 | 41 | $ENV{TAR} ||= 'tar';
|
39 |
| -$ENV{ZSTD} ||= 'zstd'; |
40 | 42 |
|
41 | 43 | # buildenv.pl is for specifying the build environment settings
|
42 | 44 | # it should contain lines like:
|
|
119 | 121 |
|
120 | 122 | ########################################################################
|
121 | 123 |
|
| 124 | +# Helper function for set_command_env, to set one environment command. |
| 125 | +sub set_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 | + return if (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} = $envdefault if $rc == 0; |
| 140 | + return; |
| 141 | +} |
| 142 | + |
| 143 | +# Set environment values for various command types. These can be used |
| 144 | +# in the TAP tests. |
| 145 | +sub set_command_env |
| 146 | +{ |
| 147 | + set_single_env('GZIP_PROGRAM', 'gzip'); |
| 148 | + set_single_env('LZ4', 'lz4'); |
| 149 | + set_single_env('ZSTD', 'zstd'); |
| 150 | +} |
| 151 | + |
122 | 152 | sub installcheck_internal
|
123 | 153 | {
|
124 | 154 | my ($schedule, @EXTRA_REGRESS_OPTS) = @_;
|
@@ -276,6 +306,8 @@ sub bincheck
|
276 | 306 | {
|
277 | 307 | InstallTemp();
|
278 | 308 |
|
| 309 | + set_command_env(); |
| 310 | + |
279 | 311 | my $mstat = 0;
|
280 | 312 |
|
281 | 313 | # Find out all the existing TAP tests by looking for t/ directories
|
@@ -310,6 +342,9 @@ sub taptest
|
310 | 342 | push(@args, "$topdir/$dir");
|
311 | 343 |
|
312 | 344 | InstallTemp();
|
| 345 | + |
| 346 | + set_command_env(); |
| 347 | + |
313 | 348 | my $status = tap_check(@args);
|
314 | 349 | exit $status if $status;
|
315 | 350 | return;
|
|
0 commit comments