From bc44989f497254af32d4761fee5f8e9bf2d53735 Mon Sep 17 00:00:00 2001 From: Davide Petilli Date: Fri, 12 Aug 2022 07:47:20 +0200 Subject: [PATCH] mutator: fix resource leakage (#123) There was a resource leakage since we the external management of timeout. Gremlins killed the test process, but not the child processes that remained hanging forever. --- pkg/mutator/mutator.go | 1 + pkg/mutator/mutator_test.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/mutator/mutator.go b/pkg/mutator/mutator.go index 053a8f21..ceaae6c5 100644 --- a/pkg/mutator/mutator.go +++ b/pkg/mutator/mutator.go @@ -298,6 +298,7 @@ func (mu *Mutator) getTestArgs() []string { if mu.buildTags != "" { args = append(args, "-tags", mu.buildTags) } + args = append(args, "-timeout", (1*time.Second + mu.testExecutionTime).String()) args = append(args, "./...") return args diff --git a/pkg/mutator/mutator_test.go b/pkg/mutator/mutator_test.go index 2cb3e947..eddbf2b0 100644 --- a/pkg/mutator/mutator_test.go +++ b/pkg/mutator/mutator_test.go @@ -372,7 +372,7 @@ func TestMutatorRun(t *testing.T) { _ = mut.Run(context.Background()) - want := "go test -tags tag1 tag2 ./..." + want := "go test -tags tag1 tag2 -timeout 21s ./..." got := fmt.Sprintf("go %v", strings.Join(holder.args, " ")) if !cmp.Equal(got, want) {