isposix

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

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

tests (1053B)


      1 #! /bin/sh
      2 
      3 _die() { printf "$red$@$norm" >&2 ; }
      4 _success() { printf "$green$@$norm" >&2; }
      5 _inform() { printf "$blue$@$norm" >&2; }
      6 red="\033[91m";green="\033[92m";blue="\033[94m";norm="\033[0m"
      7 
      8 assert() {
      9 	c="$1";shift
     10 	assertion="$*"
     11 	_inform "Testing if $c $assertion : "
     12 	case "$assertion" in
     13 		( 'is posix' )     echo "$c" | ./isposix 2>/dev/null && return 0 || return 1;;
     14 		( 'is not posix' ) echo "$c" | ./isposix 2>/dev/null && return 1 || return 0;;
     15 	esac
     16 }
     17 
     18 _inform "Testing commands\n"
     19 
     20 # On teste toutes les commandes posix
     21 for cmd in $(find bdd -type f | sed -E 's,bdd/([^.]+)\.html,\1,' | sort);do
     22 	if assert "$cmd" is posix;then
     23 		_success "correct\n"
     24 	else
     25 		_die "not correct\n"
     26 		failed="$failed\n$cmd is posix"
     27 	fi
     28 done
     29 
     30 # On teste des commandes pas posix
     31 for cmd in l edioja oedkp ze-zeod pjzd_zeodj;do
     32 	if assert "$cmd" is not posix;then
     33 		_success "correct\n"
     34 	else
     35 		_die "not correct\n"
     36 		failed="$failed\n$cmd is not posix"
     37 	fi
     38 done
     39 
     40 [ -z "$failed" ] && _success "tests passed\n" || _die "tests failed : $failed\n"
     41 exit $ts
     42