From e57ca153308f827c3674d1e6f1a558b619c0a247 Mon Sep 17 00:00:00 2001 From: James Shubin Date: Wed, 17 Jul 2019 00:29:27 -0400 Subject: [PATCH] lang: Avoid running graphviz in tests by default This will help travis actually run the tests faster. --- lang/interpret_test.go | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/lang/interpret_test.go b/lang/interpret_test.go index b7e34ceb..33304e4a 100644 --- a/lang/interpret_test.go +++ b/lang/interpret_test.go @@ -40,6 +40,10 @@ import ( "github.com/spf13/afero" ) +const ( + runGraphviz = false // run graphviz in tests? +) + func vertexAstCmpFn(v1, v2 pgraph.Vertex) (bool, error) { //fmt.Printf("V1: %T %+v\n", v1, v1) //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: Running graphviz...", index) - if err := graph.ExecGraphviz("dot", "/tmp/graphviz.dot", ""); err != nil { - t.Errorf("test #%d: FAIL", index) - t.Errorf("test #%d: writing graph failed: %+v", index, err) - return + if runGraphviz { + t.Logf("test #%d: Running graphviz...", index) + if err := graph.ExecGraphviz("dot", "/tmp/graphviz.dot", ""); err != nil { + t.Errorf("test #%d: FAIL", index) + t.Errorf("test #%d: writing graph failed: %+v", index, err) + return + } } 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: Running graphviz...", index) - if err := graph.ExecGraphviz("dot", "/tmp/graphviz.dot", ""); err != nil { - t.Errorf("test #%d: FAIL", index) - t.Errorf("test #%d: writing graph failed: %+v", index, err) - return + + if runGraphviz { + t.Logf("test #%d: Running graphviz...", index) + if err := graph.ExecGraphviz("dot", "/tmp/graphviz.dot", ""); err != nil { + 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