Esempio n. 1
0
func makeFakeDB(graph *dag.DAG, sig []byte) BuildDB {
	var bdb BuildDB = db.NewFakeDB()
	for _, node := range graph.Nodes() {
		record := db.NewBuildRecord()
		record.SetTargetSignature(sig)
		for _, parent := range graph.ParentNodes(node) {
			record.AddParent(parent.Name(), sig)
		}
		bdb.WriteNode(node.Name(), record)
	}
	return bdb
}
Esempio n. 2
0
// add a stub build rule to every target node, so we track when each
// rule's Execute() method is called
func addTrackingRules(graph *dag.DAG) *[]string {
	executed := []string{}
	callback := func(name string) {
		executed = append(executed, name)
	}
	for _, node := range graph.Nodes() {
		if graph.HasParents(node) {
			rule := dag.MakeStubRule(callback, node)
			node.SetBuildRule(rule)
		}
	}
	// need to return a pointer to the executed slice because
	// callback() modifies the slice
	return &executed
}
Esempio n. 3
0
func assertBuild(
	t *testing.T,
	graph *dag.DAG,
	expect []buildexpect,
	executed []string) {

	actual := make([]buildexpect, len(executed))
	for i, name := range executed {
		state := graph.Lookup(name).State()
		actual[i] = buildexpect{name, state}
	}

	if len(expect) != len(actual) {
		t.Errorf("expected %d build attempts, but got %d\n"+
			"expect: %v\n"+
			"actual: %v",
			len(expect), len(actual), expect, actual)
		return
	}
	for i := range expect {
		assert.Equal(t, expect[i], actual[i])
	}
}
Esempio n. 4
0
func setNodeSigs(graph *dag.DAG, sig []byte) {
	for _, node := range graph.Nodes() {
		node.(*dag.StubNode).SetSignature(sig)
	}
}
Esempio n. 5
0
func setNodeExists(graph *dag.DAG, exists bool) {
	for _, node := range graph.Nodes() {
		node.(*dag.StubNode).SetExists(exists)
	}
}