diff --git a/distbuild/disttest/single_worker_test.go b/distbuild/disttest/single_worker_test.go index 0c2b1e2..9fe5ae5 100644 --- a/distbuild/disttest/single_worker_test.go +++ b/distbuild/disttest/single_worker_test.go @@ -1,6 +1,7 @@ package disttest import ( + "fmt" "io/ioutil" "testing" @@ -69,8 +70,8 @@ func TestJobCaching(t *testing.T) { var sourceFilesGraph = build.Graph{ SourceFiles: map[build.ID]string{ - build.ID{'a'}: "a.txt", - build.ID{'c'}: "b/c.txt", + {'a'}: "a.txt", + {'c'}: "b/c.txt", }, Jobs: []build.Job{ { @@ -98,3 +99,34 @@ func TestSourceFiles(t *testing.T) { assert.Len(t, recorder.Jobs, 1) assert.Equal(t, &JobResult{Stdout: "foo", Stderr: "bar", Code: new(int)}, recorder.Jobs[build.ID{'a'}]) } + +var artifactTransferGraph = build.Graph{ + Jobs: []build.Job{ + { + ID: build.ID{'a'}, + Name: "write", + Cmds: []build.Cmd{ + {CatTemplate: "OK", CatOutput: "{{.OutputDir}}/out.txt"}, + }, + }, + { + ID: build.ID{'b'}, + Name: "cat", + Cmds: []build.Cmd{ + {Exec: []string{"cat", fmt.Sprintf("{{index .Deps %q}}/out.txt", build.ID{'a'})}}, + }, + Deps: []build.ID{{'a'}}, + }, + }, +} + +func TestArtifactTransfer(t *testing.T) { + env, cancel := newEnv(t) + defer cancel() + + recorder := NewRecorder() + require.NoError(t, env.Client.Build(env.Ctx, artifactTransferGraph, recorder)) + + assert.Len(t, recorder.Jobs, 2) + assert.Equal(t, &JobResult{Stdout: "OK", Code: new(int)}, recorder.Jobs[build.ID{'b'}]) +} diff --git a/distbuild/pkg/worker/worker.go b/distbuild/pkg/worker/worker.go index 91a5c9b..cde1d9b 100644 --- a/distbuild/pkg/worker/worker.go +++ b/distbuild/pkg/worker/worker.go @@ -119,7 +119,7 @@ func (w *Worker) Run(ctx context.Context) error { for _, spec := range rsp.JobsToRun { result, err := w.runJob(ctx, &spec) if err != nil { - errStr := err.Error() + errStr := fmt.Sprintf("job %s failed: %v", spec.Job.ID, err) w.jobFinished(&proto.JobResult{ID: spec.Job.ID, Error: &errStr}) continue }