Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1aVIdY-0007KF-Bq for pgsql-hackers@arkaria.postgresql.org; Mon, 15 Feb 2016 12:52:20 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1aVIdX-0007sA-Ph for pgsql-hackers@arkaria.postgresql.org; Mon, 15 Feb 2016 12:52:19 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1aVIcC-0006OT-SR for pgsql-hackers@postgresql.org; Mon, 15 Feb 2016 12:50:57 +0000 Received: from newmail.postgrespro.ru ([93.174.131.138] helo=mail.postgrespro.ru) by makus.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1aVIc9-0002VE-0q for pgsql-hackers@postgresql.org; Mon, 15 Feb 2016 12:50:55 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id EB6DC21C63AE; Mon, 15 Feb 2016 15:50:50 +0300 (MSK) Received: from mail.postgrespro.ru ([127.0.0.1]) by localhost (mail.postgrespro.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id U9brKVRU1OmB; Mon, 15 Feb 2016 15:50:48 +0300 (MSK) Received: from [192.168.27.116] (unknown [192.168.27.1]) by mail.postgrespro.ru (Postfix) with ESMTPSA id 55B5D21C5C38; Mon, 15 Feb 2016 15:50:48 +0300 (MSK) Subject: Re: Small PATCH: check of 2 Perl modules To: Michael Paquier , Robert Haas References: <56BDDC20.9020506@postgrespro.ru> Cc: "pgsql-hackers@postgresql.org" From: Eugene Kazakov Message-ID: <56C1C9A8.5070604@postgrespro.ru> Date: Mon, 15 Feb 2016 15:50:48 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/mixed; boundary="------------060907010205060301010205" X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org This is a multi-part message in MIME format. --------------060907010205060301010205 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit 13.02.2016 16:04, Michael Paquier : > On Sat, Feb 13, 2016 at 1:47 PM, Robert Haas wrote: >> On Fri, Feb 12, 2016 at 8:20 AM, Eugene Kazakov >> wrote: >>> TAP-tests need two Perl modules: Test::More and IPC::Run. >>> >>> The patch adds checking of modules in configure.in and configure. >> Why would we want that? > I was doubtful at the beginning, but it doesn't hurt to have those > sanity checks in configure actually. The idea is that when > --enable-tap-tests is used now we simply error with "Can't locate > IPC/Run.pm in @INC" when kicking the tests, this check would allow one > to know if his environment is adapted to run the tests or not before > compiling anything. > > And with this patch, we would fail now with that: > configure: error: Need Perl IPC::Run module > > By the way, the patch given upthread by Eugene is incorrect. To begin > with, AX_PROG_PERL_MODULES has not been compiled by autoconf and I > can't believe that it is available on all platforms, for example on > OSX 10.8 I could not see it. And it is actually here: > https://www.gnu.org/software/autoconf-archive/ax_prog_perl_modules.html > > I would recommend grabbing a copy of this file, and change the error > message as follows: > Perl module IPC::Run is required to run TAP tests > > See the patch attached as reference, we could simplify the macro of > this m4 file and remove the check for perl, which is here: > +# Make sure we have perl > +if test -z "$PERL"; then > +AC_CHECK_PROG(PERL,perl,perl) > +fi > Though I kept the original script as-is in the patch attached. > Regards, Michael, Thank you. You are right, of course. I missed the m4_ax_prog_perl_modules. Please, see the fixed version of patch in the attach. I added m4_ax_prog_perl_modules and change the error messages. The best regards, Eugene Kazakov, Postgres Professional --------------060907010205060301010205 Content-Type: text/plain; charset=UTF-8; name="configure-tap-modules-v3" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="configure-tap-modules-v3" diff --git a/aclocal.m4 b/aclocal.m4 index 6f930b6..e6b2aaf 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -10,3 +10,4 @@ m4_include([config/perl.m4]) m4_include([config/programs.m4]) m4_include([config/python.m4]) m4_include([config/tcl.m4]) +m4_include([config/m4_ax_prog_perl_modules.m4]) diff --git a/config/m4_ax_prog_perl_modules.m4 b/config/m4_ax_prog_perl_modules.m4 new file mode 100644 index 0000000..ed5dd30 --- /dev/null +++ b/config/m4_ax_prog_perl_modules.m4 @@ -0,0 +1,72 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_prog_perl_modules.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_PROG_PERL_MODULES([MODULES], [ACTION-IF-TRUE], [ACTION-IF-FALSE]) +# +# DESCRIPTION +# +# Checks to see if the given perl modules are available. If true the shell +# commands in ACTION-IF-TRUE are executed. If not the shell commands in +# ACTION-IF-FALSE are run. Note if $PERL is not set (for example by +# calling AC_CHECK_PROG, or AC_PATH_PROG), AC_CHECK_PROG(PERL, perl, perl) +# will be run. +# +# MODULES is a space separated list of module names. To check for a +# minimum version of a module, append the version number to the module +# name, separated by an equals sign. +# +# Example: +# +# AX_PROG_PERL_MODULES( Text::Wrap Net::LDAP=1.0.3, , +# AC_MSG_WARN(Need some Perl modules) +# +# LICENSE +# +# Copyright (c) 2009 Dean Povey +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 7 + +AU_ALIAS([AC_PROG_PERL_MODULES], [AX_PROG_PERL_MODULES]) +AC_DEFUN([AX_PROG_PERL_MODULES],[dnl + +m4_define([ax_perl_modules]) +m4_foreach([ax_perl_module], m4_split(m4_normalize([$1])), + [ + m4_append([ax_perl_modules], + [']m4_bpatsubst(ax_perl_module,=,[ ])[' ]) + ]) + +if test "x$PERL" != x; then + ax_perl_modules_failed=0 + for ax_perl_module in ax_perl_modules; do + AC_MSG_CHECKING(for perl module $ax_perl_module) + + # Would be nice to log result here, but can't rely on autoconf internals + $PERL -e "use $ax_perl_module; exit" > /dev/null 2>&1 + if test $? -ne 0; then + AC_MSG_RESULT(no); + ax_perl_modules_failed=1 + else + AC_MSG_RESULT(ok); + fi + done + + # Run optional shell commands + if test "$ax_perl_modules_failed" = 0; then + : + $2 + else + : + $3 + fi +else + AC_MSG_WARN(could not find perl) +fi])dnl diff --git a/configure b/configure index 1903815..2d80202 100755 --- a/configure +++ b/configure @@ -15554,6 +15554,79 @@ done if test -z "$PERL"; then as_fn_error $? "Perl not found" "$LINENO" 5 fi + + + + + + + +if test "x$PERL" != x; then + ax_perl_modules_failed=0 + for ax_perl_module in 'Test::More' ; do + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for perl module $ax_perl_module" >&5 +$as_echo_n "checking for perl module $ax_perl_module... " >&6; } + + # Would be nice to log result here, but can't rely on autoconf internals + $PERL -e "use $ax_perl_module; exit" > /dev/null 2>&1 + if test $? -ne 0; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; }; + ax_perl_modules_failed=1 + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 +$as_echo "ok" >&6; }; + fi + done + + # Run optional shell commands + if test "$ax_perl_modules_failed" = 0; then + : + + else + : + as_fn_error $? "Perl module IPC::Test is required to run TAP tests " "$LINENO" 5 + fi +else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not find perl" >&5 +$as_echo "$as_me: WARNING: could not find perl" >&2;} +fi + + + + + + +if test "x$PERL" != x; then + ax_perl_modules_failed=0 + for ax_perl_module in 'IPC::Run' ; do + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for perl module $ax_perl_module" >&5 +$as_echo_n "checking for perl module $ax_perl_module... " >&6; } + + # Would be nice to log result here, but can't rely on autoconf internals + $PERL -e "use $ax_perl_module; exit" > /dev/null 2>&1 + if test $? -ne 0; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; }; + ax_perl_modules_failed=1 + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 +$as_echo "ok" >&6; }; + fi + done + + # Run optional shell commands + if test "$ax_perl_modules_failed" = 0; then + : + + else + : + as_fn_error $? "Perl module IPC::Run is required to run TAP tests " "$LINENO" 5 + fi +else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not find perl" >&5 +$as_echo "$as_me: WARNING: could not find perl" >&2;} +fi fi # Thread testing diff --git a/configure.in b/configure.in index 0bd90d7..c265471 100644 --- a/configure.in +++ b/configure.in @@ -2055,6 +2055,9 @@ if test "$enable_tap_tests" = yes; then if test -z "$PERL"; then AC_MSG_ERROR([Perl not found]) fi + + AX_PROG_PERL_MODULES( Test::More, , AC_MSG_ERROR( [Perl module IPC::Test is required to run TAP tests] )) + AX_PROG_PERL_MODULES( IPC::Run, , AC_MSG_ERROR( [Perl module IPC::Run is required to run TAP tests] )) fi # Thread testing --------------060907010205060301010205 Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers --------------060907010205060301010205--