pacoxu / kubernetes

Production-Grade Container Scheduling and Management
https://kubernetes.io
Apache License 2.0
2 stars 4 forks source link

Improve testing coverage on unit test level #1775

Open pacoxu opened 1 year ago

pacoxu commented 1 year ago

5 files depth 2

https://github.com/kubernetes/kubernetes/issues/97355

pacoxu commented 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 为例: 快速扫描方法如上,结果如下: