@@ -23,7 +23,6 @@ import (
23
23
"go/ast"
24
24
"go/parser"
25
25
"go/token"
26
- "gopkg.in/yaml.v2"
27
26
"io"
28
27
"log"
29
28
"os"
@@ -33,11 +32,27 @@ import (
33
32
"strings"
34
33
"text/template"
35
34
36
- "github.com/onsi/ginkgo/types "
35
+ "gopkg.in/yaml.v2 "
37
36
38
- "k8s.io/kubernetes/test/conformance/behaviors "
37
+ "github.com/onsi/ginkgo/types "
39
38
)
40
39
40
+ // ConformanceData describes the structure of the conformance.yaml file
41
+ type ConformanceData struct {
42
+ // A URL to the line of code in the kube src repo for the test. Omitted from the YAML to avoid exposing line number.
43
+ URL string `yaml:"-"`
44
+ // Extracted from the "Testname:" comment before the test
45
+ TestName string
46
+ // CodeName is taken from the actual ginkgo descriptions, e.g. `[sig-apps] Foo should bar [Conformance]`
47
+ CodeName string
48
+ // Extracted from the "Description:" comment before the test
49
+ Description string
50
+ // Version when this test is added or modified ex: v1.12, v1.13
51
+ Release string
52
+ // File is the filename where the test is defined. We intentionally don't save the line here to avoid meaningless changes.
53
+ File string
54
+ }
55
+
41
56
var (
42
57
baseURL = flag .String ("url" , "https://github.com/kubernetes/kubernetes/tree/master/" , "location of the current source" )
43
58
k8sPath = flag .String ("source" , "" , "location of the current source on the current machine" )
@@ -80,7 +95,7 @@ func main() {
80
95
81
96
seenLines = map [string ]struct {}{}
82
97
dec := json .NewDecoder (f )
83
- testInfos := []* behaviors. ConformanceData {}
98
+ testInfos := []* ConformanceData {}
84
99
for {
85
100
var spec * types.SpecSummary
86
101
if err := dec .Decode (& spec ); err == io .EOF {
@@ -109,8 +124,8 @@ func isConformance(spec *types.SpecSummary) bool {
109
124
return strings .Contains (getTestName (spec ), "[Conformance]" )
110
125
}
111
126
112
- func getTestInfo (spec * types.SpecSummary ) * behaviors. ConformanceData {
113
- var c * behaviors. ConformanceData
127
+ func getTestInfo (spec * types.SpecSummary ) * ConformanceData {
128
+ var c * ConformanceData
114
129
var err error
115
130
// The key to this working is that we don't need to parse every file or walk
116
131
// every componentCodeLocation. The last componentCodeLocation is going to typically start
@@ -140,7 +155,7 @@ func getTestName(spec *types.SpecSummary) string {
140
155
return strings .Join (spec .ComponentTexts [1 :], " " )
141
156
}
142
157
143
- func saveAllTestInfo (dataSet []* behaviors. ConformanceData ) {
158
+ func saveAllTestInfo (dataSet []* ConformanceData ) {
144
159
if * confDoc {
145
160
// Note: this assumes that you're running from the root of the kube src repo
146
161
templ , err := template .ParseFiles ("./test/conformance/cf_header.md" )
@@ -171,7 +186,7 @@ func saveAllTestInfo(dataSet []*behaviors.ConformanceData) {
171
186
fmt .Println (string (b ))
172
187
}
173
188
174
- func getConformanceDataFromStackTrace (fullstackstrace string ) (* behaviors. ConformanceData , error ) {
189
+ func getConformanceDataFromStackTrace (fullstackstrace string ) (* ConformanceData , error ) {
175
190
// The full stacktrace to parse from ginkgo is of the form:
176
191
// k8s.io/kubernetes/test/e2e/storage/utils.SIGDescribe(0x51f4c4f, 0xf, 0x53a0dd8, 0xc000ab6e01)\n\ttest/e2e/storage/utils/framework.go:23 +0x75\n ... ...
177
192
// So we need to split it into lines, remove whitespace, and then grab the files/lines.
@@ -225,7 +240,7 @@ func getConformanceDataFromStackTrace(fullstackstrace string) (*behaviors.Confor
225
240
226
241
// scanFileForFrame will scan the target and look for a conformance comment attached to the function
227
242
// described by the target frame. If the comment can't be found then nil, nil is returned.
228
- func scanFileForFrame (filename string , src interface {}, targetFrame frame ) (* behaviors. ConformanceData , error ) {
243
+ func scanFileForFrame (filename string , src interface {}, targetFrame frame ) (* ConformanceData , error ) {
229
244
fset := token .NewFileSet () // positions are relative to fset
230
245
f , err := parser .ParseFile (fset , filename , src , parser .ParseComments )
231
246
if err != nil {
@@ -251,7 +266,7 @@ func validateTestName(s string) error {
251
266
return nil
252
267
}
253
268
254
- func tryCommentGroupAndFrame (fset * token.FileSet , cg * ast.CommentGroup , f frame ) * behaviors. ConformanceData {
269
+ func tryCommentGroupAndFrame (fset * token.FileSet , cg * ast.CommentGroup , f frame ) * ConformanceData {
255
270
if ! shouldProcessCommentGroup (fset , cg , f ) {
256
271
return nil
257
272
}
@@ -275,10 +290,10 @@ func shouldProcessCommentGroup(fset *token.FileSet, cg *ast.CommentGroup, f fram
275
290
return lineDiff > 0 && lineDiff <= conformanceCommentsLineWindow
276
291
}
277
292
278
- func commentToConformanceData (comment string ) * behaviors. ConformanceData {
293
+ func commentToConformanceData (comment string ) * ConformanceData {
279
294
lines := strings .Split (comment , "\n " )
280
295
descLines := []string {}
281
- cd := & behaviors. ConformanceData {}
296
+ cd := & ConformanceData {}
282
297
var curLine string
283
298
for _ , line := range lines {
284
299
line = strings .TrimSpace (line )
@@ -300,17 +315,9 @@ func commentToConformanceData(comment string) *behaviors.ConformanceData {
300
315
descLines = append (descLines , sline [1 ])
301
316
continue
302
317
}
303
- if sline := regexp .MustCompile ("^Behaviors\\ s*:\\ s*" ).Split (line , - 1 ); len (sline ) == 2 {
304
- curLine = "Behaviors"
305
- continue
306
- }
307
318
308
319
// Line has no header
309
- if curLine == "Behaviors" {
310
- if sline := regexp .MustCompile ("^-\\ s" ).Split (line , - 1 ); len (sline ) == 2 {
311
- cd .Behaviors = append (cd .Behaviors , sline [1 ])
312
- }
313
- } else if curLine == "Description" {
320
+ if curLine == "Description" {
314
321
descLines = append (descLines , line )
315
322
}
316
323
}
0 commit comments