diff --git a/test/conformance/walk.go b/test/conformance/walk.go index 6cc600e9fc5..455f35fb9ff 100644 --- a/test/conformance/walk.go +++ b/test/conformance/walk.go @@ -76,6 +76,8 @@ type conformanceData struct { Release string // File is the filename where the test is defined. We intentionally don't save the line here to avoid meaningless changes. File string + // Behaviors is the list of conformance behaviors tested by a particular e2e test + Behaviors []string `yaml:"behaviors,omitempty"` } func main() { @@ -292,23 +294,40 @@ func commentToConformanceData(comment string) *conformanceData { lines := strings.Split(comment, "\n") descLines := []string{} cd := &conformanceData{} + var curLine string for _, line := range lines { line = strings.TrimSpace(line) if len(line) == 0 { continue } if sline := regexp.MustCompile("^Testname\\s*:\\s*").Split(line, -1); len(sline) == 2 { + curLine = "Testname" cd.TestName = sline[1] continue } if sline := regexp.MustCompile("^Release\\s*:\\s*").Split(line, -1); len(sline) == 2 { + curLine = "Release" cd.Release = sline[1] continue } if sline := regexp.MustCompile("^Description\\s*:\\s*").Split(line, -1); len(sline) == 2 { - line = sline[1] + curLine = "Description" + descLines = append(descLines, sline[1]) + continue + } + if sline := regexp.MustCompile("^Behaviors\\s*:\\s*").Split(line, -1); len(sline) == 2 { + curLine = "Behaviors" + continue + } + + // Line has no header + if curLine == "Behaviors" { + if sline := regexp.MustCompile("^-\\s").Split(line, -1); len(sline) == 2 { + cd.Behaviors = append(cd.Behaviors, sline[1]) + } + } else if curLine == "Description" { + descLines = append(descLines, line) } - descLines = append(descLines, line) } if cd.Release == "" && cd.TestName == "" { return nil diff --git a/test/conformance/walk_test.go b/test/conformance/walk_test.go index 339f4adbddf..066a83cd9cb 100644 --- a/test/conformance/walk_test.go +++ b/test/conformance/walk_test.go @@ -158,6 +158,14 @@ func TestCommentToConformanceData(t *testing.T) { desc: "All fields parsed and newlines and whitespace removed from description", input: "Release: v1.1\n\t\tTestname: mytest\n\t\tDescription: foo\n\t\tbar\ndone", expected: &conformanceData{TestName: "mytest", Release: "v1.1", Description: "foo bar done"}, + }, { + desc: "Behaviors are read", + input: "Testname: behaviors\nBehaviors:\n- should behave\n- second behavior", + expected: &conformanceData{TestName: "behaviors", Behaviors: []string{"should behave", "second behavior"}}, + }, { + desc: "Multiple behaviors are parsed", + input: "Testname: behaviors2\nBehaviors:\n- first behavior\n- second behavior", + expected: &conformanceData{TestName: "behaviors2", Behaviors: []string{"first behavior", "second behavior"}}, }, }