diff options
author | Johannes Sixt <j6t@kdbg.org> | 2009-03-01 21:04:46 +0100 |
---|---|---|
committer | Johannes Sixt <j6t@kdbg.org> | 2009-03-21 21:09:27 +0100 |
commit | a7bb394037e1c32d47d0b04da025bdbe2eb78d66 (patch) | |
tree | fd9ac3aa1136ba93126483cbc0e4beb2178269f3 /t/t0000-basic.sh | |
parent | 64e61f2d173b0172d9dbaa9667486764224568fb (diff) | |
download | git-a7bb394037e1c32d47d0b04da025bdbe2eb78d66.tar.gz |
test-lib: Infrastructure to test and check for prerequisites
Some tests can be run only if a particular prerequisite is available. For
example, some tests require that an UTF-8 locale is available. Here we
introduce functions that are used in this way:
1. Insert code that checks whether the prerequisite is available. If it is,
call test_set_prereq with an arbitrary tag name that subsequently can be
used to check for the prerequisite:
case $LANG in
*.utf-8)
test_set_prereq UTF8
;;
esac
2. In the calls to test_expect_success pass the tag name:
test_expect_success UTF8 '...description...' '...tests...'
3. There is an auxiliary predicate that can be used anywhere to test for
a prerequisite explicitly:
if test_have_prereq UTF8
then
...code to be skipped if prerequisite is not available...
fi
Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Diffstat (limited to 't/t0000-basic.sh')
-rwxr-xr-x | t/t0000-basic.sh | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh index ddcd5b0efb..c53de1f212 100755 --- a/t/t0000-basic.sh +++ b/t/t0000-basic.sh @@ -57,6 +57,21 @@ test_expect_failure 'pretend we have a known breakage' ' test_expect_failure 'pretend we have fixed a known breakage' ' : ' +test_set_prereq HAVEIT +haveit=no +test_expect_success HAVEIT 'test runs if prerequisite is satisfied' ' + test_have_prereq HAVEIT && + haveit=yes +' +donthaveit=yes +test_expect_success DONTHAVEIT 'unmet prerequisite causes test to be skipped' ' + donthaveit=no +' +if test $haveit$donthaveit != yesyes +then + say "bug in test framework: prerequisite tags do not work reliably" + exit 1 +fi ################################################################ # Basics of the basics |