Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
Commits
d7528830
Commit
d7528830
authored
Jan 03, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
18a556b7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
39 deletions
+39
-39
go/internal/xtracing/tracetest/chan.go
go/internal/xtracing/tracetest/chan.go
+11
-0
go/internal/xtracing/tracetest/tracetest.go
go/internal/xtracing/tracetest/tracetest.go
+28
-39
No files found.
go/internal/xtracing/tracetest/chan.go
View file @
d7528830
...
...
@@ -140,6 +140,17 @@ func (m *_Msg) nak(why string) {
m
.
ack
<-
errors
.
New
(
why
)
}
// nak represents scheduled call to `msg.nak(why)`.
type
nak
struct
{
msg
*
_Msg
why
string
}
// queuenak schedules call to `msg.nak(why)`.
func
(
t
*
T
)
queuenak
(
msg
*
_Msg
,
why
string
)
{
t
.
nakq
=
append
(
t
.
nakq
,
nak
{
msg
,
why
})
}
// newChan creates new _chan channel.
func
(
t
*
T
)
newChan
(
name
string
)
*
_chan
{
// NOTE T ensures not to create channels with duplicate names.
...
...
go/internal/xtracing/tracetest/tracetest.go
View file @
d7528830
...
...
@@ -155,11 +155,6 @@ type delayInjectState struct {
delayT
time
.
Duration
// by delayT time.
}
type
nak
struct
{
msg
*
_Msg
why
string
}
// SetEventRouter tells t to which stream an event should go.
//
...
...
@@ -221,7 +216,20 @@ func (t *T) RxEvent(event interface{}) {
// xget1 gets 1 event in place and checks it has expected type
//
// if checks do not pass - fatal testing error is raised
func
(
t
*
T
)
xget1
(
stream
string
,
eventp
interface
{})
*
_Msg
{
t
.
Helper
()
t
.
mu
.
Lock
()
ch
:=
t
.
chanForStream
(
stream
)
t
.
mu
.
Unlock
()
// XXX ch == nil -> no longer operational
return
ch
.
RecvInto
(
eventp
)
}
...
...
@@ -230,20 +238,7 @@ func (t *T) RxEvent(event interface{}) {
// chanForStream returns channel corresponding to stream.
// must be called under mu.
func
(
t
*
T
)
chanForStream
(
stream
string
)
*
_chan
{
if
t
.
streamTab
==
nil
{
return
nil
// t is no longer operational after e.g. deadlock
}
ch
,
ok
:=
t
.
streamTab
[
stream
]
if
!
ok
{
ch
=
t
.
newChan
(
stream
)
t
.
streamTab
[
stream
]
=
ch
}
return
ch
}
// Expect receives next event on stream and verifies it to be equal to eventOK.
//
...
...
@@ -286,21 +281,6 @@ func (t *T) expect1(stream string, eventExpect interface{}) *_Msg {
return
msg
}
// xget1 gets 1 event in place and checks it has expected type
//
// if checks do not pass - fatal testing error is raised
func
(
t
*
T
)
xget1
(
stream
string
,
eventp
interface
{})
*
_Msg
{
t
.
Helper
()
t
.
mu
.
Lock
()
ch
:=
t
.
chanForStream
(
stream
)
t
.
mu
.
Unlock
()
// XXX ch == nil -> no longer operational
return
ch
.
RecvInto
(
eventp
)
}
// fatalfInNonMain should be called for fatal cases in non-main goroutines instead of panic.
//
// we don't panic because it will stop the process and prevent the main
...
...
@@ -515,6 +495,21 @@ func Verify(t *testing.T, f func(t *T)) {
}
}
// chanForStream returns channel corresponding to stream.
// must be called under mu.
func
(
t
*
T
)
chanForStream
(
stream
string
)
*
_chan
{
if
t
.
streamTab
==
nil
{
return
nil
// t is no longer operational after e.g. deadlock
}
ch
,
ok
:=
t
.
streamTab
[
stream
]
if
!
ok
{
ch
=
t
.
newChan
(
stream
)
t
.
streamTab
[
stream
]
=
ch
}
return
ch
}
// streamsOfTrace returns sorted list of all streams present in a trace.
func
streamsOfTrace
(
tracev
[]
eventTrace
)
[]
string
{
...
...
@@ -529,9 +524,3 @@ func streamsOfTrace(tracev []eventTrace) []string {
sort
.
Strings
(
streamv
)
return
streamv
}
// XXX place; just use t.Cleanup instead?
func
(
t
*
T
)
queuenak
(
msg
*
_Msg
,
why
string
)
{
t
.
nakq
=
append
(
t
.
nakq
,
nak
{
msg
,
why
})
}
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