#!/bin/bash

set -e

VERSIONS=$(pg_buildext supported-versions)

cd test

trap "cat pgagent.out" ERR

for v in $VERSIONS; do
	if ! [ -f /usr/share/postgresql/$v/extension/pgagent.control ]; then
		echo "/usr/share/postgresql/$v/extension/pgagent.control missing, cannot test PostgreSQL $v"
		continue
	fi
	if ! [ -f /usr/lib/postgresql/$v/bin/postgres ]; then
		echo "/usr/lib/postgresql/$v/bin/postgres missing, cannot test PostgreSQL $v"
		continue
	fi
	rm -f pgagent.out
	pg_buildext installcheck-$v
	cat pgagent.out
done

rm -f pgagent.out
