Make signal test work both locally and in CI
This commit is contained in:
parent
367c0b38a6
commit
7d474db765
1 changed files with 15 additions and 1 deletions
16
unix_test.go
16
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).
|
||||
|
|
|
|||
Loading…
Reference in a new issue