Improve bash formatting.

This commit is contained in:
Katharine Berry 2018-08-30 16:18:15 -07:00
parent 6afc130340
commit 8fe6467013
2 changed files with 18 additions and 18 deletions

View File

@ -451,7 +451,7 @@ kube::golang::outfile_for_binary() {
}
# Argument: the name of a Kubernetes package.
# Returns 0 if the binary can be built with coverage, 0 otherwise.
# Returns 0 if the binary can be built with coverage, 1 otherwise.
# NB: this ignores whether coverage is globally enabled or not.
kube::golang::is_covered_binary() {
return $(kube::util::array_contains "$1" "${KUBE_COVERAGE_INSTRUMENTED_PACKAGES[@]}")
@ -460,9 +460,9 @@ kube::golang::is_covered_binary() {
# Argument: the name of a Kubernetes package (e.g. k8s.io/kubernetes/cmd/kube-scheduler)
# Echos the path to a dummy test used for coverage information.
kube::golang::path_for_coverage_dummy_test() {
local package=$1
local path="${KUBE_GOPATH}/src/$package"
local name=$(basename "$package")
local package="$1"
local path="${KUBE_GOPATH}/src/${package}"
local name=$(basename "${package}")
echo "$path/zz_autogenerated_${name}_test.go"
}
@ -471,8 +471,8 @@ kube::golang::path_for_coverage_dummy_test() {
# This unit test will invoke the package's standard entry point when run.
kube::golang::create_coverage_dummy_test() {
local package="$1"
local name="$(basename "$package")"
cat <<EOF > $(kube::golang::path_for_coverage_dummy_test "$package")
local name="$(basename "${package}")"
cat <<EOF > $(kube::golang::path_for_coverage_dummy_test "${package}")
package main
import (
"testing"
@ -483,7 +483,7 @@ func TestMain(m *testing.M) {
// Get coverage running
coverage.InitCoverage("${name}")
// Go!
// Go!
main()
// Make sure we actually write the profiling information to disk, if we make it here.
@ -495,10 +495,10 @@ EOF
}
# Argument: the name of a Kubernetes package (e.g. k8s.io/kubernetes/cmd/kube-scheduler).
# Deletes a test generated by kube::golang::create_coverage_dumy_test.
# Deletes a test generated by kube::golang::create_coverage_dummy_test.
kube::golang::delete_coverage_dummy_test() {
local package=$1
rm $(kube::golang::path_for_coverage_dummy_test "$package")
local package="$1"
rm $(kube::golang::path_for_coverage_dummy_test "${package}")
}
# Arguments: a list of kubernetes packages to build.
@ -513,18 +513,18 @@ kube::golang::build_some_binaries() {
if [[ -n "${build_with_coverage:-}" ]]; then
local -a uncovered=()
for package in "$@"; do
if kube::golang::is_covered_binary "$package"; then
V=2 kube::log::info "Building $package with coverage..."
kube::golang::create_coverage_dummy_test "$package"
go test -c -o "$(kube::golang::outfile_for_binary "$package" "$platform")" \
if kube::golang::is_covered_binary "${package}"; then
V=2 kube::log::info "Building ${package} with coverage..."
kube::golang::create_coverage_dummy_test "${package}"
go test -c -o "$(kube::golang::outfile_for_binary "${package}" "${platform}")" \
-covermode count \
-coverpkg k8s.io/... \
"${build_args[@]}" \
-tags coverage \
"$package"
kube::golang::delete_coverage_dummy_test "$package"
"${package}"
kube::golang::delete_coverage_dummy_test "${package}"
else
uncovered+=("$package")
uncovered+=("${package}")
fi
done
if [[ "${#uncovered[@]}" != 0 ]]; then

View File

@ -25,7 +25,7 @@ kube::util::array_contains() {
local element
shift
for element; do
if [[ "$element" == "$search" ]]; then
if [[ "${element}" == "${search}" ]]; then
return 0
fi
done