From 7d474db76549cafcf20b519badcfa7c4e2d262f8 Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Sat, 14 May 2022 19:36:15 -0300 Subject: [PATCH] Make signal test work both locally and in CI --- unix_test.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/unix_test.go b/unix_test.go index 7424356d..8dc1bb76 100644 --- a/unix_test.go +++ b/unix_test.go @@ -11,6 +11,7 @@ package task_test import ( "bytes" "errors" + "os" "os/exec" "path/filepath" "strings" @@ -24,10 +25,11 @@ var ( ) func TestSignalSentToProcessGroup(t *testing.T) { - task, err := filepath.Abs("./bin/task") + task, err := getTaskPath() if err != nil { t.Fatal(err) } + testCases := map[string]struct { args []string sendSigs int @@ -191,6 +193,18 @@ func TestSignalSentToProcessGroup(t *testing.T) { } } +func getTaskPath() (string, error) { + if info, err := os.Stat("./bin/task"); err == nil { + return info.Name(), nil + } + + if path, err := exec.LookPath("task"); err == nil { + return path, nil + } + + return "", errors.New("task: \"task\" binary was not found!") +} + // Return the difference of the two lists: the elements that are present in the first // list, but not in the second one. The notion of presence is not with `=` but with // string.Contains(l2, l1).