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 }
// all targets exist, but the BuildDB is empty: rebuild everything // because we have no way of knowing what changed func Test_BuildState_BuildTargets_empty_db(t *testing.T) { sig := []byte{0} graph, executed := setupBuild(true, sig) bdb := db.NewFakeDB() expect := []buildexpect{ {"tool1.o", dag.BUILT}, {"misc.o", dag.BUILT}, {"util.o", dag.BUILT}, {"tool1", dag.BUILT}, {"tool2.o", dag.BUILT}, {"tool2", dag.BUILT}, } bstate := NewBuildState(graph, bdb, BuildOptions{}) goal := graph.MakeNodeSet("tool1", "tool2") err := bstate.BuildTargets(goal) assert.Nil(t, err) assertBuild(t, graph, expect, *executed) }
func openBuildDB() (build.BuildDB, error) { var bdb build.BuildDB var err error err = os.MkdirAll(".fubsy", 0755) if err != nil { return nil, err } bdb, err = db.OpenKyotoDB(".fubsy/buildstate.kch", true) if _, ok := err.(db.NotAvailableError); ok { bdb = db.NewFakeDB() err = nil log.Warning( "no database libraries available; build state will not be saved") } else if err != nil { return nil, err } return bdb, nil }