Skip to content

Commit 044dc0f

Browse files
authored
Merge pull request #112 from pmorie/test-output
Add basic output to test script
2 parents 90e77b4 + a4b3b5c commit 044dc0f

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

test.sh

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,35 @@ if [[ "$goos" == "unknown" ]]; then
4040
exit 1
4141
fi
4242

43+
# Turn colors in this script off by setting the NO_COLOR variable in your
44+
# environment to any value:
45+
#
46+
# $ NO_COLOR=1 test.sh
47+
NO_COLOR=${NO_COLOR:""}
48+
header=$'\e[1;33m'
49+
reset=$'\e[0m'
50+
function header_text {
51+
if [ -z "$NO_COLOR" ]; then
52+
echo "$header${@}$reset"
53+
else
54+
echo ${@}
55+
fi
56+
}
57+
4358
rc=0
4459
tmp_root=/tmp
4560

4661
kb_root_dir=$tmp_root/kubebuilder
4762
kb_vendor_dir=$tmp_root/vendor
4863

4964
function prepare_staging_dir {
65+
header_text "preparing staging dir"
5066
rm -rf $kb_root_dir
5167
}
5268

5369
# fetch k8s API gen tools and make it available under kb_root_dir/bin.
5470
function fetch_tools {
71+
header_text "fetching tools"
5572
kb_tools_archive_name=kubebuilder-tools-$k8s_version-$goos-$goarch.tar.gz
5673
kb_tools_download_url="https://storage.googleapis.com/kubebuilder-tools/$kb_tools_archive_name"
5774

@@ -63,11 +80,13 @@ function fetch_tools {
6380
}
6481

6582
function build_kb {
83+
header_text "building kubebuilder"
6684
go build -o $tmp_root/kubebuilder/bin/kubebuilder ./cmd/kubebuilder
6785
go build -o $tmp_root/kubebuilder/bin/kubebuilder-gen ./cmd/kubebuilder-gen
6886
}
6987

7088
function prepare_vendor_deps {
89+
header_text "preparing vendor dependencies"
7190
# TODO(droot): clean up this function
7291
rm -rf $kb_vendor_dir && rm -f $tmp_root/Gopkg.toml && rm -f $tmp_root/Gopkg.lock
7392
mkdir -p $kb_vendor_dir/github.com/kubernetes-sigs/kubebuilder/pkg/ || echo ""
@@ -82,11 +101,15 @@ function prepare_vendor_deps {
82101

83102
function prepare_testdir_under_gopath {
84103
kb_test_dir=$GOPATH/src/github.com/kubernetes-sigs/kubebuilder-test
104+
header_text "preparing test directory $kb_test_dir"
85105
rm -rf $kb_test_dir && mkdir -p $kb_test_dir && cd $kb_test_dir
106+
header_text "running kubebuilder commands in test directory $kb_test_dir"
86107
}
87108

88109
function generate_crd_resources {
89-
# Setup env vars
110+
header_text "generating CRD resources and code"
111+
112+
# Setup env vars
90113
export PATH=/tmp/kubebuilder/bin/:$PATH
91114
export TEST_ASSET_KUBECTL=/tmp/kubebuilder/bin/kubectl
92115
export TEST_ASSET_KUBE_APISERVER=/tmp/kubebuilder/bin/kube-apiserver
@@ -99,9 +122,12 @@ function generate_crd_resources {
99122
}
100123

101124
function test_generated_controller {
102-
# Verify the controller-manager builds and the tests pass
125+
header_text "building generated code"
126+
# Verify the controller-manager builds and the tests pass
103127
go build ./cmd/...
104128
go build ./pkg/...
129+
130+
header_text "testing generated code"
105131
go test -v ./cmd/...
106132
go test -v ./pkg/...
107133
}

0 commit comments

Comments
 (0)