mirror of
https://github.com/golang/go
synced 2024-11-18 09:04:49 -07:00
refactor/importgraph: add test of cycles
Nodes in a strongly connected component (which includes most stdlib packages) appear in results of both "forward" and "reverse" searches from any other node in the same SCC. LGTM=sameer R=sameer CC=golang-codereviews, gri https://golang.org/cl/136470044
This commit is contained in:
parent
520acf2e17
commit
fec4d1f60d
@ -59,6 +59,20 @@ func TestBuild(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// Test strongly-connected components. Because A's external
|
||||
// test package can depend on B, and vice versa, most of the
|
||||
// standard libraries are mutually dependent when their external
|
||||
// tests are considered.
|
||||
//
|
||||
// For any nodes x, y in the same SCC, y appears in the results
|
||||
// of both forward and reverse searches starting from x
|
||||
if !forward.Search("fmt")["io"] ||
|
||||
!forward.Search("io")["fmt"] ||
|
||||
!reverse.Search("fmt")["io"] ||
|
||||
!reverse.Search("io")["fmt"] {
|
||||
t.Errorf("fmt and io are not mutually reachable despite being in the same SCC")
|
||||
}
|
||||
|
||||
// debugging
|
||||
if false {
|
||||
for path, err := range errors {
|
||||
@ -76,6 +90,6 @@ func TestBuild(t *testing.T) {
|
||||
}
|
||||
}
|
||||
printSorted("forward", forward, this)
|
||||
printSorted("forward", reverse, this)
|
||||
printSorted("reverse", reverse, this)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user