From 5bcd21c9f1f768e1321bae67837a211e9504cb3d Mon Sep 17 00:00:00 2001 From: Paul Michali Date: Fri, 5 May 2017 17:25:58 +0000 Subject: [PATCH] Coverage: shasum command not supported on CentOS Centos has sha1sum, instead of "shasum -a1". Modified script to check for existence fo shasum, and if not present, use sha1sum for coverage test processing. If neither are available, an error will be reported and processing stopped. --- hack/make-rules/test.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/hack/make-rules/test.sh b/hack/make-rules/test.sh index 8cce276e3af..a00900ba501 100755 --- a/hack/make-rules/test.sh +++ b/hack/make-rules/test.sh @@ -27,6 +27,16 @@ kube::golang::setup_env KUBE_CACHE_MUTATION_DETECTOR="${KUBE_CACHE_MUTATION_DETECTOR:-true}" export KUBE_CACHE_MUTATION_DETECTOR +# Handle case where OS has sha#sum commands, instead of shasum. +if which shasum >/dev/null 2>&1; then + SHA1SUM="shasum -a1" +elif which sha1sum >/dev/null 2>&1; then + SHA1SUM="sha1sum" +else + echo "Failed to find shasum or sha1sum utility." >&2 + exit 1 +fi + kube::test::find_dirs() { ( cd ${KUBE_ROOT} @@ -189,7 +199,7 @@ junitFilenamePrefix() { # barely fits there and in coverage mode test names are # appended to generated file names, easily exceeding # 255 chars in length. So let's just use a sha1 hash of it. - local KUBE_TEST_API_HASH="$(echo -n "${KUBE_TEST_API//\//-}"|shasum -a 1|awk '{print $1}')" + local KUBE_TEST_API_HASH="$(echo -n "${KUBE_TEST_API//\//-}"| ${SHA1SUM} |awk '{print $1}')" echo "${KUBE_JUNIT_REPORT_DIR}/junit_${KUBE_TEST_API_HASH}_$(kube::util::sortable_date)" } @@ -239,7 +249,7 @@ runTests() { fi # Create coverage report directories. - KUBE_TEST_API_HASH="$(echo -n "${KUBE_TEST_API//\//-}"|shasum -a 1|awk '{print $1}')" + KUBE_TEST_API_HASH="$(echo -n "${KUBE_TEST_API//\//-}"| ${SHA1SUM} |awk '{print $1}')" cover_report_dir="/tmp/k8s_coverage/${KUBE_TEST_API_HASH}/$(kube::util::sortable_date)" cover_profile="coverage.out" # Name for each individual coverage profile kube::log::status "Saving coverage output in '${cover_report_dir}'"