#!/bin/sh

set -ex
export TZ=UTC

for v in $(pg_buildext supported-versions); do
	newnet pg_virtualenv -v $v <<-EOF
		set -ex
		psql -X <<-EOS
			CREATE EXTENSION pgtap;
			CREATE SCHEMA dblink;
			CREATE EXTENSION dblink WITH SCHEMA dblink;
			CREATE SCHEMA mimeo;
			CREATE EXTENSION mimeo WITH SCHEMA mimeo;
		EOS
		# full run:
		#pg_prove -v -f test/*.sql
		# selected tests:
		pg_prove -v -f test/test01_setup.sql
		pg_prove -v -f test/test02_setup_remote_tables.sql
		pg_prove -v -f test/test03_run_maker_functions.sql
		#pg_prove -v -f test/test04_check_maker_data.sql
		#pg_prove -v -f test/test05_insert_remote_data_batch2.sql
		#pg_prove -v -f test/test06_run_refresh_functions.sql
		#pg_prove -v -f test/test07_check_refresh_data.sql
		#pg_prove -v -f test/test08_insert_remote_data_batch3.sql
		#pg_prove -v -f test/test09_check_refresh_data.sql
		#pg_prove -v -f test/test10_run_repull_tests.sql
		#pg_prove -v -f test/test11_test_individual_dml_types.sql
		#pg_prove -v -f test/test80_error_tests.sql
		#pg_prove -v -f test/test81_max_multi_dml_tables.sql
		#pg_prove -v -f test/test90_batch_limit_tests.sql
		#pg_prove -v -f test/test91_check_source_changes.sql
		pg_prove -v -f test/test98_run_destroyer_functions.sql
		pg_prove -v -f test/test99_cleanup.sql
	EOF
done
