Merge pull request #2720 from brendandburns/tap

Add support for TAP (test anything protocol) output
This commit is contained in:
Daniel Smith 2014-12-15 18:29:04 -08:00
commit 0fd1ed2ba9

View File

@ -351,6 +351,33 @@ func TestNetwork(c *client.Client) bool {
return false return false
} }
type TestSpec struct {
// The test to run
test func(c *client.Client) bool
// The human readable name of this test
name string
// The id for this test. It should be constant for the life of the test.
id int
}
type TestInfo struct {
passed bool
spec TestSpec
}
// Output a summary in the TAP (test anything protocol) format for automated processing.
// See http://testanything.org/ for more info
func outputTAPSummary(infoList []TestInfo) {
glog.Infof("1..%d", len(infoList))
for _, info := range infoList {
if info.passed {
glog.Infof("ok %d - %s", info.spec.id, info.spec.name)
} else {
glog.Infof("not ok %d - %s", info.spec.id, info.spec.name)
}
}
}
func main() { func main() {
flag.Parse() flag.Parse()
goruntime.GOMAXPROCS(goruntime.NumCPU()) goruntime.GOMAXPROCS(goruntime.NumCPU())
@ -366,23 +393,26 @@ func main() {
c := loadClientOrDie() c := loadClientOrDie()
tests := []func(c *client.Client) bool{ // Define the tests. Important: for a clean test grid, please keep ids for a test constant.
TestKubernetesROService, tests := []TestSpec{
TestKubeletSendsEvent, {TestKubernetesROService, "TestKubernetesROService", 1},
TestImportantURLs, {TestKubeletSendsEvent, "TestKubeletSendsEvent", 2},
TestPodUpdate, {TestImportantURLs, "TestImportantURLs", 3},
TestNetwork, {TestPodUpdate, "TestPodUpdate", 4},
{TestNetwork, "TestNetwork", 5},
} }
info := []TestInfo{}
passed := true passed := true
for _, test := range tests { for _, test := range tests {
testPassed := test(c) testPassed := test.test(c)
if !testPassed { if !testPassed {
passed = false passed = false
} } // TODO: clean up objects created during a test after the test, so cases
// TODO: clean up objects created during a test after the test, so cases
// are independent. // are independent.
info = append(info, TestInfo{testPassed, test})
} }
outputTAPSummary(info)
if !passed { if !passed {
glog.Fatalf("Tests failed") glog.Fatalf("Tests failed")
} }