Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2022-07-15 15:35:19 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2022-07-20 07:27:55 +0300
commitcead6a0e5f2cf0ac6ad8e32d42d9dce71d424a3f (patch)
treeb97d65b7e3314dee17eddb22910229ffbca684ac
parent3fc66dc23581de48bdbbf1b5a5d5ca9faf5f925b (diff)
command: Fix weird test setup
One of our tests verifies that we can kill commands spawned via our `command` package by cancelling the context. The setup of this test does not make a whole lot of sense though: - We pass an `exec.Cmd` to `New()` that already has an explicit context set by using `CommandContext()`. So even if the `command` package failed to correctly reap the child, the Go runtime would already ensure for us that the command got killed. - We cancel the context in a separate Goroutine without much of a point. Fix these issues by passing a non-contextualized command to `New()` and by cancelling the context synchronously.
-rw-r--r--internal/command/command_test.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/internal/command/command_test.go b/internal/command/command_test.go
index c3c7b85e9..397b32456 100644
--- a/internal/command/command_test.go
+++ b/internal/command/command_test.go
@@ -194,11 +194,11 @@ func TestCommand_Wait_contextCancellationKillsCommand(t *testing.T) {
ctx, cancel := context.WithCancel(testhelper.Context(t))
- cmd, err := New(ctx, exec.CommandContext(ctx, "sleep", "1h"))
+ cmd, err := New(ctx, exec.Command("sleep", "1h"))
require.NoError(t, err)
// Cancel the command early.
- go cancel()
+ cancel()
err = cmd.Wait()
require.Error(t, err)