Open pacoxu opened 1 year ago
#!/bin/bash
SEARCH_PATH=${1:-"./cmd/kubeadm/"}
VERBOSITY=${VERBOSITY:-""}
DIRS=$(find ${SEARCH_PATH} -maxdepth 2 -mindepth 2 -type d)
for dir in ${DIRS}
do
PKGS=$(find ${dir} -name "*.go" | grep -v "_test.go" | grep -v "doc.go" | grep -v "test" | grep -v "fake" | grep -v "sample" | grep -v "stub")
COUNT=0
for pkg in ${PKGS}
do
UNIT_TEST=$(echo $pkg | sed s@\.go@_test.go@)
if [ -f ${UNIT_TEST} ]; then
continue
fi
if [ -n "${VERBOSITY}" ]; then
echo "$UNIT_TEST doesn't exist"
fi
COUNT=$(expr ${COUNT} + 1)
done
echo "${dir}: ${COUNT} files are not tested on unit tests."
done
kubeadm 为例: 快速扫描方法如上,结果如下:
https://github.com/kubernetes/kubernetes/issues/97355