Remove intermittent failure from newEdge test
Because the vertex visit was record after the Update call, Updated vertices may have been visited before the visit was recorded, causing occasional test failures. The order is now deterministic, and we can remove the brute-force loop.
This commit is contained in:
parent
7bf33c2a7f
commit
d01b0b0647
|
@ -175,8 +175,6 @@ func TestWalker_removeVertex(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestWalker_newEdge(t *testing.T) {
|
||||
// Run it a bunch of times since it is timing dependent
|
||||
for i := 0; i < 50; i++ {
|
||||
var g AcyclicGraph
|
||||
g.Add(1)
|
||||
g.Add(2)
|
||||
|
@ -186,16 +184,18 @@ func TestWalker_newEdge(t *testing.T) {
|
|||
var order []interface{}
|
||||
recordF := walkCbRecord(&order)
|
||||
|
||||
// Build a callback that delays until we close a channel
|
||||
var w *Walker
|
||||
cb := func(v Vertex) error {
|
||||
// record where we are first, otherwise the Updated vertex may get
|
||||
// walked before the first visit.
|
||||
err := recordF(v)
|
||||
|
||||
if v == 1 {
|
||||
g.Add(3)
|
||||
g.Connect(BasicEdge(3, 2))
|
||||
w.Update(&g)
|
||||
}
|
||||
|
||||
return recordF(v)
|
||||
return err
|
||||
}
|
||||
|
||||
// Add the initial vertices
|
||||
|
@ -212,7 +212,6 @@ func TestWalker_newEdge(t *testing.T) {
|
|||
if !reflect.DeepEqual(order, expected) {
|
||||
t.Fatalf("bad: %#v", order)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestWalker_removeEdge(t *testing.T) {
|
||||
|
|
Loading…
Reference in New Issue