keybuk/libnih — pull request #8 by xnox (2013-11-06 17:11:22+00:00)
Title: Make test.h use TAP formatted output

This branch changes output:
```
Testing nih_main_write_pidfile()
...with successful write
...with overwrite of existing pid
...with failure to write to temporary file
```
To:
```
ok 21 - nih_main_write_pidfile()
ok 22 - nih_main_write_pidfile() with successful write
ok 23 - nih_main_write_pidfile() with overwrite of existing pid
ok 24 - nih_main_write_pidfile() with failure to write to temporary file
```

Which is in TAP format (Test Anything Protocol).

This results in automake build logs change from:
```
...
PASS: test_command
PASS: test_config
PASS: test_logging
PASS: test_error
...
============================================================================
Testsuite summary for libnih 1.0.4
============================================================================
# TOTAL: 17
# PASS: 17
# SKIP: 0
# XFAIL: 0
# FAIL: 0
# XPASS: 0
# ERROR: 0
============================================================================
```

To:
```
PASS: test_error 1 - nih_error_raise()
PASS: test_error 2 - nih_error_raise_printf()
PASS: test_error 3 - nih_error_raise_system()
PASS: test_error 4 - nih_error_raise_no_memory()
PASS: test_error 5 - nih_error_raise_error()
PASS: test_error 6 - nih_error_raise_error() with no current error
PASS: test_error 7 - nih_error_raise_error() with unhandled error
PASS: test_error 8 - nih_return_error()
PASS: test_error 9 - nih_return_system_error()
PASS: test_error 10 - nih_return_no_memory_error()
PASS: test_error 11 - nih_error_steal()
PASS: test_error 12 - nih_error_steal() with same context
PASS: test_error 13 - nih_error_steal() with different contexts
PASS: test_error 14 - nih_error_push_context()
PASS: test_error 15 - nih_error_pop_context()
PASS: test_error 16 - nih_error_pop_context() with unhandled error in context
PASS: test_error 17 - nih_error_pop_context() with unhandled error beneath context
make[3]: Entering directory `/home/xnox/canonical/libnih/libnih/nih'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/home/xnox/canonical/libnih/libnih/nih'
============================================================================
Testsuite summary for libnih 1.0.4
============================================================================
# TOTAL: 839
# PASS: 839
# SKIP: 0
# XFAIL: 0
# FAIL: 0
# XPASS: 0
# ERROR: 0
============================================================================
```

Which is a more accurate and useful build-log output.
Furthermore it will enable: skipping tests, marking them expected fail, marking them TODO (unimplemented features), whilst accurately reporting each one of them.

There is no break in testing API and this implementation works across all libnih tests. There is no dependency on executing the test-suite under the TAP runner.

There is one change of behaviour: instead of aborting (bailing) on test failure, a FAIL is reported and the individual test binary will "keep going". I believe this is acceptable as the overall build will fail and is accurately reported. I added a define "TEST_TAP_BAIL_ON_FAIL" which will report a TAP "bail" command and abort as it was done previously. In case one wants previous behaviour.