Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
2fcb0452
Commit
2fcb0452
authored
Nov 08, 2011
by
Andrew Gerrand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gotest: don't run examples that have no expected output
R=golang-dev, rsc CC=golang-dev
https://golang.org/cl/5364041
parent
46ee09ef
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
2 deletions
+8
-2
src/cmd/gotest/doc.go
src/cmd/gotest/doc.go
+1
-0
src/cmd/gotest/gotest.go
src/cmd/gotest/gotest.go
+7
-2
No files found.
src/cmd/gotest/doc.go
View file @
2fcb0452
...
...
@@ -37,6 +37,7 @@ os.Stdout and os.Stderr is compared against their doc comment.
Multiple example functions may be provided for a given name XXX if they are
discriminated by a distinct suffix starting with "_", such as ExampleXXX_2.
Example functions without doc comments are compiled but not executed.
See the documentation of the testing package for more information.
...
...
src/cmd/gotest/gotest.go
View file @
2fcb0452
...
...
@@ -231,9 +231,14 @@ func getTestNames() {
}
else
if
isTest
(
name
,
"Benchmark"
)
{
f
.
benchmarks
=
append
(
f
.
benchmarks
,
name
)
}
else
if
isTest
(
name
,
"Example"
)
{
output
:=
doc
.
CommentText
(
n
.
Doc
)
if
output
==
""
{
// Don't run examples with no output.
continue
}
f
.
examples
=
append
(
f
.
examples
,
example
{
name
:
name
,
output
:
doc
.
CommentText
(
n
.
Doc
)
,
output
:
output
,
})
}
// TODO: worth checking the signature? Probably not.
...
...
@@ -372,7 +377,7 @@ func writeTestmainGo() {
insideTests
:=
false
for
_
,
f
:=
range
files
{
//println(f.name, f.pkg)
if
len
(
f
.
tests
)
==
0
&&
len
(
f
.
benchmarks
)
==
0
{
if
len
(
f
.
tests
)
==
0
&&
len
(
f
.
benchmarks
)
==
0
&&
len
(
f
.
examples
)
==
0
{
continue
}
if
isOutsideTest
(
f
.
pkg
)
{
...
...
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