Re: meson: Make test output much more useful on failure (both in CI and locally)

Christoph Berg <myon@debian.org>

From: Christoph Berg <myon@debian.org>
To: Jelte Fennema-Nio <postgres@jeltef.nl>
Cc: Andrew Dunstan <andrew@dunslane.net>, Peter Eisentraut <peter@eisentraut.org>, Corey Huinker <corey.huinker@gmail.com>, Zsolt Parragi <zsolt.parragi@percona.com>, Nazir Bilal Yavuz <byavuz81@gmail.com>, Andres Freund <andres@anarazel.de>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2026-05-26T19:19:49Z
Lists: pgsql-hackers
Re: Jelte Fennema-Nio
> 5. Reduce the default diff truncation limit to 50.

Could we also get a "show everything" mode, perhaps based on an env var?

Debian's build and test machinery doesn't provide means to get at
files from the build/test run, so all evidence needs to be in the
build log. The debian/rules file for the PG server currently has this
contraption:

override_dh_auto_test-arch:
ifeq (, $(findstring nocheck, $(DEB_BUILD_OPTIONS)))
	# when tests fail, print newest log files
	# initdb doesn't like LANG and LC_ALL to contradict, unset LANG and LC_CTYPE here
	# temp-install wants to be invoked from a top-level make, unset MAKELEVEL here
	# tell pg_upgrade to create its sockets in /tmp to avoid too long paths
	unset LANG LC_CTYPE MAKELEVEL; ulimit -c unlimited; \
	if ! make -C build check-world \
	  PGSOCKETDIR="/tmp" \
	  PG_TEST_EXTRA='ssl' \
	  PROVE_FLAGS="--verbose"; \
	then \
	    for l in `find build -name 'regression.*' -o -name '*.log' -o -name '*_log_*' | perl -we 'print map { "$$_\n"; } sort { (stat $$a)[9] <=> (stat $$b)[9] } map { chomp; $$_; } <>' | tail -n 10`; do \
		echo "******** $$l ********"; \
		cat $$l; \
	    done; \
	    for c in `find build -name 'core*'`; do \
	        echo "******** $$c ********"; \
	        gdb -batch -ex 'bt full' build/tmp_install/usr/lib/postgresql/$(MAJOR_VER)/bin/postgres $$c || :; \
	    done; \
	    $(TEST_FAIL_COMMAND); \
	fi
ifeq ($(WITH_PG_BSD_INDENT),y)
	$(MAKE) -C build/src/tools/pg_bsd_indent test DESTDIR=$(CURDIR)/debian/tmp
endif
endif

The part with the TAP output files is ugly, and the "sort files by
mtime and show the 10 newest ones" even more so. I would welcome
anything that allowed me to simplify this.

Thanks,
Christoph