Skip to content

Commit d75d448

Browse files
findleyrgopherbot
authored andcommitted
internal/task: ensure go is in PATH when generating telemetry config
This changed caused a test failure due to use of ExecOpts.Path with the fake buildlet. Turn off that check to get the test passing, leaving a TODO to implement proper Path support. Also, restrict TestTagTelemetry to builders that actually have shell scripting support. Change-Id: Ic9ffbc8979b468d0338fb46ec26696c014a26fb0 Reviewed-on: https://go-review.googlesource.com/c/build/+/522897 Reviewed-by: Heschi Kreinick <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Run-TryBot: Robert Findley <[email protected]> Auto-Submit: Robert Findley <[email protected]>
1 parent 4999efa commit d75d448

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

internal/task/fakes.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,10 @@ func (b *fakeBuildlet) Close() error {
181181
}
182182

183183
func (b *fakeBuildlet) Exec(ctx context.Context, cmd string, opts buildlet.ExecOpts) (remoteErr error, execErr error) {
184-
if opts.Path != nil {
185-
return nil, fmt.Errorf("opts.Path option is set, but fakeBuildlet doesn't support it")
186-
} else if opts.OnStartExec != nil {
184+
// TODO: add support for opts.Path. Previously, setting opts.Path would cause
185+
// an error here, but that caused unnecessary failures in tests that use mock
186+
// execution.
187+
if opts.OnStartExec != nil {
187188
return nil, fmt.Errorf("opts.OnStartExec option is set, but fakeBuildlet doesn't support it")
188189
}
189190
b.logf("exec %v %v\n\twd %q env %v", cmd, opts.Args, opts.Dir, opts.ExtraEnv)

internal/task/tagtelemetry.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,11 @@ func (t *TagTelemetryTasks) GenerateConfig(ctx *wf.TaskContext, reviewers []stri
9292

9393
logWriter := &LogWriter{Logger: ctx}
9494
go logWriter.Run(ctx)
95-
remoteErr, execErr := bc.Exec(ctx, "go/bin/go", buildlet.ExecOpts{
95+
remoteErr, execErr := bc.Exec(ctx, "./go/bin/go", buildlet.ExecOpts{
9696
Dir: "telemetry",
9797
Args: []string{"run", "./internal/configgen", "-w"},
9898
Output: logWriter,
99+
Path: []string{"$WORKDIR/go/bin", "$PATH"},
99100
ExtraEnv: []string{"GO_DISABLE_OUTBOUND_NETWORK=0"},
100101
})
101102
if execErr != nil {

internal/task/tagtelemetry_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import (
1616
)
1717

1818
func TestTagTelemetry(t *testing.T) {
19+
mustHaveShell(t)
20+
1921
tests := []struct {
2022
label string
2123
tags []string

internal/task/tagx_test.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -344,10 +344,16 @@ type tagXTestDeps struct {
344344
tagXTasks *TagXReposTasks
345345
}
346346

347-
func newTagXTestDeps(t *testing.T, dashboardStatus string, repos ...*FakeRepo) *tagXTestDeps {
347+
// mustHaveShell skips if the current environment doesn't support shell
348+
// scripting (/bin/bash).
349+
func mustHaveShell(t *testing.T) {
348350
if runtime.GOOS != "linux" && runtime.GOOS != "darwin" {
349351
t.Skip("Requires bash shell scripting support.")
350352
}
353+
}
354+
355+
func newTagXTestDeps(t *testing.T, dashboardStatus string, repos ...*FakeRepo) *tagXTestDeps {
356+
mustHaveShell(t)
351357

352358
ctx, cancel := context.WithCancel(context.Background())
353359
t.Cleanup(cancel)

0 commit comments

Comments
 (0)