From 858e6985f1a47824e09a2f974842d1bc2bff3539 Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Wed, 22 Feb 2023 10:27:40 -0500 Subject: [PATCH 01/58] working on linux --- PGBuild/Modules/TestDecoding.pm | 3 +- PGBuild/Utils.pm | 11 +- build-farm.conf.sample | 34 ++- run_build.pl | 397 +++++++++++++++++++++++--------- 4 files changed, 333 insertions(+), 112 deletions(-) diff --git a/PGBuild/Modules/TestDecoding.pm b/PGBuild/Modules/TestDecoding.pm index 8e0d2ca..3a3e601 100644 --- a/PGBuild/Modules/TestDecoding.pm +++ b/PGBuild/Modules/TestDecoding.pm @@ -32,7 +32,8 @@ sub setup my $pgsql = shift; # postgres build dir # for now do nothing on MSVC - return if $conf->{using_msvc}; + # meson runs the test on its own + return if $conf->{using_msvc} || $conf->{using_meson}; # only for supported branches return unless $branch eq 'HEAD' || $branch ge 'REL9_4_STABLE'; diff --git a/PGBuild/Utils.pm b/PGBuild/Utils.pm index d08225d..a0f3226 100644 --- a/PGBuild/Utils.pm +++ b/PGBuild/Utils.pm @@ -409,7 +409,16 @@ sub check_install_is_complete my $suffix = '.dll'; # adjust settings for non-MSVC - if (-e "$build_dir/src/Makefile.global") # i.e. not msvc + + # use a simplified test for meson - where we always install everything + if (-e "$build_dir/meson-private") + { + $tmp_loc = "$tmp_loc/$install_dir"; + $bindir = "$tmp_loc/bin"; + $libdir = "$tmp_loc/lib/postgresql"; + return (-d $bindir && -d $libdir); + } + elsif (-e "$build_dir/src/Makefile.global") # i.e. not msvc { no warnings qw(once); my $make = $PGBuild::conf{make}; diff --git a/build-farm.conf.sample b/build-farm.conf.sample index 36a8145..1ce489b 100644 --- a/build-farm.conf.sample +++ b/build-farm.conf.sample @@ -266,6 +266,11 @@ my $confdir = File::Spec->rel2abs(File::Basename::dirname(__FILE__)); # see below for MSVC config + # set true if running with meson + # will be ignored for branches older than 16 + using_meson => undef, + + # options used with configure (and not for meson) config_opts => [ qw( --enable-cassert @@ -282,7 +287,29 @@ my $confdir = File::Spec->rel2abs(File::Basename::dirname(__FILE__)); ), # could also add for example --enable-tap-tests - ], + ], + + # Note, for meson we turn off all the auto options and then selectively + # re-enable them using these options, so zlib and readline have to be + # explicitly enabled here. + meson_opts => [ + qw( + -Dcassert=true + -Ddebug=true + -Dnls=enabled + -Dplperl=enabled + -Dplpython=enabled + -Dpltcl=enabled + -Dgssapi=enabled + -Dssl=openssl + -Dldap=enabled + -Dlibxml=enabled + -Dlibxslt=enabled + -Dzlib=enabled + -Dreadline=enabled + ), + # could for example add -Dtap_tests=enabled + ], # per-branch contents of extra config for check stages. # each branch has an array of setting lines (no \n required) @@ -388,10 +415,13 @@ if ($conf{using_msvc}) %{ $conf{build_env} } = (%{ $conf{build_env} }, %$vsenv); - # MSVC needs a somewhat different style of config opts (why??) + # MSVC non-meson needs a somewhat different style of config opts (why??) # What we write here will be literally (via Data::Dumper) put into # the config.pl file for the MSVC build. + # This will be ignored for meson builds, which use meson_opts rather + # than config_opts. See above for meson_opts. + $conf{config_opts} = { asserts => 1, # --enable-cassert integer_datetimes => 1, # --enable-integer-datetimes diff --git a/run_build.pl b/run_build.pl index 92919a6..d635352 100755 --- a/run_build.pl +++ b/run_build.pl @@ -185,7 +185,8 @@ BEGIN $wait_timeout, $use_accache, $use_valgrind, $valgrind_options, $use_installcheck_parallel, $max_load_avg, - $use_discard_caches, $archive_reports + $use_discard_caches, $archive_reports, + $using_meson, ) = @PGBuild::conf{ qw(build_root target animal aux_path trigger_exclude @@ -193,9 +194,11 @@ BEGIN use_vpath tar_log_cmd using_msvc extra_config make_jobs core_file_glob ccache_failure_remove wait_timeout use_accache use_valgrind valgrind_options use_installcheck_parallel max_load_avg - use_discard_caches archive_reports) + use_discard_caches archive_reports using_meson) }; +$using_meson = undef unless $branch eq 'HEAD' || $branch ge 'REL_16_STABLE'; + $ts_prefix = sprintf('%s:%-13s ', $animal, $branch); if ($max_load_avg) @@ -245,8 +248,10 @@ BEGIN print scalar(localtime()), ": buildfarm run for $animal:$branch starting\n" if $verbose; +$use_vpath ||= $using_meson; + die "cannot use vpath with MSVC" - if ($using_msvc and $use_vpath); + if ($using_msvc and $use_vpath and !$using_meson); if (ref($force_every) eq 'HASH') { @@ -254,6 +259,7 @@ BEGIN } my $config_opts = $PGBuild::conf{config_opts}; +my $meson_opts = $PGBuild::conf{meson_opts}; our ($buildport); @@ -428,11 +434,11 @@ BEGIN } else { - $pgsql = $scm->get_build_path($use_vpath); + $pgsql = $scm->get_build_path($use_vpath || $using_meson); } # make sure we are using GNU make (except for MSVC) -unless ($using_msvc) +unless ($using_msvc || $using_meson) { die "$make is not GNU Make - please fix config file" unless check_make(); @@ -882,20 +888,20 @@ END make_check() unless $delay_check; # contrib is built under the standard build step for msvc -make_contrib() unless ($using_msvc); +make_contrib() unless ($using_msvc || $using_meson); make_testmodules() - unless ($using_msvc || ($branch ne 'HEAD' && $branch lt 'REL9_5')); + unless ($using_msvc || $using_meson || ($branch ne 'HEAD' && $branch lt 'REL9_5')); make_doc() if (check_optional_step('build_docs')); make_install(); # contrib is installed under standard install for msvc -make_contrib_install() unless ($using_msvc); +make_contrib_install() unless ($using_msvc || $using_meson); make_testmodules_install() - unless ($using_msvc || ($branch ne 'HEAD' && $branch lt 'REL9_5')); + unless ($using_msvc || $using_meson || ($branch ne 'HEAD' && $branch lt 'REL9_5')); make_check() if $delay_check; @@ -909,11 +915,18 @@ END process_module_hooks("check") if $delay_check; -make_misc_check(); +if ($using_meson) +{ + run_meson_noninst_checks(); +} +else +{ + make_misc_check(); -run_bin_tests(); + run_bin_tests(); -run_misc_tests(); + run_misc_tests(); +} foreach my $locale (@locales) { @@ -947,80 +960,92 @@ END process_module_hooks('installcheck', $locale) if step_wanted('install-check'); - if ( -d "$pgsql/src/test/isolation" - && $locale eq 'C' - && step_wanted('isolation-check')) + if ($using_meson) { - # restart the db to clear the log file print time_str(), "restarting db ($locale)...\n" if $verbose; stop_db($locale); start_db($locale); - print time_str(), "running make isolation check ...\n" if $verbose; + print time_str(), "running meson installchecks ...\n" if $verbose; - make_isolation_check($locale); + run_meson_install_checks($locale); } - - if ( - step_wanted('pl-install-check') - && ( - ( - !$using_msvc - && (grep { /--with-(perl|python|tcl)/ } @$config_opts) - ) - || ( - $using_msvc - && ( defined($config_opts->{perl}) - || defined($config_opts->{python}) - || defined($config_opts->{tcl})) - ) - ) - ) + else { + if ( -d "$pgsql/src/test/isolation" + && $locale eq 'C' + && step_wanted('isolation-check')) + { + # restart the db to clear the log file + print time_str(), "restarting db ($locale)...\n" if $verbose; - # restart the db to clear the log file - print time_str(), "restarting db ($locale)...\n" if $verbose; + stop_db($locale); + start_db($locale); - stop_db($locale); - start_db($locale); + print time_str(), "running make isolation check ...\n" + if $verbose; + make_isolation_check($locale); + } - print time_str(), "running make PL installcheck ($locale)...\n" - if $verbose; + if ( + step_wanted('pl-install-check') + && ( + ( + !$using_msvc + && (grep { /--with-(perl|python|tcl)/ } @$config_opts) + ) + || ( + $using_msvc + && ( defined($config_opts->{perl}) + || defined($config_opts->{python}) + || defined($config_opts->{tcl})) + ) + ) + ) + { + # restart the db to clear the log file + print time_str(), "restarting db ($locale)...\n" if $verbose; - make_pl_install_check($locale); - } + stop_db($locale); + start_db($locale); - if (step_wanted('contrib-install-check')) - { + print time_str(), "running make PL installcheck ($locale)...\n" + if $verbose; - # restart the db to clear the log file - print time_str(), "restarting db ($locale)...\n" if $verbose; + make_pl_install_check($locale); + } - stop_db($locale); - start_db($locale); + if (step_wanted('contrib-install-check')) + { + # restart the db to clear the log file + print time_str(), "restarting db ($locale)...\n" if $verbose; - print time_str(), "running make contrib installcheck ($locale)...\n" - if $verbose; + stop_db($locale); + start_db($locale); - make_contrib_install_check($locale); - } + print time_str(), "running make contrib installcheck ($locale)...\n" + if $verbose; - unless (!step_wanted('testmodules-install-check') - || ($branch ne 'HEAD' && $branch lt 'REL9_5')) - { - print time_str(), "restarting db ($locale)...\n" if $verbose; + make_contrib_install_check($locale); + } - stop_db($locale); - start_db($locale); + unless (!step_wanted('testmodules-install-check') + || ($branch ne 'HEAD' && $branch lt 'REL9_5')) + { + print time_str(), "restarting db ($locale)...\n" if $verbose; - print time_str(), - "running make test-modules installcheck ($locale)...\n" - if $verbose; + stop_db($locale); + start_db($locale); - make_testmodules_install_check($locale); - } + print time_str(), + "running make test-modules installcheck ($locale)...\n" + if $verbose; + + make_testmodules_install_check($locale); + } + } # end of non-meson block print time_str(), "stopping db ($locale)...\n" if $verbose; @@ -1034,7 +1059,7 @@ END unless $keepall; } -if (step_wanted('ecpg-check')) +if (!$using_meson && step_wanted('ecpg-check')) { print time_str(), "running make ecpg check ...\n" if $verbose; @@ -1182,19 +1207,23 @@ sub make print time_str(), "running make ...\n" if $verbose; my (@makeout); - unless ($using_msvc) + if ($using_meson) { - my $make_cmd = $make; - $make_cmd = "$make -j $make_jobs" - if ($make_jobs > 1); - @makeout = run_log("cd $pgsql && $make_cmd"); + @makeout = run_log("meson compile -C $pgsql"); } - else + elsif ($using_msvc) { chdir "$pgsql/src/tools/msvc"; @makeout = run_log("perl build.pl"); chdir $branch_root; } + else + { + my $make_cmd = $make; + $make_cmd = "$make -j $make_jobs" + if ($make_jobs > 1); + @makeout = run_log("cd $pgsql && $make_cmd"); + } my $status = $? >> 8; writelog('make', \@makeout); print "======== make log ===========\n", @makeout if ($verbose > 1); @@ -1236,16 +1265,20 @@ sub make_install print time_str(), "running make install ...\n" if $verbose; my @makeout; - unless ($using_msvc) + if($using_meson) { - @makeout = run_log("cd $pgsql && $make install"); + @makeout = run_log("meson install -C $pgsql "); } - else + elsif ($using_msvc) { chdir "$pgsql/src/tools/msvc"; @makeout = run_log(qq{perl install.pl "$installdir"}); chdir $branch_root; } + else + { + @makeout = run_log("cd $pgsql && $make install"); + } my $status = $? >> 8; writelog('make-install', \@makeout); print "======== make install log ===========\n", @makeout if ($verbose > 1); @@ -1625,7 +1658,20 @@ sub make_install_check print time_str(), "running make installcheck ($locale)...\n" if $verbose; my @checklog; - unless ($using_msvc) + if ($using_meson) + { + local %ENV = (PATH => $ENV{PATH}, + PGUSER => $ENV{PGUSER}, + PGHOST => $ENV{PGHOST}); + @checklog = run_log("meson test -v -C $pgsql --no-rebuild --print-errorlogs --setup running --suite regress-running --logbase regress-installcheck-$locale"); + } + elsif ($using_msvc) + { + chdir "$pgsql/src/tools/msvc"; + @checklog = run_log("perl vcregress.pl installcheck"); + chdir $branch_root; + } + else { my $chktarget = $use_installcheck_parallel @@ -1642,12 +1688,6 @@ sub make_install_check } @checklog = run_log("cd $pgsql/src/test/regress && $make $chktarget"); } - else - { - chdir "$pgsql/src/tools/msvc"; - @checklog = run_log("perl vcregress.pl installcheck"); - chdir $branch_root; - } my $status = $? >> 8; my @logfiles = ("$pgsql/src/test/regress/regression.diffs", "inst/logfile"); my $log = PGBuild::Log->new("check"); @@ -1707,6 +1747,77 @@ sub make_contrib_install_check return; } +# run tests for all the installcheck suites meson knows about +sub run_meson_install_checks +{ + my $locale = shift; + return unless step_wanted('misc-install-check'); + local %ENV = (PATH => $ENV{PATH}, + PGUSER => $ENV{PGUSER}, + PGHOST => $ENV{PGHOST}); + my @tests = run_log("meson test -C $pgsql --setup running --no-rebuild --list"); + chomp @tests; + do { s/^postgresql:// ; s! / .*!!; } foreach @tests; + my %suites = map {$_ => 1} @tests; + + delete $suites{"regress-running"}; # already run + delete $suites{"ecpg-running"}; # already run + delete $suites{"unsafe_tests-running"}; # shouldn't run + delete $suites{"isolation-running"} unless $locale eq 'C'; # ony run once + + foreach my $suite (keys %suites) + { + print time_str(), "running test suite $suite...\n" if $verbose; + + my $bare_suite = $suite; + $bare_suite =~ s/-running$//; + + my @checklog=run_log("meson test --print-errorlogs --no-rebuild -C $pgsql --logbase $suite --suite $suite"); + my $status ||= $? >> 8; + + my $log = PGBuild::Log->new("$bare_suite-installcheck"); + $log->add_log("$pgsql/meson-logs/$suite.txt"); + push(@checklog, $log->log_string); + writelog("${bare_suite}InstallCheck", \@checklog); + print @checklog if ($verbose > 1); + send_result("${bare_suite}InstallCheck", $status, \@checklog) if $status; + $steps_completed .= " ${bare_suite}InstallCheck"; + } + return; +} + +# run tests for all the non-installcheck suites meson knows about +sub run_meson_noninst_checks +{ + return unless step_wanted('misc-check'); + local %ENV = (PATH => $ENV{PATH}); + my @tests = run_log("meson test -C $pgsql --no-rebuild --list"); + chomp @tests; + do { s/^postgresql:// ; s! / .*!!; } foreach @tests; + my %suites = map {$_ => 1} @tests; + + delete $suites{regress}; + delete $suites{setup}; + delete $suites{isolation}; + + foreach my $suite (keys %suites) + { + print time_str(), "running test suite $suite...\n" if $verbose; + + my @checklog=run_log("meson test --print-errorlogs --no-rebuild -C $pgsql --logbase $suite --suite $suite"); + my $status ||= $? >> 8; + + my $log = PGBuild::Log->new("$suite-check"); + $log->add_log("$pgsql/meson-logs/$suite.txt"); + push(@checklog, $log->log_string); + writelog("$suite-check", \@checklog); + print @checklog if ($verbose > 1); + send_result("MiscCheck", $status, \@checklog) if $status; + $steps_completed .= " ${suite}Check"; + } + return; +} + # run the modules that can't be run with installcheck sub make_misc_check { @@ -2043,7 +2154,20 @@ sub make_check print time_str(), "running make check ...\n" if $verbose; my @makeout; - unless ($using_msvc) + if ($using_meson) + { + # prevent meson from logging the whole environment, + # see its issue 5328 + local %ENV = (PATH => $ENV{PATH}, PGUSER => $ENV{PGUSER}); + @makeout=run_log("meson test --logbase checklog --print-errorlogs --no-rebuild -C $pgsql --suite setup --suite regress"); + } + elsif ($using_msvc) + { + chdir "$pgsql/src/tools/msvc"; + @makeout = run_log("perl vcregress.pl check"); + chdir $branch_root; + } + else { my $chktarget = "check"; if ($schedule && -s $schedule) @@ -2059,12 +2183,6 @@ sub make_check @makeout = run_log("cd $pgsql/src/test/regress && $make NO_LOCALE=1 $chktarget"); } - else - { - chdir "$pgsql/src/tools/msvc"; - @makeout = run_log("perl vcregress.pl check"); - chdir $branch_root; - } my $status = $? >> 8; @@ -2072,7 +2190,7 @@ sub make_check # get the log files and the regression diffs my @logs = - glob("$pgsql/src/test/regress/log/*.log $pgsql/tmp_install/log/*"); + glob("$pgsql/src/test/regress/log/*.log $pgsql/tmp_install/log/* $pgsql/*/checklog.txt"); unshift(@logs, "$pgsql/src/test/regress/regression.diffs") if (-e "$pgsql/src/test/regress/regression.diffs"); $log->add_log($_) foreach (@logs); @@ -2314,37 +2432,100 @@ sub find_typedefs return; } -sub configure +sub meson_setup { + my $env = $PGBuild::conf{config_env}; + local %ENV = (%ENV, %$env); - if ($using_msvc) + my @quoted_opts; + foreach my $c_opt (@$meson_opts) { - my $lconfig = { %$config_opts, "--with-pgport" => $buildport }; - my $conf = Data::Dumper->Dump([$lconfig], ['config']); - my @text = ( - "# Configuration arguments for vcbuild.\n", - "# written by buildfarm client \n", - "use strict; \n", - "use warnings;\n", - "our $conf \n", - "1;\n" - ); + if ($c_opt =~ /['"]/) + { + push(@quoted_opts, $c_opt); + } + else + { + push(@quoted_opts, "'$c_opt'"); + } + } - my $handle; - open($handle, ">", "$pgsql/src/tools/msvc/config.pl") - || die "opening $pgsql/src/tools/msvc/config.pl: $!"; - print $handle @text; - close($handle); + my $confstr = join(" ", + "-Dauto_features=disabled", + @quoted_opts, + "-Dlibdir=lib", + "-Dprefix=$installdir", + "-Dpgport=$buildport"); - push(@text, "# no configure step for MSCV - config file shown\n"); + my @confout = run_log("meson setup $confstr $pgsql pgsql"); - writelog('configure', \@text); + my $status = $? >> 8; + + print "======== configure output ===========\n", @confout + if ($verbose > 1); + + if (-s "$pgsql/config.log") + { + push(@confout, + "\n\n================= config.log ================\n\n", + file_lines("$pgsql/config.log")); + } + + writelog('configure', \@confout); + + if ($status) + { + send_result('Configure', $status, \@confout); + } + $steps_completed .= " Configure"; + + return; + +} + +sub msvc_setup +{ + my $lconfig = { %$config_opts, "--with-pgport" => $buildport }; + my $conf = Data::Dumper->Dump([$lconfig], ['config']); + my @text = ( + "# Configuration arguments for vcbuild.\n", + "# written by buildfarm client \n", + "use strict; \n", + "use warnings;\n", + "our $conf \n", + "1;\n" + ); + + my $handle; + open($handle, ">", "$pgsql/src/tools/msvc/config.pl") + || die "opening $pgsql/src/tools/msvc/config.pl: $!"; + print $handle @text; + close($handle); + + push(@text, "# no configure step for MSCV - config file shown\n"); + + writelog('configure', \@text); + + $steps_completed .= " Configure"; + return; +} - $steps_completed .= " Configure"; +sub configure +{ + if ($using_meson) + { + meson_setup(); + return; + } + if ($using_msvc) + { + msvc_setup(); return; } + # autoconf/configure setup + my @quoted_opts; foreach my $c_opt (@$config_opts) { From 9d8701b92076884a1e3af8e9b1fb185abaacbec0 Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Wed, 22 Feb 2023 18:06:52 -0500 Subject: [PATCH 02/58] fixes for meson+msvc --- build-farm.conf.sample | 1 + run_build.pl | 23 ++++++++++++++++++----- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/build-farm.conf.sample b/build-farm.conf.sample index 1ce489b..e335778 100644 --- a/build-farm.conf.sample +++ b/build-farm.conf.sample @@ -233,6 +233,7 @@ my $confdir = File::Spec->rel2abs(File::Basename::dirname(__FILE__)); # comment out if not using ccache # ccache is known to cause issues sometimes on msys2 + # don't set CC at all if using MSVC, especially with meson CC => 'ccache gcc', # If using vpath builds, this makes it use true symbolic links diff --git a/run_build.pl b/run_build.pl index d635352..95930db 100755 --- a/run_build.pl +++ b/run_build.pl @@ -1660,9 +1660,11 @@ sub make_install_check my @checklog; if ($using_meson) { + my $sysroot = $ENV{SystemRoot}; local %ENV = (PATH => $ENV{PATH}, PGUSER => $ENV{PGUSER}, PGHOST => $ENV{PGHOST}); + $ENV{SystemRoot} = $sysroot if $sysroot; @checklog = run_log("meson test -v -C $pgsql --no-rebuild --print-errorlogs --setup running --suite regress-running --logbase regress-installcheck-$locale"); } elsif ($using_msvc) @@ -1752,9 +1754,11 @@ sub run_meson_install_checks { my $locale = shift; return unless step_wanted('misc-install-check'); + my $sysroot = $ENV{SystemRoot}; local %ENV = (PATH => $ENV{PATH}, PGUSER => $ENV{PGUSER}, PGHOST => $ENV{PGHOST}); + $ENV{SystemRoot} = $sysroot if $sysroot; my @tests = run_log("meson test -C $pgsql --setup running --no-rebuild --list"); chomp @tests; do { s/^postgresql:// ; s! / .*!!; } foreach @tests; @@ -1790,7 +1794,9 @@ sub run_meson_install_checks sub run_meson_noninst_checks { return unless step_wanted('misc-check'); - local %ENV = (PATH => $ENV{PATH}); + my $sysroot = $ENV{SystemRoot}; + local %ENV = (PATH => $ENV{PATH}, PGUSER => $ENV{PGUSER}); + $ENV{SystemRoot} = $sysroot if $sysroot; my @tests = run_log("meson test -C $pgsql --no-rebuild --list"); chomp @tests; do { s/^postgresql:// ; s! / .*!!; } foreach @tests; @@ -1804,7 +1810,7 @@ sub run_meson_noninst_checks { print time_str(), "running test suite $suite...\n" if $verbose; - my @checklog=run_log("meson test --print-errorlogs --no-rebuild -C $pgsql --logbase $suite --suite $suite"); + my @checklog=run_log("meson test -C $pgsql --print-errorlogs --no-rebuild --logbase $suite --suite $suite"); my $status ||= $? >> 8; my $log = PGBuild::Log->new("$suite-check"); @@ -2158,8 +2164,10 @@ sub make_check { # prevent meson from logging the whole environment, # see its issue 5328 + my $sysroot = $ENV{SystemRoot}; local %ENV = (PATH => $ENV{PATH}, PGUSER => $ENV{PGUSER}); - @makeout=run_log("meson test --logbase checklog --print-errorlogs --no-rebuild -C $pgsql --suite setup --suite regress"); + $ENV{SystemRoot} = $sysroot if $sysroot; + @makeout=run_log("meson test -C $pgsql --logbase checklog --print-errorlogs --no-rebuild --suite setup --suite regress"); } elsif ($using_msvc) { @@ -2444,6 +2452,10 @@ sub meson_setup { push(@quoted_opts, $c_opt); } + elsif ($using_msvc) + { + push(@quoted_opts,qq{"$c_opt"}); + } else { push(@quoted_opts, "'$c_opt'"); @@ -2454,10 +2466,11 @@ sub meson_setup "-Dauto_features=disabled", @quoted_opts, "-Dlibdir=lib", - "-Dprefix=$installdir", + qq{-Dprefix="$installdir"}, "-Dpgport=$buildport"); - my @confout = run_log("meson setup $confstr $pgsql pgsql"); + my $flag = $using_msvc ? "--backend vs" : ""; + my @confout = run_log("meson setup $flag $confstr $pgsql pgsql"); my $status = $? >> 8; From d9bebeaf96c7beb3c42a9e1cb50234328512f064 Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Thu, 23 Feb 2023 07:47:06 -0500 Subject: [PATCH 03/58] tweaks and refactoring --- run_build.pl | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/run_build.pl b/run_build.pl index 95930db..6e0f315 100755 --- a/run_build.pl +++ b/run_build.pl @@ -1497,6 +1497,18 @@ sub initdb return; } + +sub _meson_env +{ + my %env; + foreach my $setting (qw(PATH PGUSER PGHOST SystemRoot)) + { + my $v = $ENV{$setting}; + $env{$setting} = $v if $v; + } + return %env; +} + sub start_valgrind_db { # run the postmaster under valgrind. @@ -1660,11 +1672,7 @@ sub make_install_check my @checklog; if ($using_meson) { - my $sysroot = $ENV{SystemRoot}; - local %ENV = (PATH => $ENV{PATH}, - PGUSER => $ENV{PGUSER}, - PGHOST => $ENV{PGHOST}); - $ENV{SystemRoot} = $sysroot if $sysroot; + local %ENV = _meson_env(); @checklog = run_log("meson test -v -C $pgsql --no-rebuild --print-errorlogs --setup running --suite regress-running --logbase regress-installcheck-$locale"); } elsif ($using_msvc) @@ -1754,11 +1762,7 @@ sub run_meson_install_checks { my $locale = shift; return unless step_wanted('misc-install-check'); - my $sysroot = $ENV{SystemRoot}; - local %ENV = (PATH => $ENV{PATH}, - PGUSER => $ENV{PGUSER}, - PGHOST => $ENV{PGHOST}); - $ENV{SystemRoot} = $sysroot if $sysroot; + local %ENV = _meson_env(); my @tests = run_log("meson test -C $pgsql --setup running --no-rebuild --list"); chomp @tests; do { s/^postgresql:// ; s! / .*!!; } foreach @tests; @@ -1794,9 +1798,7 @@ sub run_meson_install_checks sub run_meson_noninst_checks { return unless step_wanted('misc-check'); - my $sysroot = $ENV{SystemRoot}; - local %ENV = (PATH => $ENV{PATH}, PGUSER => $ENV{PGUSER}); - $ENV{SystemRoot} = $sysroot if $sysroot; + local %ENV = _meson_env(); my @tests = run_log("meson test -C $pgsql --no-rebuild --list"); chomp @tests; do { s/^postgresql:// ; s! / .*!!; } foreach @tests; @@ -1818,7 +1820,7 @@ sub run_meson_noninst_checks push(@checklog, $log->log_string); writelog("$suite-check", \@checklog); print @checklog if ($verbose > 1); - send_result("MiscCheck", $status, \@checklog) if $status; + send_result("${suite}Check", $status, \@checklog) if $status; $steps_completed .= " ${suite}Check"; } return; @@ -2164,9 +2166,7 @@ sub make_check { # prevent meson from logging the whole environment, # see its issue 5328 - my $sysroot = $ENV{SystemRoot}; - local %ENV = (PATH => $ENV{PATH}, PGUSER => $ENV{PGUSER}); - $ENV{SystemRoot} = $sysroot if $sysroot; + local %ENV = _meson_env(); @makeout=run_log("meson test -C $pgsql --logbase checklog --print-errorlogs --no-rebuild --suite setup --suite regress"); } elsif ($using_msvc) @@ -2440,9 +2440,12 @@ sub find_typedefs return; } +# meson setup for all platforms sub meson_setup { my $env = $PGBuild::conf{config_env}; + $env = { %$env }; # clone it + delete $env->{CC} if $using_msvc; # this can confuse meson in this case local %ENV = (%ENV, %$env); my @quoted_opts; @@ -2496,6 +2499,7 @@ sub meson_setup } +# non-meson MSVC setup sub msvc_setup { my $lconfig = { %$config_opts, "--with-pgport" => $buildport }; @@ -2523,6 +2527,8 @@ sub msvc_setup return; } +# setup entry, directly implements autoconf setup, +# calls above for meson / msvc sub configure { if ($using_meson) From c26f9a527e6b2b82b9b8e2880822a3dcf5b9c9be Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Thu, 23 Feb 2023 09:22:16 -0500 Subject: [PATCH 04/58] setup PG_TEST_PORT_DIR for TAP tests --- build-farm.conf.sample | 3 +++ run_build.pl | 3 +++ 2 files changed, 6 insertions(+) diff --git a/build-farm.conf.sample b/build-farm.conf.sample index e335778..6e95fc1 100644 --- a/build-farm.conf.sample +++ b/build-farm.conf.sample @@ -225,6 +225,9 @@ my $confdir = File::Spec->rel2abs(File::Basename::dirname(__FILE__)); # These are the ones omitted without the setting # on a secure single user system it makes sense to enable these # PG_TEST_EXTRA => "ssl ldap kerberos", + + # Where to put port locks. Default is the buildroot + # PG_TEST_PORT_DIR => 'some path', }, # env settings to pass to configure. These settings will only be seen by diff --git a/run_build.pl b/run_build.pl index 6e0f315..bfaf852 100755 --- a/run_build.pl +++ b/run_build.pl @@ -379,6 +379,9 @@ BEGIN $ENV{$envkey} = $envval; } +# default directory for port locks in TAP tests +$ENV{PG_TEST_PORT_DIR} ||= $buildroot; + # default value - supply unless set via the config file # or calling environment $ENV{PGCTLTIMEOUT} = 120 unless exists $ENV{PGCTLTIMEOUT}; From 16b97c52a488ae920ca01b091a509dc69f8f2cfd Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Thu, 23 Feb 2023 09:26:23 -0500 Subject: [PATCH 05/58] pass through PG_TEST_PORT_DIR to meson --- run_build.pl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/run_build.pl b/run_build.pl index bfaf852..7eada08 100755 --- a/run_build.pl +++ b/run_build.pl @@ -1504,7 +1504,8 @@ sub initdb sub _meson_env { my %env; - foreach my $setting (qw(PATH PGUSER PGHOST SystemRoot)) + # these are safe to appear on the log and are required for running tests + foreach my $setting (qw(PATH PGUSER PGHOST SystemRoot PG_TEST_PORT_DIR)) { my $v = $ENV{$setting}; $env{$setting} = $v if $v; From 932fbfa75766667af30a7325a2f25988b30f858a Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Sat, 25 Feb 2023 07:54:36 -0500 Subject: [PATCH 06/58] extent safe environment set --- run_build.pl | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/run_build.pl b/run_build.pl index 7eada08..36d2518 100755 --- a/run_build.pl +++ b/run_build.pl @@ -1504,8 +1504,14 @@ sub initdb sub _meson_env { my %env; - # these are safe to appear on the log and are required for running tests - foreach my $setting (qw(PATH PGUSER PGHOST SystemRoot PG_TEST_PORT_DIR)) + # these should be safe to appear on the log and could be required + # for running tests + my @safe_set = qw( + PATH + PGUSER PGHOST PG_TEST_PORT_DIR PG_TEST_EXTRA + SystemRoot TEMP TMP + USER USERNAME USERDOMAIN); + foreach my $setting (@safe_set) { my $v = $ENV{$setting}; $env{$setting} = $v if $v; From f88e6a25ecf864dcfefd6485b6a60bd4ff2286d3 Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Sat, 25 Feb 2023 09:41:56 -0500 Subject: [PATCH 07/58] allow for locale names with spaces --- run_build.pl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/run_build.pl b/run_build.pl index 36d2518..68b7b8c 100755 --- a/run_build.pl +++ b/run_build.pl @@ -939,6 +939,8 @@ END initdb($locale); + $locale =~ s/\s/-/g; + do { # silence warning about uninitialized value, on e.g. frogmouth. @@ -1423,7 +1425,9 @@ sub initdb chdir $installdir; - my $initdbopts = qq{-A trust -U buildfarm --locale=$locale}; + my $initdbopts = qq{-A trust -U buildfarm --locale="$locale"}; + + $locale =~ s/\s/-/g; if ($use_discard_caches && ($branch eq 'HEAD' || $branch ge 'REL_14')) { From 0ce558ce057c7955f478f39c94310778144ce885 Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Sat, 25 Feb 2023 09:53:23 -0500 Subject: [PATCH 08/58] honor use_installcheck_parallel for msvc --- run_build.pl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/run_build.pl b/run_build.pl index 68b7b8c..e37ecef 100755 --- a/run_build.pl +++ b/run_build.pl @@ -1691,8 +1691,9 @@ sub make_install_check } elsif ($using_msvc) { + my $parallel = $use_installcheck_parallel ? "parallel" : ""; chdir "$pgsql/src/tools/msvc"; - @checklog = run_log("perl vcregress.pl installcheck"); + @checklog = run_log("perl vcregress.pl installcheck $parallel"); chdir $branch_root; } else From aa3d56e1bdecb5d352ad42539be71e486c57b1f8 Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Mon, 27 Feb 2023 14:04:26 -0500 Subject: [PATCH 09/58] allow for --no-locale in check --- run_build.pl | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/run_build.pl b/run_build.pl index e37ecef..c96ad3e 100755 --- a/run_build.pl +++ b/run_build.pl @@ -888,6 +888,8 @@ END make(); +meson_test_setup() if $using_meson; + make_check() unless $delay_check; # contrib is built under the standard build step for msvc @@ -1772,6 +1774,14 @@ sub make_contrib_install_check return; } +sub meson_test_setup +{ + # we run test setup separately so we can pass test arguments + # in the check stage + local %ENV = _meson_env(); + my @log = run_log("meson test -C $pgsql --no-rebuild --suite setup"); +} + # run tests for all the installcheck suites meson knows about sub run_meson_install_checks { @@ -2182,7 +2192,7 @@ sub make_check # prevent meson from logging the whole environment, # see its issue 5328 local %ENV = _meson_env(); - @makeout=run_log("meson test -C $pgsql --logbase checklog --print-errorlogs --no-rebuild --suite setup --suite regress"); + @makeout=run_log("meson test -C $pgsql --logbase checklog --print-errorlogs --no-rebuild --suite regress --test-args=--no-locale"); } elsif ($using_msvc) { From 64a6eefe067a78ff015df86f4d44dd0a6dc3d866 Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Mon, 27 Feb 2023 16:04:18 -0500 Subject: [PATCH 10/58] fix path for make_check --- run_build.pl | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/run_build.pl b/run_build.pl index c96ad3e..be64a9a 100755 --- a/run_build.pl +++ b/run_build.pl @@ -2192,6 +2192,13 @@ sub make_check # prevent meson from logging the whole environment, # see its issue 5328 local %ENV = _meson_env(); + if ($using_msvc) + { + # not sure why we need to do this for msvc, but it works + my $inst = $installdir; + $inst =~ s/^[a-z]://i; + $ENV{PATH} = "$pgsql/tmp_install$inst/bin;$ENV{PATH}"; + } @makeout=run_log("meson test -C $pgsql --logbase checklog --print-errorlogs --no-rebuild --suite regress --test-args=--no-locale"); } elsif ($using_msvc) From 238ddf9f9f63d5e104e040ba1297e7d5d1ea14b6 Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Tue, 28 Feb 2023 11:55:12 -0500 Subject: [PATCH 11/58] mainly parallelizing most of the tests also changing some log lines and step names --- run_build.pl | 191 +++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 140 insertions(+), 51 deletions(-) diff --git a/run_build.pl b/run_build.pl index be64a9a..a8fd3c0 100755 --- a/run_build.pl +++ b/run_build.pl @@ -251,7 +251,7 @@ BEGIN $use_vpath ||= $using_meson; die "cannot use vpath with MSVC" - if ($using_msvc and $use_vpath and !$using_meson); + if ($using_msvc && $use_vpath && !$using_meson); if (ref($force_every) eq 'HASH') { @@ -769,7 +769,8 @@ END } } - print time_str(), "checking if build run needed ...\n" if $verbose; + print time_str(), "checking if build run needed ...\n" + if $verbose && !($testmode || $from_source); # transition to new time processing unlink "last.success"; @@ -852,7 +853,8 @@ END if ($use_vpath) { - print time_str(), "creating vpath build dir $pgsql ...\n" if $verbose; + my $str = $using_meson ? "meson" : "vpath"; + print time_str(), "creating $str build dir $pgsql ...\n" if $verbose; mkdir $pgsql || die "making $pgsql: $!"; } elsif (!$from_source && $scm->copy_source_required()) @@ -878,7 +880,8 @@ END if (step_wanted('configure')) { - print time_str(), "running configure ...\n" if $verbose; + my $str = $using_meson ? "meson setup" : "configure"; + print time_str(), "running $str ...\n" if $verbose; configure(); } @@ -975,8 +978,6 @@ END stop_db($locale); start_db($locale); - print time_str(), "running meson installchecks ...\n" if $verbose; - run_meson_install_checks($locale); } else @@ -1211,7 +1212,7 @@ sub check_make sub make { return unless step_wanted('make'); - print time_str(), "running make ...\n" if $verbose; + print time_str(), "running build ...\n" if $verbose; my (@makeout); if ($using_meson) @@ -1232,11 +1233,11 @@ sub make @makeout = run_log("cd $pgsql && $make_cmd"); } my $status = $? >> 8; - writelog('make', \@makeout); + writelog('build', \@makeout); print "======== make log ===========\n", @makeout if ($verbose > 1); - $status ||= check_make_log_warnings('make', $verbose) if $check_warnings; - send_result('Make', $status, \@makeout) if $status; - $steps_completed .= " Make"; + $status ||= check_make_log_warnings('build', $verbose) if $check_warnings; + send_result('Build', $status, \@makeout) if $status; + $steps_completed .= " Build"; return; } @@ -1269,7 +1270,7 @@ sub make_doc sub make_install { return unless step_wanted('install'); - print time_str(), "running make install ...\n" if $verbose; + print time_str(), "running install ...\n" if $verbose; my @makeout; if($using_meson) @@ -1683,7 +1684,7 @@ sub make_install_check { my $locale = shift; return unless step_wanted('install-check'); - print time_str(), "running make installcheck ($locale)...\n" if $verbose; + print time_str(), "running installcheck ($locale)...\n" if $verbose; my @checklog; if ($using_meson) @@ -1780,6 +1781,8 @@ sub meson_test_setup # in the check stage local %ENV = _meson_env(); my @log = run_log("meson test -C $pgsql --no-rebuild --suite setup"); + # XXX fixme: logging etc. + return; } # run tests for all the installcheck suites meson knows about @@ -1788,33 +1791,74 @@ sub run_meson_install_checks my $locale = shift; return unless step_wanted('misc-install-check'); local %ENV = _meson_env(); - my @tests = run_log("meson test -C $pgsql --setup running --no-rebuild --list"); - chomp @tests; - do { s/^postgresql:// ; s! / .*!!; } foreach @tests; - my %suites = map {$_ => 1} @tests; + print time_str(), "running meson misc installchecks ($locale) ...\n" if $verbose; + + # clean out old logs etc + unlink "$pgsql/meson-logs/installcheckworld.txt"; + rmtree $_ foreach glob("$pgsql/testrun/*-running"); + + # skip regress, done by make_installcheck + # skip isolation and ecpg, done with misc checks + my @checklog=run_log("meson test -C $pgsql --setup running --print-errorlogs --no-rebuild --logbase installcheckworld --no-suite regress-running --no-suite isolation-running --no-suite ecpg-running"); - delete $suites{"regress-running"}; # already run - delete $suites{"ecpg-running"}; # already run - delete $suites{"unsafe_tests-running"}; # shouldn't run - delete $suites{"isolation-running"} unless $locale eq 'C'; # ony run once + my @fails = glob("$pgsql/testrun/*/*/test.fail"); - foreach my $suite (keys %suites) + my $status = (0 < @fails); + + my @faildirs = map { dirname $_ } @fails; + my (@miscdirs,@moddirs,@contribdirs,@otherdirs); + foreach my $dir (@faildirs) { - print time_str(), "running test suite $suite...\n" if $verbose; + my $sname = basename (dirname ($dir)); + $sname =~ s/-running$//; + if (-e "pgsql/src/test/$sname") + { + push @miscdirs, $dir; + } + elsif (-e "pgsql/src/test/modules/$sname") + { + push @moddirs, $dir; + } + elsif (-e "pgsql/contrib/$sname") + { + push @contribdirs, $dir; + } + else + { + push @otherdirs, $dir; + } + } - my $bare_suite = $suite; - $bare_suite =~ s/-running$//; + @miscdirs = sort @miscdirs; + @moddirs = sort @moddirs; + @contribdirs = sort @contribdirs; + @otherdirs = sort @otherdirs; - my @checklog=run_log("meson test --print-errorlogs --no-rebuild -C $pgsql --logbase $suite --suite $suite"); - my $status ||= $? >> 8; + @faildirs = (@miscdirs, @moddirs, @contribdirs, @otherdirs); - my $log = PGBuild::Log->new("$bare_suite-installcheck"); - $log->add_log("$pgsql/meson-logs/$suite.txt"); - push(@checklog, $log->log_string); - writelog("${bare_suite}InstallCheck", \@checklog); + my $log = PGBuild::Log->new("misc-installcheck-$locale"); + $log->add_log("$pgsql/meson-logs/installcheckworld.txt"); + foreach my $dir (@faildirs) + { + $log->add_log($_) + foreach ("$dir/regression.diffs", glob("$dir/log/*")); + } + push(@checklog, $log->log_string); + + if ($status) + { + my $first = $faildirs[0]; + $first = basename (dirname $first); + $first =~ s/-running$//; + writelog("$first-installcheck-$locale", \@checklog); + print @checklog if ($verbose > 1); + send_result("${first}InstallCheck-$locale", $status, \@checklog); + } + else + { + writelog("misc-installcheck-$locale", \@checklog); print @checklog if ($verbose > 1); - send_result("${bare_suite}InstallCheck", $status, \@checklog) if $status; - $steps_completed .= " ${bare_suite}InstallCheck"; + $steps_completed .= " MiscInstallCheck-$locale"; } return; } @@ -1824,29 +1868,74 @@ sub run_meson_noninst_checks { return unless step_wanted('misc-check'); local %ENV = _meson_env(); - my @tests = run_log("meson test -C $pgsql --no-rebuild --list"); - chomp @tests; - do { s/^postgresql:// ; s! / .*!!; } foreach @tests; - my %suites = map {$_ => 1} @tests; - delete $suites{regress}; - delete $suites{setup}; - delete $suites{isolation}; + print time_str(), "running meson misc tests ...\n" if $verbose; + + # skip setup, already done + # skip regress, done by make_check + my @checklog=run_log("meson test -C $pgsql --print-errorlogs --no-rebuild --logbase checkworld --no-suite setup --no-suite regress"); - foreach my $suite (keys %suites) + my @fails = glob("$pgsql/testrun/*/*/test.fail"); + + my $status = (0 < @fails); + + my @faildirs = map { dirname $_ } @fails; + my (@bindirs,@miscdirs,@moddirs,@contribdirs,@otherdirs); + foreach my $dir (@faildirs) { - print time_str(), "running test suite $suite...\n" if $verbose; + my $sname = basename (dirname ($dir)); + if (-e "pgsql/src/bin/$sname") + { + push @bindirs,$dir; + } + elsif (-e "pgsql/src/test/$sname") + { + push @miscdirs, $dir; + } + elsif (-e "pgsql/src/test/modules/$sname") + { + push @moddirs, $dir; + } + elsif (-e "pgsql/contrib/$sname") + { + push @contribdirs, $dir; + } + else + { + push @otherdirs, $dir; + } + } + + @bindirs = sort @bindirs; + @miscdirs = sort @miscdirs; + @moddirs = sort @moddirs; + @contribdirs = sort @contribdirs; + @otherdirs = sort @otherdirs; - my @checklog=run_log("meson test -C $pgsql --print-errorlogs --no-rebuild --logbase $suite --suite $suite"); - my $status ||= $? >> 8; + @faildirs = (@bindirs, @miscdirs, @moddirs, @contribdirs, @otherdirs); + + my $log = PGBuild::Log->new("misc-check"); + $log->add_log("$pgsql/meson-logs/checkworld.txt"); + foreach my $dir (@faildirs) + { + $log->add_log($_) + foreach ("$dir/regression.diffs", glob("$dir/log/*")); + } + push(@checklog, $log->log_string); - my $log = PGBuild::Log->new("$suite-check"); - $log->add_log("$pgsql/meson-logs/$suite.txt"); - push(@checklog, $log->log_string); - writelog("$suite-check", \@checklog); + if ($status) + { + my $first = $faildirs[0]; + $first = basename (dirname $first); + writelog("$first-check", \@checklog); + print @checklog if ($verbose > 1); + send_result("${first}Check", $status, \@checklog); + } + else + { + writelog("misc-check", \@checklog); print @checklog if ($verbose > 1); - send_result("${suite}Check", $status, \@checklog) if $status; - $steps_completed .= " ${suite}Check"; + $steps_completed .= " MiscCheck"; } return; } @@ -2184,7 +2273,7 @@ sub run_misc_tests sub make_check { return unless step_wanted('check'); - print time_str(), "running make check ...\n" if $verbose; + print time_str(), "running basic regression tests ...\n" if $verbose; my @makeout; if ($using_meson) From e7fddb01cc208c2ed69bcb70f7eec02409995501 Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Tue, 28 Feb 2023 15:42:26 -0500 Subject: [PATCH 12/58] more environment variables required --- run_build.pl | 1 + 1 file changed, 1 insertion(+) diff --git a/run_build.pl b/run_build.pl index a8fd3c0..364a349 100755 --- a/run_build.pl +++ b/run_build.pl @@ -1516,6 +1516,7 @@ sub _meson_env my @safe_set = qw( PATH PGUSER PGHOST PG_TEST_PORT_DIR PG_TEST_EXTRA + PG_TEST_USING_UNIX_SOCKETS PG_REGRESS_SOCK_DIR SystemRoot TEMP TMP USER USERNAME USERDOMAIN); foreach my $setting (@safe_set) From 8b193745b3147496f34ab668c7fcaa9dde752c9e Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Tue, 28 Feb 2023 16:11:04 -0500 Subject: [PATCH 13/58] fix typo --- run_build.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run_build.pl b/run_build.pl index 364a349..b9b8a98 100755 --- a/run_build.pl +++ b/run_build.pl @@ -1516,7 +1516,7 @@ sub _meson_env my @safe_set = qw( PATH PGUSER PGHOST PG_TEST_PORT_DIR PG_TEST_EXTRA - PG_TEST_USING_UNIX_SOCKETS PG_REGRESS_SOCK_DIR + PG_TEST_USE_UNIX_SOCKETS PG_REGRESS_SOCK_DIR SystemRoot TEMP TMP USER USERNAME USERDOMAIN); foreach my $setting (@safe_set) From 6e0b961d144dc93302d2742c276e8162d4e3bb73 Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Wed, 1 Mar 2023 07:06:23 -0500 Subject: [PATCH 14/58] honor PG_TEST_USE_UNIX_SOCKETS --- run_build.pl | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/run_build.pl b/run_build.pl index b9b8a98..c810b9d 100755 --- a/run_build.pl +++ b/run_build.pl @@ -956,6 +956,10 @@ END { $ENV{PGHOST} = $tmpdir; } + elsif ($ENV{PG_TEST_USE_UNIX_SOCKETS}) + { + $ENV{PGHOST} = $tmpdir; + } else { $ENV{PGHOST} = 'localhost'; @@ -1449,13 +1453,16 @@ sub initdb print $handle "\n# Configuration added by buildfarm client\n\n"; - if (!$using_msvc && $Config{osname} !~ /msys|MSWin/) + if ($ENV{PG_TEST_USE_UNIX_SOCKETS} || (!$using_msvc && $Config{osname} !~ /msys|MSWin/)) { + # postgres treats backslash as escape + my $tmpd = $tmpdir; + $tmpd =~ s!\\!/!g; my $param = - $branch eq 'REL9_2_STABLE' + ($branch le 'REL9_2_STABLE' && $branch ne 'HEAD') ? "unix_socket_directory" : "unix_socket_directories"; - print $handle "$param = '$tmpdir'\n"; + print $handle "$param = '$tmpd'\n"; print $handle "listen_addresses = ''\n"; } else @@ -1469,7 +1476,7 @@ sub initdb } close($handle); - if ($using_msvc || $Config{osname} =~ /msys|MSWin/) + if (!$ENV{PG_TEST_USE_UNIX_SOCKETS} && ($using_msvc || $Config{osname} =~ /msys|MSWin/)) { my $pg_regress; From 0fe7b2d7b4741f7bfc61ddacf47d0df1abc0b7fe Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Wed, 1 Mar 2023 07:10:37 -0500 Subject: [PATCH 15/58] find pg_regress in right path for meson --- run_build.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run_build.pl b/run_build.pl index c810b9d..70b2600 100755 --- a/run_build.pl +++ b/run_build.pl @@ -1480,7 +1480,7 @@ sub initdb { my $pg_regress; - if ($using_msvc) + if ($using_msvc && !$using_meson) { $pg_regress = "$abspgsql/Release/pg_regress/pg_regress"; unless (-e "$pg_regress.exe") From e1818721003c2a6ada7d7787c6c18fbcd7c2e485 Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Wed, 1 Mar 2023 12:02:59 -0500 Subject: [PATCH 16/58] protect windows TAP tests from finding the wrong executable --- run_build.pl | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/run_build.pl b/run_build.pl index 70b2600..cfffe35 100755 --- a/run_build.pl +++ b/run_build.pl @@ -1879,6 +1879,16 @@ sub run_meson_noninst_checks print time_str(), "running meson misc tests ...\n" if $verbose; + # move windows executables aside so that the TAP tests find them from + # the tmp_install rather than where they are built. + foreach my $file (glob("$pgsql/src/bin/*/*.exe")) + { + my $exe = basename $file; + next if $exe =~ /built-/; + (my $dest = $file) =~ s/$exe/built-$exe/; + move $exe, $dest; + } + # skip setup, already done # skip regress, done by make_check my @checklog=run_log("meson test -C $pgsql --print-errorlogs --no-rebuild --logbase checkworld --no-suite setup --no-suite regress"); From 23762e8f9f90cce804e43b6cf1a2b25ebe221e37 Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Wed, 1 Mar 2023 15:21:18 -0500 Subject: [PATCH 17/58] fix thinko --- run_build.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run_build.pl b/run_build.pl index cfffe35..daca07c 100755 --- a/run_build.pl +++ b/run_build.pl @@ -1886,7 +1886,7 @@ sub run_meson_noninst_checks my $exe = basename $file; next if $exe =~ /built-/; (my $dest = $file) =~ s/$exe/built-$exe/; - move $exe, $dest; + move $file, $dest; } # skip setup, already done From 46df1cd25b691f676db42633391a9569ce231fa2 Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Fri, 3 Mar 2023 07:59:25 -0500 Subject: [PATCH 18/58] fix path setting, tweak log collection --- run_build.pl | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/run_build.pl b/run_build.pl index daca07c..d359a2f 100755 --- a/run_build.pl +++ b/run_build.pl @@ -2304,7 +2304,8 @@ sub make_check # not sure why we need to do this for msvc, but it works my $inst = $installdir; $inst =~ s/^[a-z]://i; - $ENV{PATH} = "$pgsql/tmp_install$inst/bin;$ENV{PATH}"; + my $abs_pgsql = abs_path($pgsql); + $ENV{PATH} = "$abs_pgsql/tmp_install$inst/bin;$ENV{PATH}"; } @makeout=run_log("meson test -C $pgsql --logbase checklog --print-errorlogs --no-rebuild --suite regress --test-args=--no-locale"); } @@ -2337,9 +2338,9 @@ sub make_check # get the log files and the regression diffs my @logs = - glob("$pgsql/src/test/regress/log/*.log $pgsql/tmp_install/log/* $pgsql/*/checklog.txt"); - unshift(@logs, "$pgsql/src/test/regress/regression.diffs") - if (-e "$pgsql/src/test/regress/regression.diffs"); + glob("$pgsql/src/test/regress/log/*.log $pgsql/tmp_install/log/* $pgsql/*/checklog.txt $pgsql/testrun/regress/regress/log/*"); + unshift @logs, "$_/regression.diffs" + foreach ("$pgsql/src/test/regress","$pgsql/testrun/regress/regress"); $log->add_log($_) foreach (@logs); my $base = "$pgsql/src/test/regress/tmp_check"; if ($status) From 80982d0e26c3d869f9537ac3f16854897e52e6fb Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Sat, 4 Mar 2023 08:56:49 -0500 Subject: [PATCH 19/58] clean up references to config_opts --- PGBuild/Modules/TestICU.pm | 11 +++++++---- PGBuild/Modules/TestMyTap.pm | 4 ++-- run_build.pl | 13 +++++++++++-- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/PGBuild/Modules/TestICU.pm b/PGBuild/Modules/TestICU.pm index 899373c..fa54ed5 100644 --- a/PGBuild/Modules/TestICU.pm +++ b/PGBuild/Modules/TestICU.pm @@ -34,16 +34,19 @@ sub setup my $branch = shift; # The branch of Postgres that's being built. my $conf = shift; # ref to the whole config object my $pgsql = shift; # postgres build dir + my @opts = (@{ $conf->{config_opts} }, @{ $conf->{meson_opts} }); - return unless grep { $_ eq '--with-icu' } @{ $conf->{config_opts} }, + # for autoconf, we require --with-icu to be explicit even if it's the + # default + return unless grep { $_ eq '--with-icu' || $_ eq '-Dicu=enabled' } @opts; - # could even set up several of these (e.g. for different branches) - my $self = { + # could even set up several of these (e.g. for different branches) + my $self = { buildroot => $buildroot, pgbranch => $branch, bfconf => $conf, pgsql => $pgsql - }; + }; bless($self, $class); # for each instance you create, do: diff --git a/PGBuild/Modules/TestMyTap.pm b/PGBuild/Modules/TestMyTap.pm index 5079ad8..a80a9ef 100644 --- a/PGBuild/Modules/TestMyTap.pm +++ b/PGBuild/Modules/TestMyTap.pm @@ -40,9 +40,9 @@ sub setup return unless $branch eq 'HEAD'; - my @opts = @{ $conf->{config_opts} }; + my @opts = (@{ $conf->{config_opts} }, @{ $conf->{meson_opts} }); - return unless grep { /enable-tap-tests/ } @opts; + return unless grep { /enable-tap-tests|-Dtap_tests=enabled/ } @opts; my $tests = $conf->{my_tap_tests}; diff --git a/run_build.pl b/run_build.pl index d359a2f..134539e 100755 --- a/run_build.pl +++ b/run_build.pl @@ -258,8 +258,17 @@ BEGIN $force_every = $force_every->{$branch} || $force_every->{default}; } -my $config_opts = $PGBuild::conf{config_opts}; -my $meson_opts = $PGBuild::conf{meson_opts}; +my ($config_opts, $meson_opts); +if ($using_meson) +{ + $meson_opts = $PGBuild::conf{meson_opts}; + delete $PGBuild::conf{config_opts}; +} +else +{ + $config_opts = $PGBuild::conf{config_opts}; + delete $PGBuild::conf{meson_opts}; +} our ($buildport); From 4ab8afcc946a3bcb25090a7861ebdbf19d3e2882 Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Sat, 4 Mar 2023 09:23:54 -0500 Subject: [PATCH 20/58] add comment re meson redundancy --- PGBuild/Modules/TestUpgrade.pm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/PGBuild/Modules/TestUpgrade.pm b/PGBuild/Modules/TestUpgrade.pm index 85d7c47..9d51454 100644 --- a/PGBuild/Modules/TestUpgrade.pm +++ b/PGBuild/Modules/TestUpgrade.pm @@ -46,6 +46,8 @@ sub setup my $conf = shift; # ref to the whole config object my $pgsql = shift; # postgres build dir + # this obviates the need of any meson support in this module, as + # this has been in since release 15 return if -d "$buildroot/$branch/pgsql/src/bin/pg_upgrade/t"; die From d15789d50be40d6f8297c1effe2fdaa54693524d Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Tue, 7 Mar 2023 15:45:36 -0500 Subject: [PATCH 21/58] fix lazy use of possibly missing reference in commit 80982d0 --- PGBuild/Modules/TestICU.pm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/PGBuild/Modules/TestICU.pm b/PGBuild/Modules/TestICU.pm index fa54ed5..a60c3b4 100644 --- a/PGBuild/Modules/TestICU.pm +++ b/PGBuild/Modules/TestICU.pm @@ -34,7 +34,12 @@ sub setup my $branch = shift; # The branch of Postgres that's being built. my $conf = shift; # ref to the whole config object my $pgsql = shift; # postgres build dir - my @opts = (@{ $conf->{config_opts} }, @{ $conf->{meson_opts} }); + my @opts; + foreach my $k ('config_opts','meson_opts') + { + next unless exists $conf->{$k}; + push @opts, @{ $conf->{$k} } + } # for autoconf, we require --with-icu to be explicit even if it's the # default From 8ff05939f56cfa71e1bbedd9de8aef0b3c006149 Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Wed, 8 Mar 2023 15:52:20 -0500 Subject: [PATCH 22/58] Install test modules in installdir Follow up to upstream commits which made this necessary --- run_build.pl | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/run_build.pl b/run_build.pl index 134539e..d1f2a44 100755 --- a/run_build.pl +++ b/run_build.pl @@ -918,7 +918,7 @@ END make_contrib_install() unless ($using_msvc || $using_meson); make_testmodules_install() - unless ($using_msvc || $using_meson || ($branch ne 'HEAD' && $branch lt 'REL9_5')); + unless ($branch ne 'HEAD' && $branch lt 'REL9_5'); make_check() if $delay_check; @@ -1412,21 +1412,36 @@ sub make_contrib_install sub make_testmodules_install { + return if $using_msvc && ! $using_meson; return unless (step_wanted('testmodules') and step_wanted('install')); - print time_str(), "running make testmodules install ...\n" + print time_str(), "running testmodules install ...\n" if $verbose; - my $tmp_inst = abs_path($pgsql) . "/tmp_install"; - my $cmd = "cd $pgsql/src/test/modules && " - . "$make install && $make DESTDIR=$tmp_inst install"; - my @makeout = run_log($cmd); + my @out; + if ($using_meson) + { + # for meson, the test setup installs these in the tmp_dir but + # the install procedure doesn't install them in $installdir, so + # do that using a special "compile" target + my $cmd = "meson compile -C $pgsql install-test-files"; + @out = run_log($cmd); + } + else + { + # for autoconf, we need to install them in both $tmp_install + # and $installdir + my $tmp_inst = abs_path($pgsql) . "/tmp_install"; + my $cmd = "cd $pgsql/src/test/modules && " + . "$make install && $make DESTDIR=$tmp_inst install"; + @out = run_log($cmd); + } my $status = $? >> 8; - writelog('install-testmodules', \@makeout); - print "======== make testmodules install log ===========\n", @makeout + writelog('install-testmodules', \@out); + print "======== testmodules install log ===========\n", @out if ($verbose > 1); - send_result('TestModulesInstall', $status, \@makeout) if $status; + send_result('TestModulesInstall', $status, \@out) if $status; $steps_completed .= " TestModulesInstall"; return; } From 50bc023ad2749bb103be4552437b47e1636bc94b Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Wed, 8 Mar 2023 17:19:33 -0500 Subject: [PATCH 23/58] use ninja backend even for MSVC --- run_build.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/run_build.pl b/run_build.pl index d1f2a44..71693e3 100755 --- a/run_build.pl +++ b/run_build.pl @@ -2636,8 +2636,8 @@ sub meson_setup qq{-Dprefix="$installdir"}, "-Dpgport=$buildport"); - my $flag = $using_msvc ? "--backend vs" : ""; - my @confout = run_log("meson setup $flag $confstr $pgsql pgsql"); + # use default ninja backend on all platforms + my @confout = run_log("meson setup $confstr $pgsql pgsql"); my $status = $? >> 8; From 518c22c45c5bace87615c1f4f6a4536b7f099fb7 Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Thu, 9 Mar 2023 14:36:40 -0500 Subject: [PATCH 24/58] support for building docs --- run_build.pl | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/run_build.pl b/run_build.pl index 71693e3..829a5ac 100755 --- a/run_build.pl +++ b/run_build.pl @@ -1257,21 +1257,26 @@ sub make sub make_doc { return unless step_wanted('make-doc'); - print time_str(), "running make doc ...\n" if $verbose; + print time_str(), "building docs ...\n" if $verbose; my (@makeout); - unless ($using_msvc) + if ($using_meson) { - my $extra_targets = $PGBuild::conf{extra_doc_targets} || ""; @makeout = - run_log("cd $pgsql/doc/src/sgml && $make html $extra_targets"); + run_log("cd $pgsql && ninja docs"); } - else + elsif ($using_msvc) { chdir "$pgsql/src/tools/msvc"; @makeout = run_log("perl builddoc.pl"); chdir $branch_root; } + else + { + my $extra_targets = $PGBuild::conf{extra_doc_targets} || ""; + @makeout = + run_log("cd $pgsql/doc/src/sgml && $make html $extra_targets"); + } my $status = $? >> 8; writelog('make-doc', \@makeout); print "======== make doc log ===========\n", @makeout if ($verbose > 1); From 338e7afebe6045d0ccb4de78d98a250d0408bc19 Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Thu, 9 Mar 2023 14:37:44 -0500 Subject: [PATCH 25/58] no support yet for checking headers --- PGBuild/Modules/CheckHeaders.pm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/PGBuild/Modules/CheckHeaders.pm b/PGBuild/Modules/CheckHeaders.pm index bd64c21..ed77806 100644 --- a/PGBuild/Modules/CheckHeaders.pm +++ b/PGBuild/Modules/CheckHeaders.pm @@ -36,6 +36,8 @@ sub setup return if $branch ne 'HEAD'; + return if $conf->{using_meson}; # no support yet + # could even set up several of these (e.g. for different branches) my $self = { buildroot => $buildroot, From 7a162e780a7b932d9247d2c06fb8efa17ba7060f Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Thu, 9 Mar 2023 14:38:22 -0500 Subject: [PATCH 26/58] handle some dbname differences in cross version upgrade --- PGBuild/Modules/TestUpgradeXversion.pm | 36 +++++++++++++++++--------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/PGBuild/Modules/TestUpgradeXversion.pm b/PGBuild/Modules/TestUpgradeXversion.pm index c4e2c97..b86e1da 100644 --- a/PGBuild/Modules/TestUpgradeXversion.pm +++ b/PGBuild/Modules/TestUpgradeXversion.pm @@ -99,6 +99,22 @@ sub run_psql ## no critic (Subroutines::ProhibitManyArgs) return; # callers can check $? } +sub dbnames +{ + my $loc = shift; + # collect names of databases. + my $sql = 'select datname from pg_database'; + + run_psql("psql", "-A -t", $sql, "postgres", "$loc-dbnames.data"); + my @dbnames = file_lines("$loc-dbnames.data"); + + chomp @dbnames; + my %dbnames; + do { s/\r$//; $dbnames{$_} = 1; } + foreach @dbnames; + return %dbnames; +} + sub get_lock { my $self = shift; @@ -292,6 +308,8 @@ sub save_for_testing # fix the regression database so its functions point to $libdir rather than # the source directory, which won't persist past this build. + my %dbnames = dbnames("$upgrade_loc/save"); + my $sql = 'select distinct probin::text from pg_proc ' . 'where probin not like $$$libdir%$$'; @@ -325,11 +343,14 @@ sub save_for_testing return if $?; + my $dblink = (grep { /_dblink$/ } keys %dbnames)[0]; + if (($this_branch ge 'REL9_5' || $this_branch eq 'HEAD') - && !$self->{bfconf}->{using_msvc}) + && !$self->{bfconf}->{using_msvc} + && $dblink) { run_psql("$installdir/bin/psql", "-A -t -e", $sql, - "contrib_regression_dblink", "$upgrade_loc/fix.log", 1); + $dblink, "$upgrade_loc/fix.log", 1); return if $?; } @@ -418,16 +439,7 @@ sub test_upgrade ## no critic (Subroutines::ProhibitManyArgs) $sport = $sport + 0; # collect names of databases present in old installation. - my $sql = 'select datname from pg_database'; - - run_psql("psql", "-A -t", $sql, "postgres", - "$upgrade_loc/$oversion-dbnames.data"); - my @dbnames = file_lines("$upgrade_loc/$oversion-dbnames.data"); - - chomp @dbnames; - my %dbnames; - do { s/\r$//; $dbnames{$_} = 1; } - foreach @dbnames; + my %dbnames = dbnames("$upgrade_loc/$oversion"); if ($oversion ne $this_branch) { From b84b9fff74af4fb4370e750b64435adec84f8886 Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Sun, 12 Mar 2023 10:15:53 -0400 Subject: [PATCH 27/58] fix log message --- PGBuild/Modules/TestCollateLinuxUTF8.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PGBuild/Modules/TestCollateLinuxUTF8.pm b/PGBuild/Modules/TestCollateLinuxUTF8.pm index 3017962..b778ed8 100644 --- a/PGBuild/Modules/TestCollateLinuxUTF8.pm +++ b/PGBuild/Modules/TestCollateLinuxUTF8.pm @@ -80,7 +80,7 @@ sub installcheck return unless step_wanted("installcheck-collate-$locale"); - print time_str(), "installchecking $locale", __PACKAGE__, "\n" + print time_str(), "installchecking $locale ", __PACKAGE__, "\n" if $verbose; (my $buildport = $ENV{EXTRA_REGRESS_OPTS}) =~ s/--port=//; From 287937d52d875445a127b7ed83e643be23208131 Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Thu, 16 Mar 2023 18:31:41 -0400 Subject: [PATCH 28/58] build all docs targets, support --from-source --- run_build.pl | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/run_build.pl b/run_build.pl index 829a5ac..ac0a247 100755 --- a/run_build.pl +++ b/run_build.pl @@ -1262,8 +1262,11 @@ sub make_doc my (@makeout); if ($using_meson) { - @makeout = - run_log("cd $pgsql && ninja docs"); + my @targets = ('html'); + push (@targets, split(/\s+/,$PGBuild::conf{extra_doc_targets})) + if $PGBuild::conf{extra_doc_targets}; + do { s!^!doc/src/sgml/! } foreach @targets; + @makeout = run_log("cd $pgsql && ninja " . join (' ',@targets)); } elsif ($using_msvc) { @@ -2641,8 +2644,10 @@ sub meson_setup qq{-Dprefix="$installdir"}, "-Dpgport=$buildport"); + my $srcdir = $from_source || 'pgsql'; + # use default ninja backend on all platforms - my @confout = run_log("meson setup $confstr $pgsql pgsql"); + my @confout = run_log("meson setup $confstr $pgsql $srcdir"); my $status = $? >> 8; From 9c8e3ff14b6356fc925c66b7633fe1d078abf82e Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Fri, 17 Mar 2023 12:39:39 -0400 Subject: [PATCH 29/58] Don't remove install dir on startup unless we are installing --- run_build.pl | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/run_build.pl b/run_build.pl index ac0a247..836e580 100755 --- a/run_build.pl +++ b/run_build.pl @@ -507,9 +507,12 @@ BEGIN # recursively fix any permissions that might stop us removing the directories # then remove old run artefacts if any, die if not possible my $fix_perms = sub { chmod 0700, $_ unless -l $_; }; -File::Find::find($fix_perms, "inst") if -d "inst"; -rmtree("inst"); -die "$installdir exists!" if -e "inst"; +if step_wanted('install') +{ + File::Find::find($fix_perms, "inst") if -d "inst"; + rmtree("inst"); + die "$installdir exists!" if -e "inst"; +} unless ($from_source && !$use_vpath) { File::Find::find($fix_perms, "$pgsql") if -d $pgsql; From 6d42a54e5e8df4cfe0832dc3c96245d02326d0ad Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Sat, 18 Mar 2023 10:54:29 -0400 Subject: [PATCH 30/58] fix thinko --- run_build.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run_build.pl b/run_build.pl index 836e580..8f079c2 100755 --- a/run_build.pl +++ b/run_build.pl @@ -507,7 +507,7 @@ BEGIN # recursively fix any permissions that might stop us removing the directories # then remove old run artefacts if any, die if not possible my $fix_perms = sub { chmod 0700, $_ unless -l $_; }; -if step_wanted('install') +if (step_wanted('install')) { File::Find::find($fix_perms, "inst") if -d "inst"; rmtree("inst"); From 116b52d8e23d7eb14bffe5ed700003c934068c01 Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Sun, 19 Mar 2023 10:13:03 -0400 Subject: [PATCH 31/58] Try to use the right PGHOST dung upgrade --- PGBuild/Modules/TestUpgradeXversion.pm | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/PGBuild/Modules/TestUpgradeXversion.pm b/PGBuild/Modules/TestUpgradeXversion.pm index b86e1da..f4c228b 100644 --- a/PGBuild/Modules/TestUpgradeXversion.pm +++ b/PGBuild/Modules/TestUpgradeXversion.pm @@ -298,6 +298,13 @@ sub save_for_testing setinstenv($self, $installdir, $save_env); + # is this version using unix sockets or localhost? + + my $saveconf = file_contents("$install_loc/data-C/postgresql.conf"); + my $using_localhost = $saveconf =~ /^listen_addresses = 'localhost'/m; + + local $ENV{PGHOST} = $using_localhost ? "localhost" : $ENV{PGHOST}; + # start the server system( qq{"$installdir/bin/pg_ctl" -D "$installdir/data-C" -o -F } @@ -404,11 +411,16 @@ sub test_upgrade ## no critic (Subroutines::ProhibitManyArgs) ); return if $?; + # is the old version using unix sockets or localhost? + + my $oldconf = file_contents("$other_branch/inst/data-C/postgresql.conf"); + my $using_localhost = $oldconf =~ /^listen_addresses = 'localhost'/m; + # The old version will have the unix sockets point to tmpdir from the # run in which it was set up, which will be gone by now, so we repoint # it to the current run's tmpdir. # listen_addresses will be set correctly and requires no adjustment. - unless ($self->{bfconf}->{using_msvc} || $^O eq 'msys') + if (! $using_localhost) { open(my $opgconf, ">>", "$other_branch/inst/$upgrade_test/postgresql.conf") @@ -423,6 +435,8 @@ sub test_upgrade ## no critic (Subroutines::ProhibitManyArgs) setinstenv($self, "$other_branch/inst", $save_env); + local $ENV{PGHOST} = $using_localhost ? "localhost" : $ENV{PGHOST}; + unlink "$other_branch/inst/dump-$this_branch.log"; system( qq{"$other_branch/inst/bin/pg_ctl" -D } @@ -697,7 +711,11 @@ sub installcheck local %ENV = %ENV; - if ($self->{bfconf}->{using_msvc} || $^O eq 'msys') + if ($ENV{PG_TEST_USE_UNIX_SOCKETS}) + { + $ENV{PGHOST} = $tmpdir; + } + elsif ($self->{bfconf}->{using_msvc} || $^O eq 'msys') { $ENV{PGHOST} = 'localhost'; } From 877d961796a33a4d8ada448ca0147ac91f01ab6c Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Tue, 21 Mar 2023 10:11:38 -0400 Subject: [PATCH 32/58] fix xversion upgrade checks --- PGBuild/Modules/TestUpgradeXversion.pm | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/PGBuild/Modules/TestUpgradeXversion.pm b/PGBuild/Modules/TestUpgradeXversion.pm index f4c228b..5ea18dd 100644 --- a/PGBuild/Modules/TestUpgradeXversion.pm +++ b/PGBuild/Modules/TestUpgradeXversion.pm @@ -298,13 +298,6 @@ sub save_for_testing setinstenv($self, $installdir, $save_env); - # is this version using unix sockets or localhost? - - my $saveconf = file_contents("$install_loc/data-C/postgresql.conf"); - my $using_localhost = $saveconf =~ /^listen_addresses = 'localhost'/m; - - local $ENV{PGHOST} = $using_localhost ? "localhost" : $ENV{PGHOST}; - # start the server system( qq{"$installdir/bin/pg_ctl" -D "$installdir/data-C" -o -F } @@ -413,9 +406,11 @@ sub test_upgrade ## no critic (Subroutines::ProhibitManyArgs) # is the old version using unix sockets or localhost? - my $oldconf = file_contents("$other_branch/inst/data-C/postgresql.conf"); + my $oldconf = file_contents("$other_branch/inst/$upgrade_test/postgresql.conf"); my $using_localhost = $oldconf =~ /^listen_addresses = 'localhost'/m; + local $ENV{PGHOST} = $using_localhost ? "localhost" : $ENV{PGHOST}; + # The old version will have the unix sockets point to tmpdir from the # run in which it was set up, which will be gone by now, so we repoint # it to the current run's tmpdir. @@ -435,8 +430,6 @@ sub test_upgrade ## no critic (Subroutines::ProhibitManyArgs) setinstenv($self, "$other_branch/inst", $save_env); - local $ENV{PGHOST} = $using_localhost ? "localhost" : $ENV{PGHOST}; - unlink "$other_branch/inst/dump-$this_branch.log"; system( qq{"$other_branch/inst/bin/pg_ctl" -D } @@ -499,7 +492,7 @@ sub test_upgrade ## no critic (Subroutines::ProhibitManyArgs) . qq{> "$upgrade_loc/$oversion-initdb.log" 2>&1}); return if $?; - unless ($self->{bfconf}->{using_msvc} || $^O eq 'msys') + unless ($using_localhost) { open(my $pgconf, ">>", "$installdir/$oversion-upgrade/postgresql.conf") || die "opening $installdir/$oversion-upgrade/postgresql.conf: $!"; @@ -768,8 +761,11 @@ sub installcheck # ok, we now have the persistent copy of all branches we can use # to test upgrading from - my $dconfig = `$installdir/bin/pg_config --configure`; - my $dport = $dconfig =~ /--with-pgport=(\d+)/ ? $1 : 5432; + my $dport; + { + no warnings 'once'; + $dport = $main::buildport; + } # for other branches ignore the from-source root if it's being used my $stable_root = $self->{upgrade_install_root}; From c870f08b190506db25667ff1700c2215bce66902 Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Wed, 22 Mar 2023 14:57:09 -0400 Subject: [PATCH 33/58] support meson parallel jobs settings --- build-farm.conf.sample | 4 ++++ run_build.pl | 21 ++++++++++++++------- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/build-farm.conf.sample b/build-farm.conf.sample index 6e95fc1..99e3bdd 100644 --- a/build-farm.conf.sample +++ b/build-farm.conf.sample @@ -274,6 +274,10 @@ my $confdir = File::Spec->rel2abs(File::Basename::dirname(__FILE__)); # will be ignored for branches older than 16 using_meson => undef, + # similar to make_jobs above - how much parallelism do you want for + # meson's build and test stages. undef says use meson's default. (1?) + meson_jobs => undef, + # options used with configure (and not for meson) config_opts => [ qw( diff --git a/run_build.pl b/run_build.pl index 8f079c2..e2d5d18 100755 --- a/run_build.pl +++ b/run_build.pl @@ -186,7 +186,7 @@ BEGIN $use_valgrind, $valgrind_options, $use_installcheck_parallel, $max_load_avg, $use_discard_caches, $archive_reports, - $using_meson, + $using_meson, $meson_jobs, ) = @PGBuild::conf{ qw(build_root target animal aux_path trigger_exclude @@ -194,7 +194,7 @@ BEGIN use_vpath tar_log_cmd using_msvc extra_config make_jobs core_file_glob ccache_failure_remove wait_timeout use_accache use_valgrind valgrind_options use_installcheck_parallel max_load_avg - use_discard_caches archive_reports using_meson) + use_discard_caches archive_reports using_meson meson_jobs) }; $using_meson = undef unless $branch eq 'HEAD' || $branch ge 'REL_16_STABLE'; @@ -1233,7 +1233,8 @@ sub make my (@makeout); if ($using_meson) { - @makeout = run_log("meson compile -C $pgsql"); + my $jflag = defined($meson_jobs) ? " --jobs=$meson_jobs" : ""; + @makeout = run_log("meson compile -C $pgsql $jflag"); } elsif ($using_msvc) { @@ -1733,7 +1734,8 @@ sub make_install_check if ($using_meson) { local %ENV = _meson_env(); - @checklog = run_log("meson test -v -C $pgsql --no-rebuild --print-errorlogs --setup running --suite regress-running --logbase regress-installcheck-$locale"); + my $jflag = defined($meson_jobs) ? " --num-processes=$meson_jobs" : ""; + @checklog = run_log("meson test $jflag -v -C $pgsql --no-rebuild --print-errorlogs --setup running --suite regress-running --logbase regress-installcheck-$locale"); } elsif ($using_msvc) { @@ -1840,9 +1842,11 @@ sub run_meson_install_checks unlink "$pgsql/meson-logs/installcheckworld.txt"; rmtree $_ foreach glob("$pgsql/testrun/*-running"); + my $jflag = defined($meson_jobs) ? " --num-processes=$meson_jobs" : ""; + # skip regress, done by make_installcheck # skip isolation and ecpg, done with misc checks - my @checklog=run_log("meson test -C $pgsql --setup running --print-errorlogs --no-rebuild --logbase installcheckworld --no-suite regress-running --no-suite isolation-running --no-suite ecpg-running"); + my @checklog=run_log("meson test $jflag -C $pgsql --setup running --print-errorlogs --no-rebuild --logbase installcheckworld --no-suite regress-running --no-suite isolation-running --no-suite ecpg-running"); my @fails = glob("$pgsql/testrun/*/*/test.fail"); @@ -1924,9 +1928,11 @@ sub run_meson_noninst_checks move $file, $dest; } + my $jflag = defined($meson_jobs) ? " --num-processes $meson_jobs" : ""; + # skip setup, already done # skip regress, done by make_check - my @checklog=run_log("meson test -C $pgsql --print-errorlogs --no-rebuild --logbase checkworld --no-suite setup --no-suite regress"); + my @checklog=run_log("meson test $jflag -C $pgsql --print-errorlogs --no-rebuild --logbase checkworld --no-suite setup --no-suite regress"); my @fails = glob("$pgsql/testrun/*/*/test.fail"); @@ -2342,7 +2348,8 @@ sub make_check my $abs_pgsql = abs_path($pgsql); $ENV{PATH} = "$abs_pgsql/tmp_install$inst/bin;$ENV{PATH}"; } - @makeout=run_log("meson test -C $pgsql --logbase checklog --print-errorlogs --no-rebuild --suite regress --test-args=--no-locale"); + my $jflag = defined($meson_jobs) ? " --num-processes=$meson_jobs" : ""; + @makeout=run_log("meson test $jflag -C $pgsql --logbase checklog --print-errorlogs --no-rebuild --suite regress --test-args=--no-locale"); } elsif ($using_msvc) { From 6ee89bdd6e9696b9811087611c2fb1c01e73a298 Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Fri, 24 Mar 2023 07:37:53 -0400 Subject: [PATCH 34/58] Fixes for PG_TEST_USE_UNIX_SOCKETS --- run_build.pl | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/run_build.pl b/run_build.pl index e2d5d18..4107e85 100755 --- a/run_build.pl +++ b/run_build.pl @@ -385,6 +385,9 @@ BEGIN # set environment from config while (my ($envkey, $envval) = each %{ $PGBuild::conf{build_env} }) { + # ignore this setting for branches older than 13 + next if $envkey eq 'PG_TEST_USE_UNIX_SOCKETS' && + $branch lt "REL_13_STABLE" && $branch ne 'HEAD'; $ENV{$envkey} = $envval; } @@ -421,6 +424,13 @@ BEGIN ); umask $oldmask unless $using_msvc; +my $vtmpdir = $tmpdir; +if ($Config{osname} =~ /msys/i) +{ + $tmpdir = `cygpath -a -m $tmpdir`; + chomp $tmpdir; +} + my $scm = PGBuild::SCM->new(\%PGBuild::conf); if (!$from_source) { @@ -720,8 +730,8 @@ END if ($extra_config && $extra_config->{$branch}) { - my $tmpname = "$tmpdir/bfextra.conf"; - open($extraconf, ">", "$tmpname") || die 'opening $tmpname $!'; + my $tmpname = "$vtmpdir/bfextra.conf"; + open($extraconf, ">", "$tmpname") || die "opening $tmpname $!"; $ENV{TEMP_CONFIG} = $tmpname; foreach my $line (@{ $extra_config->{$branch} }) { From b16aa3868fea826a7eb00858e0cc307cf0d0bdd3 Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Tue, 28 Mar 2023 11:38:58 -0400 Subject: [PATCH 35/58] collect meson logs --- run_build.pl | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/run_build.pl b/run_build.pl index 4107e85..37a8e1c 100755 --- a/run_build.pl +++ b/run_build.pl @@ -1245,6 +1245,13 @@ sub make { my $jflag = defined($meson_jobs) ? " --jobs=$meson_jobs" : ""; @makeout = run_log("meson compile -C $pgsql $jflag"); + move "$pgsql/meson-logs/meson-log.txt", "$pgsql/meson-logs/compile.log"; + if (-s "$pgsql/meson-logs/compile.log") + { + my $log = PGBuild::Log->new("compile"); + $log->add_log("$pgsql/meson-logs/compile.log"); + push(@makeout,$log->log_string); + } } elsif ($using_msvc) { @@ -1311,6 +1318,13 @@ sub make_install if($using_meson) { @makeout = run_log("meson install -C $pgsql "); + move "$pgsql/meson-logs/meson-log.txt","$pgsql/meson-logs/install.log"; + my $log = PGBuild::Log->new("install"); + if (-s "$pgsql/meson-logs/install.log") + { + $log->add_file("$pgsql/meson-logs/install.log"); + push(@makeout, $log->log_string); + } } elsif ($using_msvc) { @@ -2671,16 +2685,18 @@ sub meson_setup my $status = $? >> 8; - print "======== configure output ===========\n", @confout - if ($verbose > 1); + move "$pgsql/meson-logs/meson-log.txt", "$pgsql/meson-logs/setup.log"; - if (-s "$pgsql/config.log") + if (-s "$pgsql/meson-logs/setup.log") { - push(@confout, - "\n\n================= config.log ================\n\n", - file_lines("$pgsql/config.log")); + my $log = PGBuild::log->new("setup"); + $log->add_log("$pgsql/meson-logs/setup.log"); + push(@confout,$log->log_string); } + print "======== setup output ===========\n", @confout + if ($verbose > 1); + writelog('configure', \@confout); if ($status) @@ -2873,9 +2889,9 @@ sub configure if (-s "$pgsql/config.log") { - push(@confout, - "\n\n================= config.log ================\n\n", - file_lines("$pgsql/config.log")); + my $log = PGBuild::Log->new("configure"); + $log->add_log("$pgsql/config.log"); + push(@confout,$log->log_string); } writelog('configure', \@confout); From ac3ff4ea9b29f84b0d81e86e1974665c8b190c0a Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Fri, 31 Mar 2023 10:10:20 -0400 Subject: [PATCH 36/58] fix typo --- run_build.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run_build.pl b/run_build.pl index 37a8e1c..35dd9a4 100755 --- a/run_build.pl +++ b/run_build.pl @@ -2689,7 +2689,7 @@ sub meson_setup if (-s "$pgsql/meson-logs/setup.log") { - my $log = PGBuild::log->new("setup"); + my $log = PGBuild::Log->new("setup"); $log->add_log("$pgsql/meson-logs/setup.log"); push(@confout,$log->log_string); } From d44102454ff16e07ad9c26db4fddf024656095bd Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Mon, 3 Apr 2023 08:35:20 -0400 Subject: [PATCH 37/58] typdefs improvements ignore postmaster.exe even if it's not a symlink, since it should be identical to postgres.exe remove use of external egrep -Ann in favor of a simple perl function doing the same thing. --- run_build.pl | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/run_build.pl b/run_build.pl index 35dd9a4..a226aee 100755 --- a/run_build.pl +++ b/run_build.pl @@ -2479,6 +2479,22 @@ sub make_ecpg_check return; } +# replace previous use of external egrep -A +sub _dump_filter +{ + my ($lines, $tag, $context) = @_; + my @output; + while (@$lines) + { + my $line = shift @$lines; + if (index($line,$tag) > -1) + { + push(@output, splice(@$lines,0,$context)); + } + } + return @output; +} + sub find_typedefs { my ($hostobjdump) = grep { /--host=/ } @$config_opts; @@ -2533,12 +2549,14 @@ sub find_typedefs { next if $bin =~ m!bin/(ipcclean|pltcl_)!; next unless -f $bin; - next if -l $bin; # ignore symlinks to plain files (e.g. postmaster) + next if -l $bin; # ignore symlinks to plain files + next if $bin =~ m!/postmaster.exe$!; # sometimes a copy not a link + if ($using_osx) { # no run_log due to redirections. - @dumpout = - `dwarfdump $bin 2>/dev/null | egrep -A2 TAG_typedef 2>/dev/null`; + @dumpout = `dwarfdump $bin 2>/dev/null`; + @dumpout = _dump_filter(\@dumpout,'TAG_typedef',2); foreach (@dumpout) { ## no critic (RegularExpressions::ProhibitCaptureWithoutTest) @@ -2561,9 +2579,9 @@ sub find_typedefs } elsif (@err == 1) # Linux and sometimes windows { - my $cmd = "$objdump -Wi $bin 2>/dev/null | " - . "egrep -A3 DW_TAG_typedef 2>/dev/null"; + my $cmd = "$objdump -Wi $bin 2>/dev/null"; @dumpout = `$cmd`; # no run_log because of redirections + @dumpout = _dump_filter(\@dumpout,'DW_TAG_typedef',3); foreach (@dumpout) { @flds = split; @@ -2578,10 +2596,10 @@ sub find_typedefs { # FreeBSD, similar output to Linux - my $cmd = "readelf -w $bin 2>/dev/null | " - . "egrep -A3 DW_TAG_typedef 2>/dev/null"; - + my $cmd = "readelf -w $bin 2>/dev/null"; @dumpout = ` $cmd`; # no run_log due to redirections + @dumpout = _dump_filter(\@dumpout,'DW_TAG_typedef',3); + foreach (@dumpout) { @flds = split; From b18a129f91352f77e67084a758462b92ac1abaf7 Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Wed, 5 Apr 2023 16:45:35 -0400 Subject: [PATCH 38/58] fix docs builds for meson update --- run_build.pl | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/run_build.pl b/run_build.pl index a226aee..bfbb935 100755 --- a/run_build.pl +++ b/run_build.pl @@ -1283,11 +1283,8 @@ sub make_doc my (@makeout); if ($using_meson) { - my @targets = ('html'); - push (@targets, split(/\s+/,$PGBuild::conf{extra_doc_targets})) - if $PGBuild::conf{extra_doc_targets}; - do { s!^!doc/src/sgml/! } foreach @targets; - @makeout = run_log("cd $pgsql && ninja " . join (' ',@targets)); + my $extra_targets = $PGBuild::conf{extra_doc_targets} || ""; + @makeout = run_log("meson compile -C $pgsql html $extra_targets"); } elsif ($using_msvc) { @@ -2689,9 +2686,16 @@ sub meson_setup } } + my $docs_opts=""; + $docs_opts = "-Ddocs=enabled" + if defined($PGBuild::conf{optional_steps}->{build_docs}); + $docs_opts .= " -Ddocs_pdf=enabled" + if $docs_opts && ($PGBuild::conf{extra_doc_targets} || "") =~ /[.]pdf/; + my $confstr = join(" ", "-Dauto_features=disabled", @quoted_opts, + $docs_opts, "-Dlibdir=lib", qq{-Dprefix="$installdir"}, "-Dpgport=$buildport"); From 96610ead9c844b5fcae2b1b27e9af9439fb15541 Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Thu, 6 Apr 2023 07:36:15 -0400 Subject: [PATCH 39/58] adjust meson environment settings --- run_build.pl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/run_build.pl b/run_build.pl index bfbb935..c37f8ca 100755 --- a/run_build.pl +++ b/run_build.pl @@ -908,6 +908,10 @@ END configure(); } +# force this on to avoid meson errors on build +local $ENV{MSYS} = $ENV{MSYS} || ""; +$ENV{MSYS} .= " winjitdebug" if ($using_meson); + # module configure has to wait until we have built and installed the base # so see below @@ -1581,7 +1585,8 @@ sub _meson_env PATH PGUSER PGHOST PG_TEST_PORT_DIR PG_TEST_EXTRA PG_TEST_USE_UNIX_SOCKETS PG_REGRESS_SOCK_DIR - SystemRoot TEMP TMP + SystemRoot TEMP TMP MSYS + TEMP_CONFIG PGCTLTIMEOUT USER USERNAME USERDOMAIN); foreach my $setting (@safe_set) { From 47c6e8b008491777afbd593c7935bf5fbf01d36b Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Sun, 9 Apr 2023 08:18:54 -0400 Subject: [PATCH 40/58] Provide --skip-suites option for skipping particular test suites --- PGBuild/Options.pm | 4 +++- run_build.pl | 21 +++++++++++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/PGBuild/Options.pm b/PGBuild/Options.pm index 39bfa3f..80c615d 100644 --- a/PGBuild/Options.pm +++ b/PGBuild/Options.pm @@ -26,7 +26,7 @@ BEGIN @option_list = qw( $forcerun $buildconf $keepall $help $quiet $from_source $from_source_clean $testmode - $skip_steps $only_steps $find_typedefs + $skip_steps $only_steps $skip_suites $find_typedefs $nosend $nostatus $verbose @config_set $schedule $tests $check_warnings $delay_check $show_error_log $avoid_ts_collisions @@ -49,6 +49,7 @@ our ( $nostatus, $verbose, @config_set, $schedule, $tests, $check_warnings, $delay_check, $show_error_log, $avoid_ts_collisions, + $skip_suites ); my (%standard_options); @@ -68,6 +69,7 @@ my (%standard_options); 'quiet' => \$quiet, 'skip-steps=s' => \$skip_steps, 'only-steps=s' => \$only_steps, + 'skip-suites=s' => \$skip_suites, 'config-set=s' => \@config_set, 'schedule=s' => \$schedule, 'tests=s' => \$tests, diff --git a/run_build.pl b/run_build.pl index c37f8ca..893357f 100755 --- a/run_build.pl +++ b/run_build.pl @@ -144,6 +144,12 @@ BEGIN { %only_steps = map { $_ => 1 } split(/\s+/, $only_steps); } +our %skip_suites; +$skip_suites ||= ""; +if ($skip_suites =~ /\S/) +{ + %skip_suites = map { $_ => 1 } split(/\s+/, $skip_suites); +} our ($branch); my $explicit_branch = shift; @@ -1872,7 +1878,13 @@ sub run_meson_install_checks # skip regress, done by make_installcheck # skip isolation and ecpg, done with misc checks - my @checklog=run_log("meson test $jflag -C $pgsql --setup running --print-errorlogs --no-rebuild --logbase installcheckworld --no-suite regress-running --no-suite isolation-running --no-suite ecpg-running"); + my $skip = "--no-suite regress-running --no-suite isolation-running --no-suite ecpg-running"; + foreach my $sk (keys %skip_suites) + { + $skip .= " --no-suite $sk-running"; + } + + my @checklog=run_log("meson test $jflag -C $pgsql --setup running --print-errorlogs --no-rebuild --logbase installcheckworld $skip"); my @fails = glob("$pgsql/testrun/*/*/test.fail"); @@ -1958,7 +1970,12 @@ sub run_meson_noninst_checks # skip setup, already done # skip regress, done by make_check - my @checklog=run_log("meson test $jflag -C $pgsql --print-errorlogs --no-rebuild --logbase checkworld --no-suite setup --no-suite regress"); + my $skip = "--no-suite setup --no-suite regress"; + foreach my $sk (keys %skip_suites) + { + $skip .= " --no-suite $sk"; + } + my @checklog=run_log("meson test $jflag -C $pgsql --print-errorlogs --no-rebuild --logbase checkworld $skip"); my @fails = glob("$pgsql/testrun/*/*/test.fail"); From c0d84bb66dc6a7d12e83264794c68121846258a4 Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Thu, 13 Apr 2023 08:02:24 -0400 Subject: [PATCH 41/58] skip pg_bsd_indent tests on msvc as it's not built --- run_build.pl | 1 + 1 file changed, 1 insertion(+) diff --git a/run_build.pl b/run_build.pl index 893357f..56551c2 100755 --- a/run_build.pl +++ b/run_build.pl @@ -2354,6 +2354,7 @@ sub run_misc_tests my $testname = basename($testdir); next if $testname =~ /ssl/ && !$using_ssl; next unless -d "$testdir/t"; + next if !$using_meson && $using_msvc && $testname eq 'pg_bsd_indent'; next unless step_wanted("module-$testname"); print time_str(), "running misc test module-$testname ...\n" if $verbose; From 2b670dfd0ef79efad572332794bd74dc1b339eed Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Thu, 13 Apr 2023 09:16:40 -0400 Subject: [PATCH 42/58] remove redundant logic --- run_build.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run_build.pl b/run_build.pl index 56551c2..c78796b 100755 --- a/run_build.pl +++ b/run_build.pl @@ -2354,7 +2354,7 @@ sub run_misc_tests my $testname = basename($testdir); next if $testname =~ /ssl/ && !$using_ssl; next unless -d "$testdir/t"; - next if !$using_meson && $using_msvc && $testname eq 'pg_bsd_indent'; + next if $using_msvc && $testname eq 'pg_bsd_indent'; next unless step_wanted("module-$testname"); print time_str(), "running misc test module-$testname ...\n" if $verbose; From 43fef8e317a65d2b23c866e5deb64bee066ad9c5 Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Thu, 13 Apr 2023 10:44:39 -0400 Subject: [PATCH 43/58] prevent msys2 converting some paths we don't want converted --- run_build.pl | 1 + 1 file changed, 1 insertion(+) diff --git a/run_build.pl b/run_build.pl index c78796b..56f6cf4 100755 --- a/run_build.pl +++ b/run_build.pl @@ -2691,6 +2691,7 @@ sub meson_setup $env = { %$env }; # clone it delete $env->{CC} if $using_msvc; # this can confuse meson in this case local %ENV = (%ENV, %$env); + $ENV{MSYS2_ARG_CONV_EXCL} = "-Dextra"; my @quoted_opts; foreach my $c_opt (@$meson_opts) From 764d6b23fa249a210961c6e27a67afd3927677e1 Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Sat, 15 Apr 2023 08:06:20 -0400 Subject: [PATCH 44/58] run meson compile in verbose mode --- build-farm.conf.sample | 4 +++- run_build.pl | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/build-farm.conf.sample b/build-farm.conf.sample index 99e3bdd..be9a019 100644 --- a/build-farm.conf.sample +++ b/build-farm.conf.sample @@ -300,10 +300,12 @@ my $confdir = File::Spec->rel2abs(File::Basename::dirname(__FILE__)); # Note, for meson we turn off all the auto options and then selectively # re-enable them using these options, so zlib and readline have to be # explicitly enabled here. + # see meson docs re interaction of buildtype, debug and + # optimization settings. debugoptimised = debug:on + optimisation:2 meson_opts => [ qw( -Dcassert=true - -Ddebug=true + -Dbuildtype=debugoptimized -Dnls=enabled -Dplperl=enabled -Dplpython=enabled diff --git a/run_build.pl b/run_build.pl index 56f6cf4..e412e2f 100755 --- a/run_build.pl +++ b/run_build.pl @@ -1254,7 +1254,7 @@ sub make if ($using_meson) { my $jflag = defined($meson_jobs) ? " --jobs=$meson_jobs" : ""; - @makeout = run_log("meson compile -C $pgsql $jflag"); + @makeout = run_log("meson compile -C $pgsql --verbose $jflag"); move "$pgsql/meson-logs/meson-log.txt", "$pgsql/meson-logs/compile.log"; if (-s "$pgsql/meson-logs/compile.log") { From 356264c89c152a81177e5065fba2ec385798e9a3 Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Sun, 16 Apr 2023 08:40:09 -0400 Subject: [PATCH 45/58] use a different prefix in test mode, to avoid clobbering files --- run_build.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run_build.pl b/run_build.pl index e412e2f..795d6c3 100755 --- a/run_build.pl +++ b/run_build.pl @@ -386,7 +386,7 @@ BEGIN $devnull = $using_msvc ? "nul" : "/dev/null"; -$st_prefix = "$animal."; +$st_prefix = $testmode ? "$animal-test." : "$animal."; # set environment from config while (my ($envkey, $envval) = each %{ $PGBuild::conf{build_env} }) From 1192151e4aaf2233dcf80984f011e0886275a2d1 Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Sun, 16 Apr 2023 09:07:46 -0400 Subject: [PATCH 46/58] don't force the next run from test mode, as we're using a different prefix --- run_build.pl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/run_build.pl b/run_build.pl index 795d6c3..cb5b5ec 100755 --- a/run_build.pl +++ b/run_build.pl @@ -549,7 +549,8 @@ BEGIN # if it's not a regular run, make sure we force the next run # this run could defeat the up-to-date checks -if (($nosend || $nostatus) && !$from_source) +# unless it's in testmode, which uses a different prefix +if (($nosend || $nostatus) && !$from_source && !$testmode) { open(my $fh, '>', $forcefile) || die "opening $forcefile: $!"; close($fh); From 2d61885d74f1a14278c699b275414de93ef0f4ee Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Mon, 17 Apr 2023 16:45:22 -0400 Subject: [PATCH 47/58] try to get msys objdump running faster --- run_build.pl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/run_build.pl b/run_build.pl index cb5b5ec..7dc77d3 100755 --- a/run_build.pl +++ b/run_build.pl @@ -2518,6 +2518,11 @@ sub _dump_filter sub find_typedefs { + # work around the fact that ucrt/binutils objdump is far slower + # than the one in msys/binutils + local $ENV{PATH} = $ENV{PATH}; + $ENV{PATH} = "/usr/bin:$ENV{PATH}" if ($Config{osname} eq 'msys'; + my ($hostobjdump) = grep { /--host=/ } @$config_opts; $hostobjdump ||= ""; $hostobjdump =~ s/--host=(.*)/$1-objdump/; From eb8f1b2826fc52061b90a34bb05d614a1d6db199 Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Mon, 17 Apr 2023 22:51:29 -0400 Subject: [PATCH 48/58] fix typo --- run_build.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run_build.pl b/run_build.pl index 7dc77d3..22ed535 100755 --- a/run_build.pl +++ b/run_build.pl @@ -2521,7 +2521,7 @@ sub find_typedefs # work around the fact that ucrt/binutils objdump is far slower # than the one in msys/binutils local $ENV{PATH} = $ENV{PATH}; - $ENV{PATH} = "/usr/bin:$ENV{PATH}" if ($Config{osname} eq 'msys'; + $ENV{PATH} = "/usr/bin:$ENV{PATH}" if $Config{osname} eq 'msys'; my ($hostobjdump) = grep { /--host=/ } @$config_opts; $hostobjdump ||= ""; From 26fbe5f9d3334b30a66dab652e7567276ba5b841 Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Wed, 19 Apr 2023 07:36:12 -0400 Subject: [PATCH 49/58] tighten up TAP arget, find more log files --- run_build.pl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/run_build.pl b/run_build.pl index 22ed535..608058b 100755 --- a/run_build.pl +++ b/run_build.pl @@ -2069,7 +2069,7 @@ sub make_misc_check my @out = run_log("cd $dir && $make $instflags TAP_TESTS= check"); $status ||= $? >> 8; push(@checklog, "=========== Module $test check =============\n", @out); - my @logs = glob("$dir/regression.diffs $dir/log/*.log"); + my @logs = glob("$dir/regression.diffs $dir/*/regression.diffs $dir/log/*.log"); $log->add_log($_) foreach (@logs); } push(@checklog, $log->log_string); @@ -2212,6 +2212,7 @@ sub run_tap_test my $is_install_check = shift; my $taptarget = $is_install_check ? "installcheck" : "check"; + my $targname = "prove_$taptarget"; return unless step_wanted("$testname-$taptarget"); @@ -2248,7 +2249,7 @@ sub run_tap_test my $instflags = $temp_inst_ok ? "NO_TEMP_INSTALL=yes" : ""; @makeout = - run_log("cd $dir && $make NO_LOCALE=1 $pflags $instflags $taptarget"); + run_log("cd $dir && $make NO_LOCALE=1 $pflags $instflags $targname"); } my $status = $? >> 8; From 0c4b5823c044f5421bf3c81ac421c16d47af810f Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Wed, 19 Apr 2023 11:01:10 -0400 Subject: [PATCH 50/58] Revert "tighten up TAP arget, find more log files" This reverts commit cfbb2b428bb5c40b7809cafd12915e21ef196420. This was ill-considered. --- run_build.pl | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/run_build.pl b/run_build.pl index 608058b..22ed535 100755 --- a/run_build.pl +++ b/run_build.pl @@ -2069,7 +2069,7 @@ sub make_misc_check my @out = run_log("cd $dir && $make $instflags TAP_TESTS= check"); $status ||= $? >> 8; push(@checklog, "=========== Module $test check =============\n", @out); - my @logs = glob("$dir/regression.diffs $dir/*/regression.diffs $dir/log/*.log"); + my @logs = glob("$dir/regression.diffs $dir/log/*.log"); $log->add_log($_) foreach (@logs); } push(@checklog, $log->log_string); @@ -2212,7 +2212,6 @@ sub run_tap_test my $is_install_check = shift; my $taptarget = $is_install_check ? "installcheck" : "check"; - my $targname = "prove_$taptarget"; return unless step_wanted("$testname-$taptarget"); @@ -2249,7 +2248,7 @@ sub run_tap_test my $instflags = $temp_inst_ok ? "NO_TEMP_INSTALL=yes" : ""; @makeout = - run_log("cd $dir && $make NO_LOCALE=1 $pflags $instflags $targname"); + run_log("cd $dir && $make NO_LOCALE=1 $pflags $instflags $taptarget"); } my $status = $? >> 8; From 2eb1559ca073c25f495224ba9ce1738b6e7d3a4c Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Wed, 26 Apr 2023 20:09:06 -0400 Subject: [PATCH 51/58] Try to use IPC::Run::run if available for stopdb using system() for "pg_ctl stop" is causing some unexplained problems on meson builds on msys2, but IPC::Run seems to work, so use that if it's available. --- run_build.pl | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/run_build.pl b/run_build.pl index 22ed535..fa29995 100755 --- a/run_build.pl +++ b/run_build.pl @@ -99,6 +99,9 @@ BEGIN $devnull $send_result_routine $ts_prefix); use PGBuild::Log; +# check if we have IPC::Run, but don't make it a hard requirement +our $have_ipc_run = eval { require IPC::Run; 1; }; + $send_result_routine = \&send_res; # make sure we exit nicely on any normal interrupt @@ -1717,8 +1720,16 @@ sub stop_db my $locale = shift; my $logpos = -s "$installdir/logfile" || 0; chdir($installdir); - my $cmd = qq{"bin/pg_ctl" -D data-$locale stop >stoplog 2>&1}; - system($cmd); + if ($have_ipc_run) + { + my $cmd = ['bin/pg_ctl', "-D", "data-$locale", "stop"]; + IPC::Run::run $cmd, \"" , ">&stoplog"; + } + else + { + my $cmd = qq{"bin/pg_ctl" -D data-$locale stop >stoplog 2>&1}; + system($cmd); + } my $status = $? >> 8; chdir($branch_root); if ($use_valgrind) From dc735ba523a702262d8df6d673079633d64465b9 Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Wed, 26 Apr 2023 21:10:02 -0400 Subject: [PATCH 52/58] tweak IPC:Run usage --- run_build.pl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/run_build.pl b/run_build.pl index fa29995..c659e21 100755 --- a/run_build.pl +++ b/run_build.pl @@ -1722,8 +1722,9 @@ sub stop_db chdir($installdir); if ($have_ipc_run) { + my $in = ""; my $cmd = ['bin/pg_ctl', "-D", "data-$locale", "stop"]; - IPC::Run::run $cmd, \"" , ">&stoplog"; + IPC::Run::run($cmd, \$in , ">&stoplog"); } else { From 0506c87a6e0d843e77cc881eee8e58f0ee6d033c Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Wed, 10 May 2023 04:26:11 -0400 Subject: [PATCH 53/58] add config examples for pkgconf --- build-farm.conf.sample | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/build-farm.conf.sample b/build-farm.conf.sample index be9a019..8940482 100644 --- a/build-farm.conf.sample +++ b/build-farm.conf.sample @@ -253,6 +253,12 @@ my $confdir = File::Spec->rel2abs(File::Basename::dirname(__FILE__)); # This example makes the regression tests run with extra # checking of user names created by the tests # CPPFLAGS => '-DENFORCE_REGRESSION_TEST_NAME_RESTRICTIONS', + + # where to find a usable pkg-config or equivalent + # see for example https://github.com/pkgconf/pkgconf + # PKG_CONFIG => 'c:/path/to/pkg-config.exe', + # PATH-style list of extra directories to search for .pc files + # PKG_CONFIG_PATH => 'c:/path/to/libxml/pkgconfig', }, # settings added to those in config_env if valgrind is being used From 7a0f7c23361af096e17136822a5570d9f03b70eb Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Wed, 10 May 2023 04:40:37 -0400 Subject: [PATCH 54/58] add meson test timeout support --- build-farm.conf.sample | 4 ++++ run_build.pl | 13 ++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/build-farm.conf.sample b/build-farm.conf.sample index 8940482..6186fa3 100644 --- a/build-farm.conf.sample +++ b/build-farm.conf.sample @@ -284,6 +284,10 @@ my $confdir = File::Spec->rel2abs(File::Basename::dirname(__FILE__)); # meson's build and test stages. undef says use meson's default. (1?) meson_jobs => undef, + # timeout multiplier for meson test jobs. + # default if value is undefined is 3, 0 means no timeout + meson_test_timeout => undef, + # options used with configure (and not for meson) config_opts => [ qw( diff --git a/run_build.pl b/run_build.pl index c659e21..69d9ab5 100755 --- a/run_build.pl +++ b/run_build.pl @@ -196,6 +196,7 @@ BEGIN $use_installcheck_parallel, $max_load_avg, $use_discard_caches, $archive_reports, $using_meson, $meson_jobs, + $meson_test_timeout ) = @PGBuild::conf{ qw(build_root target animal aux_path trigger_exclude @@ -203,10 +204,12 @@ BEGIN use_vpath tar_log_cmd using_msvc extra_config make_jobs core_file_glob ccache_failure_remove wait_timeout use_accache use_valgrind valgrind_options use_installcheck_parallel max_load_avg - use_discard_caches archive_reports using_meson meson_jobs) + use_discard_caches archive_reports using_meson meson_jobs + meson_test_timeout) }; $using_meson = undef unless $branch eq 'HEAD' || $branch ge 'REL_16_STABLE'; +$meson_test_timeout //= 3; $ts_prefix = sprintf('%s:%-13s ', $animal, $branch); @@ -1780,7 +1783,7 @@ sub make_install_check { local %ENV = _meson_env(); my $jflag = defined($meson_jobs) ? " --num-processes=$meson_jobs" : ""; - @checklog = run_log("meson test $jflag -v -C $pgsql --no-rebuild --print-errorlogs --setup running --suite regress-running --logbase regress-installcheck-$locale"); + @checklog = run_log("meson test -t $meson_test_timeout $jflag -v -C $pgsql --no-rebuild --print-errorlogs --setup running --suite regress-running --logbase regress-installcheck-$locale"); } elsif ($using_msvc) { @@ -1897,7 +1900,7 @@ sub run_meson_install_checks $skip .= " --no-suite $sk-running"; } - my @checklog=run_log("meson test $jflag -C $pgsql --setup running --print-errorlogs --no-rebuild --logbase installcheckworld $skip"); + my @checklog=run_log("meson test -t $meson_test_timeout $jflag -C $pgsql --setup running --print-errorlogs --no-rebuild --logbase installcheckworld $skip"); my @fails = glob("$pgsql/testrun/*/*/test.fail"); @@ -1988,7 +1991,7 @@ sub run_meson_noninst_checks { $skip .= " --no-suite $sk"; } - my @checklog=run_log("meson test $jflag -C $pgsql --print-errorlogs --no-rebuild --logbase checkworld $skip"); + my @checklog=run_log("meson test -t $meson_test_timeout $jflag -C $pgsql --print-errorlogs --no-rebuild --logbase checkworld $skip"); my @fails = glob("$pgsql/testrun/*/*/test.fail"); @@ -2406,7 +2409,7 @@ sub make_check $ENV{PATH} = "$abs_pgsql/tmp_install$inst/bin;$ENV{PATH}"; } my $jflag = defined($meson_jobs) ? " --num-processes=$meson_jobs" : ""; - @makeout=run_log("meson test $jflag -C $pgsql --logbase checklog --print-errorlogs --no-rebuild --suite regress --test-args=--no-locale"); + @makeout=run_log("meson test -t $meson_test_timeout $jflag -C $pgsql --logbase checklog --print-errorlogs --no-rebuild --suite regress --test-args=--no-locale"); } elsif ($using_msvc) { From a51f21c6aa5c3da5db59faa45b5528db44547fa1 Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Wed, 17 May 2023 21:59:39 -0400 Subject: [PATCH 55/58] Redirect stdin in start_db() This solves an issue on recet Msys2 where pg_ctl tried to grab a shared resource, so if "pgctl start" is still running, as it will be, "pg_ctl stop" will fail as it can't grab the resource. Per diagnosis and suggestion from Andre Freund. The reverts commits dc735ba and 2eb1559 Discussion: https://postgr.es/m/848511.1682519554@sss.pgh.pa.us --- run_build.pl | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/run_build.pl b/run_build.pl index 69d9ab5..73a5e05 100755 --- a/run_build.pl +++ b/run_build.pl @@ -99,9 +99,6 @@ BEGIN $devnull $send_result_routine $ts_prefix); use PGBuild::Log; -# check if we have IPC::Run, but don't make it a hard requirement -our $have_ipc_run = eval { require IPC::Run; 1; }; - $send_result_routine = \&send_res; # make sure we exit nicely on any normal interrupt @@ -1684,9 +1681,10 @@ sub start_db # clear log file each time we start # seem to need an intermediate file here to get round Windows bogosity + # we need to redirect input from devnull to avoid issues on msys2 chdir($installdir); my $cmd = - qq{"bin/pg_ctl" -D data-$locale -l logfile -w start >startlog 2>&1}; + qq{"bin/pg_ctl" -D data-$locale -l logfile -w start <$devnull >startlog 2>&1}; system($cmd); } @@ -1723,17 +1721,8 @@ sub stop_db my $locale = shift; my $logpos = -s "$installdir/logfile" || 0; chdir($installdir); - if ($have_ipc_run) - { - my $in = ""; - my $cmd = ['bin/pg_ctl', "-D", "data-$locale", "stop"]; - IPC::Run::run($cmd, \$in , ">&stoplog"); - } - else - { - my $cmd = qq{"bin/pg_ctl" -D data-$locale stop >stoplog 2>&1}; - system($cmd); - } + my $cmd = qq{"bin/pg_ctl" -D data-$locale stop >stoplog 2>&1}; + system($cmd); my $status = $? >> 8; chdir($branch_root); if ($use_valgrind) From 101675d2ef5cf90b426c9fb2aa334a5678667b17 Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Sat, 27 May 2023 12:11:16 -0400 Subject: [PATCH 56/58] Let 'build' be a synonym for 'make' in skip/only steps --- run_build.pl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/run_build.pl b/run_build.pl index 73a5e05..06af491 100755 --- a/run_build.pl +++ b/run_build.pl @@ -138,11 +138,13 @@ BEGIN if ($skip_steps =~ /\S/) { %skip_steps = map { $_ => 1 } split(/\s+/, $skip_steps); + $skip_steps{make} = 1 if $skip_steps{build}; } $only_steps ||= ""; if ($only_steps =~ /\S/) { %only_steps = map { $_ => 1 } split(/\s+/, $only_steps); + $only_steps{make} = 1 if $only_steps{build}; } our %skip_suites; $skip_suites ||= ""; From e1a13887f1d292bbbe0ed74c1ea36c54063b61d6 Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Sat, 17 Jun 2023 09:54:55 -0400 Subject: [PATCH 57/58] Add a module to run pgindent --show-diff The module extracts the commits since the last run and passes those to pgindent with the --commit option, so it only checks files affected by those commits. It might be that we don't want to be restricted to that, but want the whole tree indented. Let's see. It would be trivial to change. (some) Discussion: https://postgr.es/m/582c503b-cd98-1891-ff87-9c8e8ce73ee5@dunslane.net --- PGBuild/Modules/CheckIndent.pm | 127 +++++++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 PGBuild/Modules/CheckIndent.pm diff --git a/PGBuild/Modules/CheckIndent.pm b/PGBuild/Modules/CheckIndent.pm new file mode 100644 index 0000000..25efdbe --- /dev/null +++ b/PGBuild/Modules/CheckIndent.pm @@ -0,0 +1,127 @@ + +# Package Namespace is hardcoded. Modules must live in +# PGBuild::Modules + +=comment + +Copyright (c) 2003-2022, Andrew Dunstan + +See accompanying License file for license details + +=cut + +package PGBuild::Modules::CheckIndent; + +use PGBuild::Options; +use PGBuild::SCM; +use PGBuild::Utils; +use PGBuild::Log; + +use Cwd qw(abs_path getcwd); + +use strict; +use warnings; + +our ($VERSION); $VERSION = 'REL_16'; + +my $hooks = { 'build' => \&build, }; + +sub setup +{ + my $class = __PACKAGE__; + + my $buildroot = shift; # where we're building + my $branch = shift; # The branch of Postgres that's being built. + my $conf = shift; # ref to the whole config object + my $pgsql = shift; # postgres build dir + + return unless $branch eq 'HEAD'; + + # could even set up several of these (e.g. for different branches) + my $self = { + buildroot => $buildroot, + pgbranch => $branch, + bfconf => $conf, + pgsql => $pgsql + }; + bless($self, $class); + + + # need to fetch the old git ref before the log directory is wiped out + + my $animal = $conf->{animal}; + + my $gitreffile = "$buildroot/$branch/$animal.lastrun-logs/githead.log"; + if (-e $gitreffile) + { + my $oldref = file_contents($gitreffile); + chomp $oldref; + $self->{oldref} = $oldref; + } + + register_module_hooks($self, $hooks); + return; +} + + + +sub build +{ + # note - we run this in the source directory, not the build directory + # even if it's a vpath build + + my $self = shift; + + return unless step_wanted('indent-check'); + + print time_str(), "checking for pgindent diffs ...\n" if $verbose; + + my $pgsql = abs_path($self->{pgsql}); + + local $ENV{PATH} = "$pgsql/src/tools/pg_bsd_indent:$ENV{PATH}"; + + my $gitref; + my $commits = ""; + + # we're just going to look at the set of files changed since the last run + # if we know what they are + if ($gitref = $self->{oldref}) + { + my @commits = `cd pgsql && git log --pretty=format:\%h $gitref..`; + chomp @commits; + $commits .= " --commit=$_" foreach @commits; + } + + my $status; + my @diffs; + + if ($commits) + { + my $cmd = "src/tools/pgindent/pgindent --show-diff $commits"; + + @diffs = run_log("cd pgsql && $cmd"); + $status = $? >> 8; + + my $log = PGBuild::Log->new("indent-check"); + $log->add_log_lines("indent.diff",\@diffs); + + # --show-diff doesn't exit with error, unlike --silent-diff + $status ||= 1 if @diffs; + + @diffs = ("============ pgindent check since $gitref ======\n", + $log->log_string); + + } + else + { + @diffs = ("============ pgindent check ======\n", + "no new commits to check\n"); + } + + writelog("indent-check", \@diffs); + print @diffs if ($verbose > 1); + send_result("indent-check", $status, \@diffs) if $status; + return; +} + +1; From 36166cd2be253022c31601ff072d6e16ad22f6c9 Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Tue, 20 Jun 2023 06:39:03 -0400 Subject: [PATCH 58/58] Don't do incremental-only indent checks This leads to failures that are transient. It's much better to leave the animal red until the indent issue is fixed, so we check the whole tree each time. --- PGBuild/Modules/CheckIndent.pm | 62 ++++++++-------------------------- 1 file changed, 14 insertions(+), 48 deletions(-) diff --git a/PGBuild/Modules/CheckIndent.pm b/PGBuild/Modules/CheckIndent.pm index 25efdbe..80b6291 100644 --- a/PGBuild/Modules/CheckIndent.pm +++ b/PGBuild/Modules/CheckIndent.pm @@ -46,19 +46,6 @@ sub setup }; bless($self, $class); - - # need to fetch the old git ref before the log directory is wiped out - - my $animal = $conf->{animal}; - - my $gitreffile = "$buildroot/$branch/$animal.lastrun-logs/githead.log"; - if (-e $gitreffile) - { - my $oldref = file_contents($gitreffile); - chomp $oldref; - $self->{oldref} = $oldref; - } - register_module_hooks($self, $hooks); return; } @@ -80,43 +67,22 @@ sub build local $ENV{PATH} = "$pgsql/src/tools/pg_bsd_indent:$ENV{PATH}"; - my $gitref; - my $commits = ""; - - # we're just going to look at the set of files changed since the last run - # if we know what they are - if ($gitref = $self->{oldref}) - { - my @commits = `cd pgsql && git log --pretty=format:\%h $gitref..`; - chomp @commits; - $commits .= " --commit=$_" foreach @commits; - } - my $status; my @diffs; - - if ($commits) - { - my $cmd = "src/tools/pgindent/pgindent --show-diff $commits"; - - @diffs = run_log("cd pgsql && $cmd"); - $status = $? >> 8; - - my $log = PGBuild::Log->new("indent-check"); - $log->add_log_lines("indent.diff",\@diffs); - - # --show-diff doesn't exit with error, unlike --silent-diff - $status ||= 1 if @diffs; - - @diffs = ("============ pgindent check since $gitref ======\n", - $log->log_string); - - } - else - { - @diffs = ("============ pgindent check ======\n", - "no new commits to check\n"); - } + + my $cmd = "src/tools/pgindent/pgindent --show-diff ."; + + @diffs = run_log("cd pgsql && $cmd"); + $status = $? >> 8; + + my $log = PGBuild::Log->new("indent-check"); + $log->add_log_lines("indent.diff",\@diffs); + + # --show-diff doesn't exit with error, unlike --silent-diff + $status ||= 1 if @diffs; + + @diffs = ("============ pgindent check ======\n", + $log->log_string); writelog("indent-check", \@diffs); print @diffs if ($verbose > 1);