Tap-functions
From Test Anything Protocol
Contents |
[edit] tap-functions: A TAP-producing BASH library
I "sorta "ported JTap to BASH. The code can be found here: SVN repo
Basically all you need to do to use it to source the tap-functions file. Here's the limited documentation that's currently available:
[edit] PLAN
plan_no_plan plan_skip_all [REASON] plan_tests NB_TESTS
[edit] TEST
ok RESULT [NAME] okx COMMAND is RESULT EXPECTED [NAME] isnt RESULT EXPECTED [NAME] like RESULT PATTERN [NAME] unlike RESULT PATTERN [NAME] pass [NAME] fail [NAME]
[edit] SKIP
skip CONDITION [REASON] [NB_TESTS=1]
skip $feature_not_present "feature not present" 2 || {
is $a "a"
is $b "b"
}
[edit] TODO
Specify TODO mode by setting $TODO: TODO="not implemented yet" ok $result "some not implemented test" unset TODO
[edit] OTHER
diag MSG
[edit] EXAMPLE
#!/bin/bash
. tap-functions
plan_tests 7
me=$USER
is $USER $me "I am myself"
like $HOME $me "My home is mine"
like "`id`" $me "My id matches myself"
/bin/ls $HOME 1>&2
ok $? "/bin/ls $HOME"
# Same thing using okx shortcut
okx /bin/ls $HOME
[ "`id -u`" != "0" ]
i_am_not_root=$?
skip $i_am_not_root "Must be root" || {
okx ls /root
}
TODO="figure out how to become root..."
okx [ "$HOME" == "/root" ]
unset TODO
-- Patrick LeBoutillier <patl@cpan.org>

