#!/bin/sh

set -eu

for version in $(pg_buildext supported-versions); do
	if ! pg_virtualenv -i '--auth trust' -v $version \
		make installcheck \
		PG_CONFIG=/usr/lib/postgresql/$version/bin/pg_config USE_PGXS=1; then
		for f in $(find . -name regression.diffs); do
			if [ -s $f ]; then
				echo "**** $f ****"
				cat $f
			fi
		done
		case $version in
		8.4|9.0)
			echo "**** expected failure on $version"
			;;
		*)
			exit 1
			;;
		esac
	fi
done
