hello Norwid,

groff already has perl and shell so we should stick on those choices.

I saw some tests in the current codebase writen in shell but nothing
that complies to a report system.

I can provide patches to rewrite those with perl Test::More so we can
get benefit of very well maintained and documented modules that provides
TAP outputs. Another solution is to provide a very simplistic (so easy
to maintain) TAP emiter in pure shell. Here is an example.

regards,


# Minimal TAP implementation (Test::More inspiration)
# https://testanything.org/
# which can be moved appart in a TAP.sh file

testing() TAPIDX=0
done_testing() echo 1..$TAPIDX
ok() {
        local r=$? status
        TAPIDX=$(( $TAPIDX + 1 ))
        [ $r = 0 ] && status=ok
        echo "${status:-not ok} $TAPIDX - $*"
        return $r
}
note() { sed 's/^/# /' ; }

# the actual test suite

is_command() {
        local command="$1" expected_bin="$2" bin
        shift 2
        bin=$( which "$command" )      ; ok "$command is installed"
        [ "$bin" = "$expected_bin"  ]  ; ok "the system $command will be used"
        true
}


_TEST() DESC="$*"
alias TEST='<<\% note; _TEST'
alias GOT='<<\%  chem > GOT'
alias EXPECT='<<\% cat > EXPECTED; diff GOT EXPECTED > NOTE; ok "$DESC" || note 
< NOTE'

testing
is_command awk /usr/bin/awk
is_command chem /usr/bin/chem

TEST first example in the documentation

    Some characters in the strings submitted to be written or/and tested
    may have a meaning to the shell (default Debian: bash).  To prevent
    this complication / a need to escape them, it is safer to process
    them as r-strings, than plain strings.
%

GOT
.cstart
    CH3
    bond
    CH2
    bond
.cend
%

EXPECT
copy "/usr/share/groff/1.23.0/pic/chem.pic"
        textht = 0.16; textwid = .1; cwid = 0.12
        lineht = 0.2; linewid = 0.2
Last: 0,0

#    CH3
Last: CH3: atom("CH\s-3\d3\u\s+3", 0.3, 0.16, 0.06, 0.16, 0.12, 0.015) with 
.L.w at Last.e

#    bond
Last: bond(0.2, 90, from Last.R.e )

#    CH2
Last: CH2: atom("CH\s-3\d2\u\s+3", 0.3, 0.16, 0.06, 0.16, 0.12, 0.015) with 
.L.w at Last.end

#    bond
Last: bond(0.2, 90, from Last.R.e )
.PE
%

done_testing


-- 
Marc Chantreux
Pôle CESAR (Calcul et services avancés à la recherche)
Université de Strasbourg
14 rue René Descartes,
BP 80010, 67084 STRASBOURG CEDEX
03.68.85.60.79


Reply via email to