Commit 50cf8b85 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 7394278b
...@@ -156,6 +156,22 @@ func TestDeadlock(t *testing.T) { ...@@ -156,6 +156,22 @@ func TestDeadlock(t *testing.T) {
}, "-tracetest.deadtime=0.5s") }, "-tracetest.deadtime=0.5s")
} }
// TestExpectType demonstrates Expect asserting with "unexpected event type".
func TestExpectType(t *testing.T) {
verify(t, func(t *tracetest.T) {
var wg sync.WaitGroup
defer wg.Wait()
wg.Add(1)
go func() { // thread 1
defer wg.Done()
hi("T1·A")
}()
t.Expect("t1", eventHello("T1·A"))
})
}
// XXX race bug with sleep caught only by delay injection // XXX race bug with sleep caught only by delay injection
...@@ -231,6 +247,7 @@ type testExpect struct { ...@@ -231,6 +247,7 @@ type testExpect struct {
// testExpectMap maps <test name> -> testExpect. // testExpectMap maps <test name> -> testExpect.
var testExpectMap = map[string]testExpect{ var testExpectMap = map[string]testExpect{
"Test2ThreadsOK": {0, ""}, "Test2ThreadsOK": {0, ""},
"TestDeadlock": {1, "TestDeadlock": {1,
`--- FAIL: TestDeadlock (<TIME>) `--- FAIL: TestDeadlock (<TIME>)
example_test.go:155: t2: recv: deadlock waiting for *tracetest_test.eventHi example_test.go:155: t2: recv: deadlock waiting for *tracetest_test.eventHi
...@@ -240,4 +257,13 @@ var testExpectMap = map[string]testExpect{ ...@@ -240,4 +257,13 @@ var testExpectMap = map[string]testExpect{
tracetest.go:<LINE>: t1: send: canceled (test failed) tracetest.go:<LINE>: t1: send: canceled (test failed)
`}, `},
"TestExpectType": {1,
`--- FAIL: TestExpectType (<TIME>)
example_test.go:171: t1: expect: tracetest_test.eventHello: got tracetest_test.eventHi T1·A
example_test.go:171: test shutdown: #streams: 1, #(pending events): 0
# t1
tracetest.go:<LINE>: t1: send: unexpected event type
`},
} }
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