Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Something I whipped up just this morning. It should work with Test::Harness, it may be missing some of the Test::More methods, let me know if I've mised the mark or something else needs to be added.
#!/bin/bash # This is a shell library for interfacing with Perl's Test::Harness fr +amework # Copyright 2004. Michael Grubb SHOULD_PRINT_PLAN=0 TEST_PLAN=0 TEST_COUNTER=0 MATCH_PROG=/bin/egrep MATCH_ARGS="-q" plan() { if [ "${1}" == "no_plan" ] ; then SHOULD_PRINT_PLAN=1 TEST_PLAN=0 else TEST_PLAN="${1}" SHOULD_PRINT_PLAN=1 _printPlan SHOULD_PRINT_PLAN=0 fi } endtests() { _printPlan } ok() { _updatePlan if [ $1 != 0 ]; then echo -n "not " fi echo "ok ${TEST_COUNTER} ${2} # \$1 is '$1'" } is() { _updatePlan if [ $1 != ${2} ] ; then echo -n "not " fi echo "ok ${TEST_COUNTER} ${3} # expecting '$1' got '$2'" } match() { _updatePlan echo "$2" | ${MATCH_PROG} ${MATCH_ARGS} ${1} rv=$? if [ $rv -ne 0 ] ; then echo -n "not " fi echo -n "ok ${TEST_COUNTER} ${3} " if [ $rv -ne 0 ] ; then echo "# '$2' did not match '$1'" else echo fi } diag() { echo "# $1" 1>&2 } _updatePlan() { TEST_COUNTER=$((${TEST_COUNTER}+1)) if [ ${SHOULD_PRINT_PLAN} ] ; then TEST_PLAN=${TEST_COUNTER} ; fi } _printPlan() { if [ ${SHOULD_PRINT_PLAN} -eq 1 ] ; then echo "1..${TEST_PLAN}" fi }

And here is a script that shows it's usage:

#!/bin/bash . ./ plan "no_plan" diag "# TEST_PLAN=$TEST_PLAN" ok 0 "Test 1" ok 0 "Test 2" ok 2 "Test 3" is "this" "this" is "this" "that" is 1 0 is 0 1 is 1 1 match "^ab[cd]efg$" "abcefg" match "^ab[cd]efg$" "abdefg" match "^ab[cd]efg$" "abcdefg" match "^ab[cd]efg$" "abhefg" endtests # only needed when "no_plan" is used
Hope this helps. Oh, and by default the "match" function uses egrep -q but you can override that if you set MATCH_PROG and MATCH_ARGS after you source Let me know if this is useful. Also note that getting Test::Harness to run this is an excercise left to the reader.

In reply to Re^2: using Test::* modules for generic testing of non perl stuff? by linux454
in thread using Test::* modules for generic testing of non perl stuff? by jfroebe

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2021-07-27 15:19 GMT
Find Nodes?
    Voting Booth?

    No recent polls found