Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
cee92022
Commit
cee92022
authored
Feb 06, 2012
by
David Symonds
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
testing: capture panics, present them, and mark the test as a failure.
R=r CC=golang-dev
https://golang.org/cl/5633044
parent
e066db3a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
0 deletions
+20
-0
testing.go
src/pkg/testing/testing.go
+20
-0
No files found.
src/pkg/testing/testing.go
View file @
cee92022
...
...
@@ -225,6 +225,19 @@ func (c *common) Fatalf(format string, args ...interface{}) {
c
.
FailNow
()
}
// TODO(dsymonds): Consider hooking into runtime·traceback instead.
func
(
c
*
common
)
stack
()
{
for
i
:=
2
;
;
i
++
{
// Caller we care about is the user, 2 frames up
pc
,
file
,
line
,
ok
:=
runtime
.
Caller
(
i
)
f
:=
runtime
.
FuncForPC
(
pc
)
if
!
ok
||
f
==
nil
{
break
}
c
.
Logf
(
"%s:%d (0x%x)"
,
file
,
line
,
pc
)
c
.
Logf
(
"
\t
%s"
,
f
.
Name
())
}
}
// Parallel signals that this test is to be run in parallel with (and only with)
// other parallel tests in this CPU group.
func
(
t
*
T
)
Parallel
()
{
...
...
@@ -247,6 +260,13 @@ func tRunner(t *T, test *InternalTest) {
// a call to runtime.Goexit, record the duration and send
// a signal saying that the test is done.
defer
func
()
{
// Consider any uncaught panic a failure.
if
err
:=
recover
();
err
!=
nil
{
t
.
failed
=
true
t
.
Log
(
err
)
t
.
stack
()
}
t
.
duration
=
time
.
Now
()
.
Sub
(
t
.
start
)
t
.
signal
<-
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