File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package golden
22
33import (
44 "fmt"
5+ "strings"
56 "sync"
67 "testing"
78)
@@ -43,6 +44,9 @@ func DagTest(t *testing.T, cases []DagTestCase) {
4344 t .Fatal (err )
4445 }
4546
47+ // Print the DAG as a Mermaid diagram for visualization.
48+ t .Logf ("DAG diagram:\n %s" , dagToMermaid (cases ))
49+
4650 open := cases
4751 done := make (map [string ]bool )
4852
@@ -129,3 +133,17 @@ func validate(cases []DagTestCase) error {
129133
130134 return nil
131135}
136+
137+ // dagToMermaid converts a set of DAG test cases to a Mermaid diagram format.
138+ // This is useful for visualizing the dependencies between test cases.
139+ func dagToMermaid (cases []DagTestCase ) string {
140+ // Convert the DAG to a Mermaid diagram format.
141+ sb := & strings.Builder {}
142+ sb .WriteString ("graph TD\n " )
143+ for _ , c := range cases {
144+ for _ , need := range c .Needs {
145+ sb .WriteString (fmt .Sprintf (" %s --> %s\n " , need , c .Name ))
146+ }
147+ }
148+ return sb .String ()
149+ }
You can’t perform that action at this time.
0 commit comments