mirror of
https://github.com/go-task/task.git
synced 2026-07-07 14:09:11 +00: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 (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -24,10 +25,11 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestSignalSentToProcessGroup(t *testing.T) {
|
func TestSignalSentToProcessGroup(t *testing.T) {
|
||||||
task, err := filepath.Abs("./bin/task")
|
task, err := getTaskPath()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
testCases := map[string]struct {
|
testCases := map[string]struct {
|
||||||
args []string
|
args []string
|
||||||
sendSigs int
|
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
|
// 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
|
// list, but not in the second one. The notion of presence is not with `=` but with
|
||||||
// string.Contains(l2, l1).
|
// string.Contains(l2, l1).
|
||||||
|
|||||||
Reference in New Issue
Block a user