func parseResult()

in testworkflow.go [1095:1161]


func parseResult(res testResult, localPath string) junit.Testsuite {
	ret := junit.Testsuite{}
	name := getTestSuiteName(res.testWorkflow)

	switch {
	case res.skipped:
		for _, test := range getTestsBySuiteName(res.testWorkflow.Name, localPath) {
			tc := junit.Testcase{}
			tc.Classname = name
			tc.Name = test
			tc.Skipped = &junit.Result{Data: res.testWorkflow.SkippedMessage()}
			ret.Testcases = append(ret.Testcases, tc)

			ret.Tests++
			ret.Skipped++
		}
	case res.workflowSuccess:
		// Workflow completed without error. Only in this case do we try to parse the result.
		ret = convertToTestSuite(res.results, name)
		// Tests handled by a suite but not executed or skipped should be marked disabled
		for _, test := range getTestsBySuiteName(res.testWorkflow.Name, localPath) {
			hasResult := false
			for _, tc := range ret.Testcases {
				if tc.Name == test {
					hasResult = true
					break
				}
			}
			if hasResult {
				continue
			}
			newTc := junit.Testcase{}
			newTc.Classname = name
			newTc.Name = test
			newTc.Skipped = &junit.Result{Data: fmt.Sprintf("%s disabled on %s", test, res.testWorkflow.ImageURL)}
			ret.Testcases = append(ret.Testcases, newTc)
			ret.Tests++
			ret.Skipped++
		}
		ret.AddProperty("image_family", res.testWorkflow.Image.Family)
		ret.AddProperty("image", res.testWorkflow.Image.SelfLink)
		ret.AddProperty("project", res.testWorkflow.Project.Name)
	default:
		var status string
		if res.err != nil {
			status = res.err.Error()
		} else {
			status = "Unknown status"
		}
		for _, test := range getTestsBySuiteName(res.testWorkflow.Name, localPath) {
			tc := junit.Testcase{}
			tc.Classname = name
			tc.Name = test
			tc.Failure = &junit.Result{Data: status, Type: "Failure"}
			ret.Testcases = append(ret.Testcases, tc)

			ret.Tests++
			ret.Failures++
		}
	}

	ret.Name = name
	if ret.Time == "" {
		ret.Time = "0.000"
	}
	return ret
}