Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1paCpi-0005nS-FW for pgsql-committers@arkaria.postgresql.org; Thu, 09 Mar 2023 09:45:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1paCph-0007UK-3A for pgsql-committers@arkaria.postgresql.org; Thu, 09 Mar 2023 09:45:09 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1paCpg-0007U3-Ru for pgsql-committers@lists.postgresql.org; Thu, 09 Mar 2023 09:45:08 +0000 Received: from out4-smtp.messagingengine.com ([66.111.4.28]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1paCpd-0003jY-PL for pgsql-committers@lists.postgresql.org; Thu, 09 Mar 2023 09:45:07 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id C414E5C00EB; Thu, 9 Mar 2023 04:45:04 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Thu, 09 Mar 2023 04:45:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1678355104; x= 1678441504; bh=ZbKZwZMw+JeqWTjg2dmXS2iGnZv/XyunyIVu56rfEg0=; b=L PHHUTbU5JP5xESaIvRjFi+9hqpaBcycvaYw5Wz13CJ1BZ9aGBEMoT2qLYgupSmyx 673AKdqdL4LZqqhLb9LsJm940AioD6cKNi6zALvgpDtYFQ6fD51qa8jtIzZhUm+g HU/MopbW9oIeNA0l3iOP7umkaoROabsaMXIViM2LfJCGb1tR4HjERSPB2HfsEl0y SFe+Dpy2Bygrb6euTxEInY281/ohCIulJRlxDZQ7GF8qy8OlktIIyDcUmQ8LsLxB hAmz2eEhvZ/QdfQDF77w7QSi57KU30VsLzglZebLCJig0pgQkymtVcdbGHaEFlwx +WfA+I2rGAUmxB7GoOE5A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrvdduiedgtdeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkgggtugfgjgesthekredttddtjeenucfhrhhomheptehlvhgr rhhoucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgh eqnecuggftrfgrthhtvghrnhepvdektdffudfftdffffehfffhjeejhffgieeuueekjeek fffgudffhfduffffueevnecuffhomhgrihhnpegvnhhtvghrphhrihhsvggusgdrtghomh enucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrlhhv hhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhg X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 9 Mar 2023 04:45:03 -0500 (EST) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 4D32E9C; Thu, 9 Mar 2023 10:45:02 +0100 (CET) Date: Thu, 9 Mar 2023 10:45:02 +0100 From: Alvaro Herrera To: Andrew Dunstan Cc: pgsql-committers@lists.postgresql.org Subject: Re: pgsql: 001_libpq_pipeline.pl: use Test::Differences if available Message-ID: <20230309094502.heamw6al2vkjr4yw@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <7cd3bbbd-0216-4436-d571-8f80c9259a07@dunslane.net> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2023-Mar-08, Andrew Dunstan wrote: > I don't think you need a stringy eval here, and they are something to be > avoided in general. If you use `require` instead of `use` it should be > unnecessary, and you can avoid all the perltidy ugliness. > > something like this should do the trick: > > >    eval { require Test::Differences; Test::Differences->import; > unified_diff; 1; }; > >    *eq_or_diff = \&is if $@; Hmm, I just grabbed the code from the Test::Differences manual, but I agree that avoiding the stringy eval is better. Let me try it out. > I wonder if it's worth centralizing this. I had a look around to see what might benefit from this. At first I thought the ugly pg_dump test would, but it doesn't because it uses like/unlike, not 'is'. Same with PostgreSQL::Test::Utils' command_like and such: AFAICS they are all matching stdout on regexps. -- Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/ "El que vive para el futuro es un iluso, y el que vive para el pasado, un imbécil" (Luis Adler, "Los tripulantes de la noche")