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
13d1961d
Commit
13d1961d
authored
Aug 31, 2018
by
Katharine Berry
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve error behaviour of package coverage.
parent
facce197
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
7 deletions
+13
-7
coverage.go
pkg/util/coverage/coverage.go
+11
-5
coverage_disabled.go
pkg/util/coverage/coverage_disabled.go
+2
-2
No files found.
pkg/util/coverage/coverage.go
View file @
13d1961d
...
...
@@ -22,6 +22,7 @@ package coverage
import
(
"flag"
"fmt"
"github.com/golang/glog"
"k8s.io/apimachinery/pkg/util/wait"
"os"
...
...
@@ -29,8 +30,6 @@ import (
"time"
)
var
flushInterval
=
5
*
time
.
Second
var
coverageFile
string
// tempCoveragePath returns a temporary file to write coverage information to.
...
...
@@ -48,9 +47,16 @@ func InitCoverage(name string) {
if
coverageFile
==
""
{
coverageFile
=
"/tmp/k8s-"
+
name
+
".cov"
}
if
duration
,
err
:=
time
.
ParseDuration
(
os
.
Getenv
(
"KUBE_COVERAGE_FLUSH_INTERVAL"
));
err
==
nil
{
flushInterval
=
duration
fmt
.
Println
(
"Dumping coverage information to "
+
coverageFile
)
flushInterval
:=
5
*
time
.
Second
requestedInterval
:=
os
.
Getenv
(
"KUBE_COVERAGE_FLUSH_INTERVAL"
)
if
requestedInterval
!=
""
{
if
duration
,
err
:=
time
.
ParseDuration
(
requestedInterval
);
err
==
nil
{
flushInterval
=
duration
}
else
{
panic
(
"Invalid KUBE_COVERAGE_FLUSH_INTERVAL value; try something like '30s'."
)
}
}
// Set up the unit test framework with the required arguments to activate test coverage.
...
...
pkg/util/coverage/coverage_disabled.go
View file @
13d1961d
...
...
@@ -18,9 +18,9 @@ limitations under the License.
package
coverage
// InitCoverage is
a no-op
when not running with coverage.
// InitCoverage is
illegal
when not running with coverage.
func
InitCoverage
(
name
string
)
{
panic
(
"Called InitCoverage when not built with coverage instrumentation."
)
}
// FlushCoverage is a no-op when not running with coverage.
...
...
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