1
0
mirror of https://github.com/zplug/zplug synced 2025-08-30 01:30:43 +02:00
zplug/misc/dev_tools/coverage.zsh
Naoki Mizuno e01833c95e Change directory structure
lib/     -> base/
src/     -> misc/
src/ext/ -> base/sources/
2016-04-13 01:25:51 -04:00

58 lines
1016 B
Bash

#!/bin/zsh
local -F all=0
local -a pass
local -a fail
local f is_create=false
while (( $# > 0 ))
do
case "$1" in
-c|--create)
is_create=true
;;
-*|--*)
printf "$1: unkown option\n" >&2
exit 1
;;
*)
;;
esac
shift
done
get_untested_files() {
local f
for f in $ZPLUG_ROOT/(autoload|lib)/**/*(.:gs:$ZPLUG_ROOT/:)
do
let all++
if [[ -f $ZPLUG_ROOT/test/${f:r}_test.zsh ]]; then
pass+=($f)
else
fail+=($f)
fi
done
}
show_untested_files() {
get_untested_files
if (( $#fail > 0 )); then
printf "- %s\n" ${fail[@]}
printf "\n"
fi
printf "%d/%d (%3.1f%%)\n" $#pass $all $(($#pass / $all * 100))
}
if $is_create; then
get_untested_files
for f in "${fail[@]}"
do
f="test/${f:r}_test.zsh"
mkdir -p "${f:h}"
echo "#!/bin/zsh" >"$f"
done
else
show_untested_files
fi