Commit 74905116 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 5b07254a
...@@ -106,7 +106,7 @@ func TestTracetestExample(t *testing.T) { ...@@ -106,7 +106,7 @@ func TestTracetestExample(t *testing.T) {
}() }()
// assert that events come as expected // assert that events come as expected
t.Expect("t2", eventHello("T1·C")) t.Expect("t2", eventHello("T2·C"))
t.Expect("t1", eventHi("T1·A")) t.Expect("t1", eventHi("T1·A"))
t.Expect("t1", eventHello("T1·B")) t.Expect("t1", eventHello("T1·B"))
......
...@@ -523,12 +523,16 @@ func (t *T) SetEventRouter(routeEvent func(event interface{}) (stream string)) { ...@@ -523,12 +523,16 @@ func (t *T) SetEventRouter(routeEvent func(event interface{}) (stream string)) {
// XXX doc; naming // XXX doc; naming
func (t *T) RxEvent(event interface{}) { func (t *T) RxEvent(event interface{}) {
stream := "default"
t.streamTabMu.Lock() t.streamTabMu.Lock()
ch := t.chanForEvent(event) if t.routeEvent != nil {
stream = t.routeEvent(event)
}
ch := t.chanForStream(stream)
t.streamTabMu.Unlock() t.streamTabMu.Unlock()
if ch == nil { if ch == nil {
t.fatalfInNonMain("test failed") t.fatalfInNonMain("%s: send: canceled (test failed)", stream)
} }
// TODO it is possible to empirically detect here if a test incorrectly // TODO it is possible to empirically detect here if a test incorrectly
...@@ -563,6 +567,7 @@ func (t *T) RxEvent(event interface{}) { ...@@ -563,6 +567,7 @@ func (t *T) RxEvent(event interface{}) {
ch.Send(event) ch.Send(event)
} }
/*
// chanForEvent returns channel corresponding to stream where event has to be delivered. // chanForEvent returns channel corresponding to stream where event has to be delivered.
// must be called under streamTabMu. // must be called under streamTabMu.
func (t *T) chanForEvent(event interface{}) Chan { func (t *T) chanForEvent(event interface{}) Chan {
...@@ -572,6 +577,7 @@ func (t *T) chanForEvent(event interface{}) Chan { ...@@ -572,6 +577,7 @@ func (t *T) chanForEvent(event interface{}) Chan {
} }
return t.chanForStream(stream) return t.chanForStream(stream)
} }
*/
// chanForStream returns channel corresponding to stream. // chanForStream returns channel corresponding to stream.
// must be called under streamTabMu. // must be called under streamTabMu.
...@@ -790,7 +796,7 @@ func (t *T) FailNow() { ...@@ -790,7 +796,7 @@ func (t *T) FailNow() {
__.msg.nak(__.why) __.msg.nak(__.why)
} }
for _, __ := range sendv { for _, __ := range sendv {
__.msg.nak("test failed") // XXX reason can be custom / different __.msg.nak("canceled (test failed)") // XXX reason can be custom / different
} }
// in any case close channel where future Sends may arrive so that will "panic" too. // in any case close channel where future Sends may arrive so that will "panic" too.
for _, ch := range streamTab { for _, ch := range streamTab {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment