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,12 +906,14 @@ 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)
} }
} }
if runGraphviz {
t.Logf("test #%d: Running graphviz...", index) t.Logf("test #%d: Running graphviz...", index)
if err := graph.ExecGraphviz("dot", "/tmp/graphviz.dot", ""); err != nil { if err := graph.ExecGraphviz("dot", "/tmp/graphviz.dot", ""); err != nil {
t.Errorf("test #%d: FAIL", index) t.Errorf("test #%d: FAIL", index)
t.Errorf("test #%d: writing graph failed: %+v", index, err) t.Errorf("test #%d: writing graph failed: %+v", index, err)
return return
} }
}
str := strings.Trim(graph.Sprint(), "\n") // text format of graph str := strings.Trim(graph.Sprint(), "\n") // text format of graph
if expstr == magicEmpty { if expstr == magicEmpty {
@@ -1334,12 +1340,15 @@ 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)
} }
} }
if runGraphviz {
t.Logf("test #%d: Running graphviz...", index) t.Logf("test #%d: Running graphviz...", index)
if err := graph.ExecGraphviz("dot", "/tmp/graphviz.dot", ""); err != nil { if err := graph.ExecGraphviz("dot", "/tmp/graphviz.dot", ""); err != nil {
t.Errorf("test #%d: FAIL", index) t.Errorf("test #%d: FAIL", index)
t.Errorf("test #%d: writing graph failed: %+v", index, err) t.Errorf("test #%d: writing graph failed: %+v", index, err)
return return
} }
}
// run the function engine once to get some real output // run the function engine once to get some real output
funcs := &funcs.Engine{ funcs := &funcs.Engine{