mirror of
https://github.com/go-task/task.git
synced 2025-09-16 09:26:16 +02:00
Make signal test work both locally and in CI
This commit is contained in:
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).
|
||||
|
Reference in New Issue
Block a user