isposix

Un outil pour savoir si une commande est posix - retour accueil

git clone git://bebou.netlib.re/isposix
Log | Files | Refs | README |

commit 9601db9f353c6edb9f3213f49900f0fddfdcc34c
parent c913dd7c582c8ebf20db6dce44eebd25d008a56f
Auteurice: Arthur Pons <arthur.pons@unistra.fr>
Date:   Mon, 25 Nov 2024 19:55:09 +0100

Ajout de tests

faire

	make test

Ne teste que les commandes, pas les options

Diffstat:
Mmakefile | 3+++
Atests | 42++++++++++++++++++++++++++++++++++++++++++
2 files changed, 45 insertions(+), 0 deletions(-)

diff --git a/makefile b/makefile @@ -2,6 +2,9 @@ PREFIX = /usr/local all: posix isposix +test: tests + ./tests + install: mkdir -p "${DESTDIR}${PREFIX}/bin" cp isposix "${DESTDIR}${PREFIX}/bin" diff --git a/tests b/tests @@ -0,0 +1,42 @@ +#! /bin/sh + +_die() { printf "$red$@$norm" >&2 ; } +_success() { printf "$green$@$norm" >&2; } +_inform() { printf "$blue$@$norm" >&2; } +red="\033[91m";green="\033[92m";blue="\033[94m";norm="\033[0m" + +assert() { + c="$1";shift + assertion="$*" + _inform "Testing if $c $assertion : " + case "$assertion" in + ( 'is posix' ) echo "$c" | ./isposix 2>/dev/null && return 0 || return 1;; + ( 'is not posix' ) echo "$c" | ./isposix 2>/dev/null && return 1 || return 0;; + esac +} + +_inform "Testing commands\n" + +# On teste toutes les commandes posix +for cmd in $(find bdd -type f | sed -E 's,bdd/([^.]+)\.html,\1,' | sort);do + if assert "$cmd" is posix;then + _success "correct\n" + else + _die "not correct\n" + failed="$failed\n$cmd is posix" + fi +done + +# On teste des commandes pas posix +for cmd in l edioja oedkp ze-zeod pjzd_zeodj;do + if assert "$cmd" is not posix;then + _success "correct\n" + else + _die "not correct\n" + failed="$failed\n$cmd is not posix" + fi +done + +[ -z "$failed" ] && _success "tests passed\n" || _die "tests failed : $failed\n" +exit $ts +