Skip to content

Instantly share code, notes, and snippets.

@robert-cronin
Last active June 1, 2024 00:36
Show Gist options
  • Save robert-cronin/150e3044b916ebe597478b1294f97da8 to your computer and use it in GitHub Desktop.
Save robert-cronin/150e3044b916ebe597478b1294f97da8 to your computer and use it in GitHub Desktop.
Hunting for packages with low test coverage in Kubernetes
#!/bin/bash
set -o errexit
# run this script from kubernetes root directory to generate and open a coverage report for a package
# first arg is the package path to run the tests for
# example: ./script.sh staging/src/k8s.io/kubelet
# make temp dir
TEMP_DIR=$(mktemp -d)
# get the package path
if [ -z "$1" ]; then
echo "Usage: $0 <path to the package>"
exit 1
fi
PACKAGE_PATH=$1
ABS_PATH=$(pwd)/$PACKAGE_PATH
# run the tests
make test KUBE_COVER=y KUBE_COVER_REPORT_DIR=$TEMP_DIR WHAT="$ABS_PATH"
# open the coverage report
open $TEMP_DIR/combined-coverage.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment