testloop (1476B)
1 #!/bin/zsh 2 setopt extendedglob 3 4 autoload -Uz colors; colors 5 6 typeset -ga test_args 7 typeset -g run evt fname 8 # typeset -gT PYTHONPATH pythonpath 9 # pythonpath=( $0:h ~/.local/bzr/*/python(/N) /usr/local/bzr/*/python(/N) $pythonpath ) 10 # export PYTHONPATH 11 12 test_args=( "$@" ) 13 14 do_test() { 15 shelltest *.test -c "$test_args[@]" 16 # time py.test "$test_args" 17 } 18 19 trigger_check() { 20 local ret show 21 ret=0; show=1 22 case $fname in 23 (*.py[co]) ret=1;; 24 (*.sw[px]) ret=1; show=0;; 25 (*.swpx) ret=1;; 26 (*.tmp) ret=1;; 27 (*'~') ret=1;; 28 (*__pycache__*) ret=1;; 29 (*/bin/[0-9]*) ret=1;; 30 (*/.hypothesis*) ret=1; show=0;; 31 (*/tests/*) ret=1; show=0;; 32 (*/test_error.sql) ret=1;; 33 (*/commlog/*) ret=1; show=0;; 34 (*/.bzr/*) ret=1; show=0;; 35 esac 36 [[ $fname =~ '.*/[0-9]+$' ]] && ret=1 37 if (($ret)); then 38 (($show)) && print -r - "$fname $evt" 39 else 40 print -r "$fg[green]$fname $evt$reset_color" 41 fi 42 return $ret 43 } 44 45 coproc inotifywait -m -q -e create,move,close_write --format '%e %w%f' -r \ 46 --exclude='\.bzr/' --exclude='/commlog/' \ 47 . 48 49 while read -prt 0.5 evt fname; do 50 print -r "$fg[blue]$fname $evt$reset_color" 51 done 52 do_test 53 while read -pr evt fname; do 54 trigger_check || continue 55 while read -prt 0.5 evt fname; do 56 print -r "$fg[blue]$fname $evt$reset_color" 57 done 58 do_test 59 done 60 61 #while inotifywait -q --exclude='.*sw[p-z]' --exclude='.*commlog.*' -e create,move,close_write **/*~commlog*~*__pycache__(/) **/*.py || (($? == 2)); do