コード例 #1
0
ファイル: build_test.go プロジェクト: sbinet/fubsy
func Test_BuildState_BuildTargets_unsignable_target(t *testing.T) {
	// if we run an action that is supposed to build a target, but the
	// target is unreadable (doesn't exist, permission denied, ...),
	// then the build fails immediately
	snode := dag.NewStubNode("source")
	tnode := NewUnsignableNode("target")
	graph := dag.NewDAG()
	graph.AddNode(snode)
	graph.AddNode(tnode)
	graph.AddParent(tnode, snode)
	executed := addTrackingRules(graph)
	graph.MarkSources()

	sig := []byte{0}
	db := makeFakeDB(graph, sig)
	opts := BuildOptions{}
	bstate := NewBuildState(graph, db, opts)

	// target gets built; the build fails after that, calculating its
	// signature
	goal := graph.MakeNodeSet("target")
	expect := []buildexpect{
		{"target", dag.BUILT},
	}
	err := bstate.BuildTargets(goal)
	assert.Equal(t,
		"could not compute signature of target \"target\": nah", err.Error())
	assertBuild(t, graph, expect, *executed)
}
コード例 #2
0
ファイル: buildrule_test.go プロジェクト: sbinet/fubsy
func Test_BuildRule_setLocals(t *testing.T) {
	targets := []dag.Node{dag.NewStubNode("foo")}
	sources := []dag.Node{dag.NewStubNode("bar"), dag.NewStubNode("qux")}
	ns := types.NewValueMap()
	rule := NewBuildRule(nil, targets, sources)

	rule.setLocals(ns)
	var val types.FuObject
	var ok bool

	val, ok = ns.Lookup("whatever")
	assert.False(t, ok)
	val, ok = ns.Lookup("target")
	assert.False(t, ok)
	val, ok = ns.Lookup("targets")
	assert.False(t, ok)

	val, ok = ns.Lookup("TARGET")
	assert.True(t, ok)
	assert.Equal(t, "foo", val.ValueString())
	assert.Equal(t, "foo", val.(*dag.StubNode).Name())

	val, ok = ns.Lookup("SOURCE")
	assert.True(t, ok)
	assert.Equal(t, "bar", val.ValueString())
	assert.Equal(t, "bar", val.(*dag.StubNode).Name())

	val, ok = ns.Lookup("TARGETS")
	assert.True(t, ok)
	assert.Equal(t, 1, len(val.List()))
	assert.Equal(t, `["foo"]`, val.String())

	val, ok = ns.Lookup("SOURCES")
	assert.True(t, ok)
	assert.Equal(t, 2, len(val.List()))
	assert.Equal(t, `["bar", "qux"]`, val.String())
}