Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
7f86cb14
Unverified
Commit
7f86cb14
authored
May 08, 2019
by
Kubernetes Prow Robot
Committed by
GitHub
May 08, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #72167 from brahmaroutu/conformance_context
Comment association to ConformanceIt block should be validated properly.
parents
5f91b68d
1cb5872c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
2 deletions
+32
-2
walk.go
test/conformance/walk.go
+20
-2
walk_test.go
test/conformance/walk_test.go
+12
-0
No files found.
test/conformance/walk.go
View file @
7f86cb14
...
@@ -166,8 +166,26 @@ func (v *visitor) failf(expr ast.Expr, format string, a ...interface{}) {
...
@@ -166,8 +166,26 @@ func (v *visitor) failf(expr ast.Expr, format string, a ...interface{}) {
func
(
v
*
visitor
)
comment
(
x
*
ast
.
BasicLit
)
string
{
func
(
v
*
visitor
)
comment
(
x
*
ast
.
BasicLit
)
string
{
for
_
,
comm
:=
range
v
.
cMap
.
Comments
()
{
for
_
,
comm
:=
range
v
.
cMap
.
Comments
()
{
testOffset
:=
int
(
x
.
Pos
()
-
comm
.
End
())
-
len
(
"framework.ConformanceIt(
\"
"
)
testOffset
:=
int
(
x
.
Pos
()
-
comm
.
End
())
-
len
(
"framework.ConformanceIt(
\"
"
)
if
0
<
testOffset
&&
testOffset
<
3
{
//Cannot assume the offset is within three or four tabs from the test block itself.
return
comm
.
Text
()
//It is better to trim the newlines, tabs, etc and then we if the comment is followed
//by the test block itself so that we can associate the comment with it properly.
if
0
<=
testOffset
&&
testOffset
<=
10
{
b1
:=
make
([]
byte
,
x
.
Pos
()
-
comm
.
End
())
//if we fail to open the file to compare the content we just assume the
//proximity of the comment and apply it.
myf
,
err
:=
os
.
Open
(
v
.
FileSet
.
File
(
x
.
Pos
())
.
Name
())
if
err
==
nil
{
if
_
,
err
:=
myf
.
Seek
(
int64
(
comm
.
End
()),
0
);
err
==
nil
{
if
_
,
err
:=
myf
.
Read
(
b1
);
err
==
nil
{
if
strings
.
Compare
(
strings
.
Trim
(
string
(
b1
),
"
\t
\r\n
"
),
"framework.ConformanceIt(
\"
"
)
==
0
{
return
comm
.
Text
()
}
}
}
}
else
{
//comment section's end is noticed within 10 characters from framework.ConformanceIt block
return
comm
.
Text
()
}
}
}
}
}
return
""
return
""
...
...
test/conformance/walk_test.go
View file @
7f86cb14
...
@@ -80,6 +80,18 @@ var _ = framework.KubeDescribe("Feature", func() {
...
@@ -80,6 +80,18 @@ var _ = framework.KubeDescribe("Feature", func() {
Description
:
`By default the stdout and stderr from the process
Description
:
`By default the stdout and stderr from the process
being executed in a pod MUST be sent to the pod's logs.`
+
"
\n\n
"
}},
being executed in a pod MUST be sent to the pod's logs.`
+
"
\n\n
"
}},
},
},
{
"e2e/foo.go"
,
`
var _ = framework.KubeDescribe("Feature", func() {
Context("with context and extra spaces before It block should still pick up Testname", func() {
// Testname: Test with spaces
//Description: Should pick up testname even if it is not within 3 spaces
//even when executed from memory.
framework.ConformanceIt("should work", func() {})
})
})`
,
[]
conformanceData
{{
URL
:
"https://github.com/kubernetes/kubernetes/tree/master/e2e/foo.go#L8"
,
TestName
:
"Test with spaces"
,
Description
:
`Should pick up testname even if it is not within 3 spaces
even when executed from memory.`
+
"
\n\n
"
}},
},
}
}
func
TestConformance
(
t
*
testing
.
T
)
{
func
TestConformance
(
t
*
testing
.
T
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment