lang: Avoid running graphviz in tests by default

This will help travis actually run the tests faster.
This commit is contained in:
James Shubin
2019-07-17 00:29:27 -04:00
parent f53376cea1
commit e57ca15330

View File

@@ -40,6 +40,10 @@ import (
"github.com/spf13/afero" "github.com/spf13/afero"
) )
const (
runGraphviz = false // run graphviz in tests?
)
func vertexAstCmpFn(v1, v2 pgraph.Vertex) (bool, error) { func vertexAstCmpFn(v1, v2 pgraph.Vertex) (bool, error) {
//fmt.Printf("V1: %T %+v\n", v1, v1) //fmt.Printf("V1: %T %+v\n", v1, v1)
//node := v1.(*funcs.Node) //node := v1.(*funcs.Node)
@@ -902,11 +906,13 @@ func TestAstFunc1(t *testing.T) {
t.Logf("test #%d: edge(%+v): %+v -> %+v", index, e, v1, v2) t.Logf("test #%d: edge(%+v): %+v -> %+v", index, e, v1, v2)
} }
} }
t.Logf("test #%d: Running graphviz...", index) if runGraphviz {
if err := graph.ExecGraphviz("dot", "/tmp/graphviz.dot", ""); err != nil { t.Logf("test #%d: Running graphviz...", index)
t.Errorf("test #%d: FAIL", index) if err := graph.ExecGraphviz("dot", "/tmp/graphviz.dot", ""); err != nil {
t.Errorf("test #%d: writing graph failed: %+v", index, err) t.Errorf("test #%d: FAIL", index)
return t.Errorf("test #%d: writing graph failed: %+v", index, err)
return
}
} }
str := strings.Trim(graph.Sprint(), "\n") // text format of graph str := strings.Trim(graph.Sprint(), "\n") // text format of graph
@@ -1334,11 +1340,14 @@ func TestAstFunc2(t *testing.T) {
t.Logf("test #%d: edge(%+v): %+v -> %+v", index, e, v1, v2) t.Logf("test #%d: edge(%+v): %+v -> %+v", index, e, v1, v2)
} }
} }
t.Logf("test #%d: Running graphviz...", index)
if err := graph.ExecGraphviz("dot", "/tmp/graphviz.dot", ""); err != nil { if runGraphviz {
t.Errorf("test #%d: FAIL", index) t.Logf("test #%d: Running graphviz...", index)
t.Errorf("test #%d: writing graph failed: %+v", index, err) if err := graph.ExecGraphviz("dot", "/tmp/graphviz.dot", ""); err != nil {
return t.Errorf("test #%d: FAIL", index)
t.Errorf("test #%d: writing graph failed: %+v", index, err)
return
}
} }
// run the function engine once to get some real output // run the function engine once to get some real output