Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
8fe64670
Commit
8fe64670
authored
Aug 30, 2018
by
Katharine Berry
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve bash formatting.
parent
6afc1303
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
18 deletions
+18
-18
golang.sh
hack/lib/golang.sh
+17
-17
util.sh
hack/lib/util.sh
+1
-1
No files found.
hack/lib/golang.sh
View file @
8fe64670
...
...
@@ -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_dum
m
y_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
...
...
hack/lib/util.sh
View file @
8fe64670
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment