Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go123
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
go123
Commits
8f1a4ded
Commit
8f1a4ded
authored
Dec 14, 2016
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
exc: In Addcallingcontext tests print name of problematic function
parent
0dfc5d9a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
2 deletions
+10
-2
exc/error_test.go
exc/error_test.go
+10
-2
No files found.
exc/error_test.go
View file @
8f1a4ded
...
@@ -14,6 +14,8 @@ package exc
...
@@ -14,6 +14,8 @@ package exc
import
(
import
(
"errors"
"errors"
"reflect"
"runtime"
"testing"
"testing"
"lab.nexedi.com/kirr/go123/myname"
"lab.nexedi.com/kirr/go123/myname"
...
@@ -115,6 +117,12 @@ func do_raise4f1() {
...
@@ -115,6 +117,12 @@ func do_raise4f1() {
do_raise4f
()
do_raise4f
()
}
}
// get name of a function
func
funcname
(
f
interface
{})
string
{
fentry
:=
reflect
.
ValueOf
(
f
)
.
Pointer
()
ffunc
:=
runtime
.
FuncForPC
(
fentry
)
return
ffunc
.
Name
()
}
func
TestErrAddCallingContext
(
t
*
testing
.
T
)
{
func
TestErrAddCallingContext
(
t
*
testing
.
T
)
{
var
tests
=
[]
struct
{
f
func
();
wanterrcontext
string
}
{
var
tests
=
[]
struct
{
f
func
();
wanterrcontext
string
}
{
...
@@ -130,11 +138,11 @@ func TestErrAddCallingContext(t *testing.T) {
...
@@ -130,11 +138,11 @@ func TestErrAddCallingContext(t *testing.T) {
e
=
Addcallingcontext
(
myfunc
,
e
)
e
=
Addcallingcontext
(
myfunc
,
e
)
msg
:=
e
.
Error
()
msg
:=
e
.
Error
()
if
msg
!=
tt
.
wanterrcontext
{
if
msg
!=
tt
.
wanterrcontext
{
t
.
Fatalf
(
"
err + calling context: %q ; want %q"
,
msg
,
tt
.
wanterrcontext
)
t
.
Fatalf
(
"
%v: err + calling context: %q ; want %q"
,
funcname
(
tt
.
f
)
,
msg
,
tt
.
wanterrcontext
)
}
}
})
})
tt
.
f
()
tt
.
f
()
t
.
Fatal
(
"error not caught"
)
t
.
Fatal
f
(
"%v: error not caught"
,
funcname
(
tt
.
f
)
)
}()
}()
}
}
}
}
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