Skip to content

Commit

Permalink
*: remove dot run from in test
Browse files Browse the repository at this point in the history
  • Loading branch information
acekingke committed Nov 8, 2022
1 parent 91af095 commit 1687bcc
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 24 deletions.
3 changes: 2 additions & 1 deletion Graph/Graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ func DrawSimple() {
})
graphInst.AddNode("G", "b", nil)
graphInst.AddEdge("a", "b", true, nil)
SaveGraph("./one.png", graphInst)
//SaveGraph("./one.png", graphInst)
fmt.Println(graphInst.String())

}
40 changes: 19 additions & 21 deletions Graph/Graph_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,14 @@ package graph

import (
"fmt"
"os"
"os/exec"
"strings"
"testing"

"github.com/awalterschulze/gographviz"
)

func TestDrawSimple(t *testing.T) {
DrawSimple()
}
// func TestDrawSimple(t *testing.T) {
// DrawSimple()
// }

func TestGraghNode_GenDotGraph(t *testing.T) {
graphAst, _ := gographviz.ParseString(`digraph G {}`)
Expand All @@ -42,19 +39,20 @@ func TestGraghNode_GenDotGraph(t *testing.T) {
graph = node.GenDotGraph(graph)
graph = AddEdge(graph, 1, 2, "E")
output := graph.String()
file, err := os.Create("./one.png")
if err != nil {
fmt.Printf("err %s\n", err.Error())
}
cmd := exec.Command("dot", "-Tpng")
cmd.Stdin = strings.NewReader(output)
cmd.Stdout = file
cmd.Stderr = os.Stderr
if err := cmd.Start(); err != nil {
panic(err)
}
cmd.Wait()
if err := file.Close(); err != nil {
fmt.Printf("err %s\n", err.Error())
}
fmt.Println(output)
// file, err := os.Create("./one.png")
// if err != nil {
// fmt.Printf("err %s\n", err.Error())
// }
// cmd := exec.Command("dot", "-Tpng")
// cmd.Stdin = strings.NewReader(output)
// cmd.Stdout = file
// cmd.Stderr = os.Stderr
// if err := cmd.Start(); err != nil {
// panic(err)
// }
// cmd.Wait()
// if err := file.Close(); err != nil {
// fmt.Printf("err %s\n", err.Error())
// }
}
4 changes: 2 additions & 2 deletions LALR/LALR_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"testing"

grammar "github.com/acekingke/yaccgo/Grammar"
graph "github.com/acekingke/yaccgo/Graph"
item "github.com/acekingke/yaccgo/Items"
rule "github.com/acekingke/yaccgo/Rules"
symbol "github.com/acekingke/yaccgo/Symbol"
Expand Down Expand Up @@ -372,7 +371,8 @@ func TestLALR1_ambiguity(t *testing.T) {
fmt.Print(err.Error())
} else {
graphInst := lalr.DrawGrammar(tab)
graph.SaveGraph("./grammar.png", graphInst)
//graph.SaveGraph("./grammar.png", graphInst)
fmt.Println(graphInst.String())
fmt.Print("/* ")
for _, sy := range lalr.G.Symbols {
fmt.Printf("%s\t", sy.Name)
Expand Down

0 comments on commit 1687bcc

Please sign in to comment.