pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
To: Noah Misch <noah@leadboat.com>
To: Andres Freund <andres@anarazel.de>
Cc: pgsql-hackers@lists.postgresql.org
Subject: Re: expressive test macros (was: Report test_atomic_ops() failures consistently, via macros)
Date: Mon, 7 Oct 2019 21:56:20 +0200
Message-ID: <f0906c55-87cb-e940-b27b-99d41c14d44d@2ndquadrant.com> (raw)
In-Reply-To: <20191006022038.GB4023404@rfd.leadboat.com>
References: <E1iGnXq-0001K7-Aj@gemulon.postgresql.org>
	<20191005190729.6sx7g23ifdu65s7s@alap3.anarazel.de>
	<20191006022038.GB4023404@rfd.leadboat.com>

On 2019-10-06 04:20, Noah Misch wrote:
>> Seems like putting ASSERT_{EQ,LT,...}_{U32,S32,...} (or Assert_Eq_...,
>> but that'd imo look weirder than the inconsistency) into c.h would make
>> sense, and EXPECT_ somewhere in common/pg_test.h or such?
> 
> Sounds reasonable.  For broader use, I would include the expected value, not
> just expected_expr:
> 
>  elog(ERROR, \
>       "%s yielded %u, expected %s (%u) in file \"%s\" line %u", \
>       #result_expr, result, #expected_expr, expected, __FILE__, __LINE__); \
> 
> I didn't do that for the atomics tests, where expected_expr is always trivial.
> The codebase has plenty of Assert(x == y) where either of x or y could have
> the surprising value.

I've been meaning to propose some JUnit-style more-specific Assert
variants such as AssertEquals for this reason.  But as Tom writes
nearby, it should be a straight wrapper around Assert, not elog.  So
these need to be named separately.

Btw., JUnit uses the ordering convention assertEquals(expected, actual),
whereas Perl Test::More uses is(actual, expected).  Let's make sure we
pick something and stick with it.

-- 
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services





view thread (10+ messages)  latest in thread

Message-ID: <f0906c55-87cb-e940-b27b-99d41c14d44d@2ndquadrant.com>
Permalink:  ../f0906c55-87cb-e940-b27b-99d41c14d44d@2ndquadrant.com/
Also on:    postgresql.org/message-id/f0906c55-87cb-e940-b27b-99d41c14d44d@2ndquadrant.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: peter.eisentraut@2ndquadrant.com, noah@leadboat.com, andres@anarazel.de, pgsql-hackers@lists.postgresql.org
  Subject: Re: expressive test macros (was: Report test_atomic_ops() failures consistently, via macros)
  In-Reply-To: <f0906c55-87cb-e940-b27b-99d41c14d44d@2ndquadrant.com>
  References: <E1iGnXq-0001K7-Aj@gemulon.postgresql.org> <20191005190729.6sx7g23ifdu65s7s@alap3.anarazel.de> <20191006022038.GB4023404@rfd.leadboat.com> <f0906c55-87cb-e940-b27b-99d41c14d44d@2ndquadrant.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox