Commits

Greg Ward  committed 6d43599

dag: simplify DAG.Dump() output a bit: just use node.String()

  • Participants
  • Parent commits db56ff9

Comments (0)

Files changed (3)

File src/fubsy/dag/dag.go

 func (self *DAG) Dump(writer io.Writer, indent string) {
 	for id, node := range self.nodes {
 		rule := node.BuildRule()
-		desc := node.Name()
-		detail := node.String()
-		if detail != desc {
-			desc += " (" + detail + ")"
-		}
-		fmt.Fprintf(writer, indent+"%04d: %s (%s, state %v)\n",
-			id, desc, node.Typename(), node.State())
+		fmt.Fprintf(writer, indent+"%04d: %s %s (state %v)\n",
+			id, node.Typename(), node, node.State())
 		if rule != nil {
 			fmt.Fprintf(writer, indent+"  action: %s\n", rule.ActionString())
 		}

File src/fubsy/dag/dag_test.go

 	dag.AddManyParents([]Node{node1, node2}, []Node{node3})
 	buf := &bytes.Buffer{}
 	dag.Dump(buf, "")
-	expect := `0000: 0 (StubNode, state UNKNOWN)
+	expect := `0000: StubNode 0 (state UNKNOWN)
   parents:
     0001: 1
     0002: 2
     0003: 3
-0001: 1 (StubNode, state UNKNOWN)
+0001: StubNode 1 (state UNKNOWN)
   parents:
     0003: 3
-0002: 2 (StubNode, state UNKNOWN)
+0002: StubNode 2 (state UNKNOWN)
   parents:
     0003: 3
-0003: 3 (StubNode, state UNKNOWN)
+0003: StubNode 3 (state UNKNOWN)
 `
 	actual := string(buf.Bytes())
-	assert.Equal(t, expect, actual,
-		"expected:\n%s\nbut got:\n%s", expect, actual)
+	if expect != actual {
+		t.Errorf("expected:\n%s\nbut got:\n%s", expect, actual)
+	}
 }
 
 func Test_DAG_MarkSources(t *testing.T) {

File src/fubsy/runtime/runtime_test.go

 	// this seems *awfully* detailed and brittle, but DAG doesn't
 	// provide a good way to query what's in it (yet...)
 	expect := "" +
-		"0000: foo (FileNode, state UNKNOWN)\n" +
+		"0000: FileNode foo (state UNKNOWN)\n" +
 		"  action: cc -o $TARGET $src\n" +
 		"  parents:\n" +
 		"    0001: foo.c\n" +
-		"0001: foo.c (FileNode, state UNKNOWN)\n"
+		"0001: FileNode foo.c (state UNKNOWN)\n"
 	var buf bytes.Buffer
 	rt.dag.Dump(&buf, "")
 	assert.Equal(t, expect, buf.String())