From db4fa48f66bfbe40984412d49d4e49a0fe1e5f8f Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Thu, 11 May 2017 22:40:50 +0200 Subject: [PATCH] rest: Add context --- src/restic/backend/rest/rest_test.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/restic/backend/rest/rest_test.go b/src/restic/backend/rest/rest_test.go index d88c71e2b..8ccbca3fc 100644 --- a/src/restic/backend/rest/rest_test.go +++ b/src/restic/backend/rest/rest_test.go @@ -2,6 +2,7 @@ package rest_test import ( "bufio" + "context" "io/ioutil" "net/url" "os" @@ -15,13 +16,13 @@ import ( . "restic/test" ) -func runRESTServer(t testing.TB, dir string) func() { +func runRESTServer(ctx context.Context, t testing.TB, dir string) func() { srv, err := exec.LookPath("rest-server") if err != nil { t.Skip(err) } - cmd := exec.Command(srv, "--path", dir) + cmd := exec.CommandContext(ctx, srv, "--path", dir) cmd.Stdout = os.Stdout stderr, err := cmd.StderrPipe() if err != nil { @@ -50,10 +51,13 @@ func runRESTServer(t testing.TB, dir string) func() { } func TestBackend(t *testing.T) { + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + dir, cleanup := TempDir(t) defer cleanup() - cleanup = runRESTServer(t, dir) + cleanup = runRESTServer(ctx, t, dir) defer cleanup() suite := test.Suite{