Skip to content

Commit 1843740

Browse files
committed
fixup! chore: use new language elements
1 parent 1839cf2 commit 1843740

File tree

4 files changed

+9
-22
lines changed

4 files changed

+9
-22
lines changed

test/bench/bench_test.go

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package bench
22

33
import (
44
"bytes"
5-
"context"
65
"errors"
76
"fmt"
87
"go/build"
@@ -55,8 +54,7 @@ func Benchmark_linters(b *testing.B) {
5554

5655
for _, repo := range repos {
5756
b.Run(repo.name, func(b *testing.B) {
58-
// TODO(ldez): clean inside go1.25 PR
59-
_ = exec.CommandContext(context.Background(), binName, "cache", "clean").Run()
57+
_ = exec.CommandContext(b.Context(), binName, "cache", "clean").Run()
6058

6159
b.Chdir(repo.dir)
6260

@@ -77,8 +75,7 @@ func Benchmark_linters(b *testing.B) {
7775
func Benchmark_golangciLint(b *testing.B) {
7876
installGolangCILint(b)
7977

80-
// TODO(ldez): clean inside go1.25 PR
81-
_ = exec.CommandContext(context.Background(), binName, "cache", "clean").Run()
78+
_ = exec.CommandContext(b.Context(), binName, "cache", "clean").Run()
8279

8380
cases := getAllRepositories(b)
8481

@@ -160,8 +157,7 @@ func cloneGithubProject(tb testing.TB, benchRoot, owner, name string) string {
160157
if _, err := os.Stat(dir); os.IsNotExist(err) {
161158
repo := fmt.Sprintf("https://github.com/%s/%s.git", owner, name)
162159

163-
// TODO(ldez): clean inside go1.25 PR
164-
err = exec.CommandContext(context.Background(), "git", "clone", "--depth", "1", "--single-branch", repo, dir).Run()
160+
err = exec.CommandContext(tb.Context(), "git", "clone", "--depth", "1", "--single-branch", repo, dir).Run()
165161
if err != nil {
166162
tb.Fatalf("can't git clone %s/%s: %s", owner, name, err)
167163
}
@@ -194,8 +190,7 @@ func launch(tb testing.TB, run func(testing.TB, string, []string), args []string
194190
func run(tb testing.TB, name string, args []string) {
195191
tb.Helper()
196192

197-
// TODO(ldez): clean inside go1.25 PR
198-
cmd := exec.CommandContext(context.Background(), name, args...)
193+
cmd := exec.CommandContext(tb.Context(), name, args...)
199194
if os.Getenv("PRINT_CMD") == "1" {
200195
log.Print(strings.Join(cmd.Args, " "))
201196
}
@@ -213,8 +208,7 @@ func run(tb testing.TB, name string, args []string) {
213208
func countGoLines(tb testing.TB) int {
214209
tb.Helper()
215210

216-
// TODO(ldez): clean inside go1.25 PR
217-
cmd := exec.CommandContext(context.Background(), "bash", "-c", `find . -type f -name "*.go" | grep -F -v vendor | xargs wc -l | tail -1`)
211+
cmd := exec.CommandContext(tb.Context(), "bash", "-c", `find . -type f -name "*.go" | grep -F -v vendor | xargs wc -l | tail -1`)
218212

219213
out, err := cmd.CombinedOutput()
220214
if err != nil {
@@ -327,8 +321,7 @@ func installGolangCILint(tb testing.TB) {
327321

328322
parentPath := findMakefile(tb)
329323

330-
// TODO(ldez): clean inside go1.25 PR
331-
cmd := exec.CommandContext(context.Background(), "make", "-C", parentPath, "build")
324+
cmd := exec.CommandContext(tb.Context(), "make", "-C", parentPath, "build")
332325

333326
output, err := cmd.CombinedOutput()
334327
if err != nil {

test/testshared/install.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package testshared
22

33
import (
4-
"context"
54
"fmt"
65
"io"
76
"os"
@@ -49,8 +48,7 @@ func InstallGolangciLint(tb testing.TB) string {
4948
defer builtLock.Unlock()
5049

5150
if !built {
52-
// TODO(ldez): clean inside go1.25 PR
53-
cmd := exec.CommandContext(context.Background(), "make", "-C", parentPath, "build")
51+
cmd := exec.CommandContext(tb.Context(), "make", "-C", parentPath, "build")
5452

5553
output, err := cmd.CombinedOutput()
5654
require.NoError(tb, err, "can't install golangci-lint %s", string(output))

test/testshared/integration/fix.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package integration
22

33
import (
4-
"context"
54
"os"
65
"os/exec"
76
"path/filepath"
@@ -31,8 +30,7 @@ func setupTestFix(t *testing.T) []string {
3130

3231
sourcesDir := filepath.Join(testdataDir, "fix")
3332

34-
// TODO(ldez): clean inside go1.25 PR
35-
err := exec.CommandContext(context.Background(), "cp", "-R", sourcesDir, tmpDir).Run()
33+
err := exec.CommandContext(t.Context(), "cp", "-R", sourcesDir, tmpDir).Run()
3634
require.NoError(t, err)
3735

3836
return findSources(t, tmpDir, "in", "*.go")

test/testshared/runner.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package testshared
22

33
import (
4-
"context"
54
"os"
65
"os/exec"
76
"path/filepath"
@@ -264,9 +263,8 @@ func (r *Runner) Command() *exec.Cmd {
264263

265264
runArgs := append([]string{r.command}, r.args...)
266265

267-
// TODO(ldez): clean inside go1.25 PR
268266
//nolint:gosec // we don't use user input here
269-
cmd := exec.CommandContext(context.Background(), r.binPath, runArgs...)
267+
cmd := exec.CommandContext(r.tb.Context(), r.binPath, runArgs...)
270268
cmd.Env = append(os.Environ(), r.env...)
271269

272270
return cmd

0 commit comments

Comments
 (0)