Commit 13d1961d authored by Katharine Berry's avatar Katharine Berry

Improve error behaviour of package coverage.

parent facce197
...@@ -22,6 +22,7 @@ package coverage ...@@ -22,6 +22,7 @@ package coverage
import ( import (
"flag" "flag"
"fmt"
"github.com/golang/glog" "github.com/golang/glog"
"k8s.io/apimachinery/pkg/util/wait" "k8s.io/apimachinery/pkg/util/wait"
"os" "os"
...@@ -29,8 +30,6 @@ import ( ...@@ -29,8 +30,6 @@ import (
"time" "time"
) )
var flushInterval = 5 * time.Second
var coverageFile string var coverageFile string
// tempCoveragePath returns a temporary file to write coverage information to. // tempCoveragePath returns a temporary file to write coverage information to.
...@@ -48,9 +47,16 @@ func InitCoverage(name string) { ...@@ -48,9 +47,16 @@ func InitCoverage(name string) {
if coverageFile == "" { if coverageFile == "" {
coverageFile = "/tmp/k8s-" + name + ".cov" coverageFile = "/tmp/k8s-" + name + ".cov"
} }
fmt.Println("Dumping coverage information to " + coverageFile)
if duration, err := time.ParseDuration(os.Getenv("KUBE_COVERAGE_FLUSH_INTERVAL")); err == nil {
flushInterval = duration 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. // Set up the unit test framework with the required arguments to activate test coverage.
......
...@@ -18,9 +18,9 @@ limitations under the License. ...@@ -18,9 +18,9 @@ limitations under the License.
package coverage package coverage
// InitCoverage is a no-op when not running with coverage. // InitCoverage is illegal when not running with coverage.
func InitCoverage(name string) { func InitCoverage(name string) {
panic("Called InitCoverage when not built with coverage instrumentation.")
} }
// FlushCoverage is a no-op when not running with coverage. // FlushCoverage is a no-op when not running with coverage.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment