==========================
= Setup test environment =
==========================

To run tests we need two bash scripts: pw_runtests.sh and pw_pgcontrol.sh.
Both scripts can be found at: https://github.com/Piiit/pwScripts

pw_pgcontrol.sh needs two more components:

1) the includes folder from https://github.com/Piiit/pwScripts, and
2) a config file named .pw_pgcontrol.ini
with the following content:
	
	PORT=5112
	LOGFILE=/tmp/postgresql-temporal3-serverlog
	DATADIR=data
	BIN=

that specifies the PORT, LOGFILE and DATADIR of the actual PostgreSQL 
installation.

The easiest installation is to download the whole folder from github.

=============
= Run tests =
=============

Run tests with one of the following commands:

- Full error reporting:
	pw_runtests.sh -vc "pw_pgcontrol.sh test A" unibz/tests/test01.sql
- Verbose error reporting:
	pw_runtests.sh -vc "pw_pgcontrol.sh test A" unibz/tests/test01.sql
- Just say if an error occurred or not:
	pw_runtests.sh -c "pw_pgcontrol.sh test A" unibz/tests/test01.sql 2>/dev/null
	
	
======================	
= Run multiple tests = 
======================

Wildcards supported, i.e. run 

	pw_runtests.sh -vc "pw_pgcontrol.sh test A" unibz/tests/test*.sql
	
for all test cases named unibz/tests/test*.sql.


=====================================
= Expected result file name pattern =
=====================================

Expected result files *must* have the following name pattern:
	<testname>_expected.txt
	
	For example, if test is called test_aligner01.sql, the expected
	result file must be named as test_aligner01_expected.txt.
	

=========================
= Ignoring SQL comments =
=========================

You can ignore SQL comments by adding 

	-i "^--" 
	
to pw_runtests.sh.


=========================
= Create new test cases =
=========================

1) Create a <testname>.sql file (see existing files for ideas)
2) Run it with the command: 
	pw_pgcontrol test <dbname> <testname>.sql
3) Check the output manually
4) If it is correct, copy it into a new file called <testname>_expected.txt

Done.

NB: Do not use psql directly, because we made several output configurations to
    support standardized test case diffs. 
    
See Peter Eisentraut's blog for further details:
    http://petereisentraut.blogspot.it/2010/03/running-sql-scripts-with-psql.html
	


