Center pipeline graphs and share port rows to reduce graph height
This commit is contained in:
@@ -18,11 +18,12 @@ func TestCompactGraphDimensions(t *testing.T) {
|
||||
for name, graph := range map[string]protocol.Graph{"linear": linear, "nested": nestedForkGraph(t)} {
|
||||
layout := layoutGraph(graph)
|
||||
t.Logf("%s: %d columns × %d rows", name, layout.width, layout.height)
|
||||
// Measured before compaction: linear 175×15; nested forks 147×48.
|
||||
if name == "linear" && (layout.width > 100 || layout.height > 15) {
|
||||
// Before compaction: linear 175×15; nested forks 147×48. Sharing input
|
||||
// and outcome rows trades a little width for substantially less height.
|
||||
if name == "linear" && (layout.width > 108 || layout.height > 12) {
|
||||
t.Fatal("linear graph grew", layout.width, layout.height)
|
||||
}
|
||||
if name == "nested" && (layout.width > 118 || layout.height > 41) {
|
||||
if name == "nested" && (layout.width > 134 || layout.height > 32) {
|
||||
t.Fatal("fork graph grew", layout.width, layout.height)
|
||||
}
|
||||
assertForkRouteClearance(t, layout)
|
||||
@@ -36,6 +37,17 @@ func TestCompactGraphDimensions(t *testing.T) {
|
||||
if !strings.Contains(view, fmt.Sprintf("%s [%d]", edge.label, edge.id)) {
|
||||
t.Fatal("compaction lost outcome", edge)
|
||||
}
|
||||
if !edge.topEntry {
|
||||
for _, node := range layout.nodes {
|
||||
if node.key == edge.target {
|
||||
line := renderGraph(graph)[edge.to]
|
||||
input := ansi.Strip(ansi.Cut(line, node.x+2, node.x+2+len(fmt.Sprintf("[%d]", edge.id))))
|
||||
if input != fmt.Sprintf("[%d]", edge.id) {
|
||||
t.Fatal("paired outcome overwrote input ID", edge, input)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user