From cacd57f72b9727767a7638a8fc2875e9b7043a4e Mon Sep 17 00:00:00 2001 From: Marco Molteni Date: Wed, 24 Nov 2021 12:40:55 +0100 Subject: [PATCH] fix ci test breakage (fork/exec ./bin/task: no such file or directory) On Github actions, the destination path of "go install" ($GOPATH/bin) is not in $PATH, thus the error. For the life of me I could not understand how to change the $PATH environment variable in an Actions workflow, so I encode the full path of the just-built task executable in the tests, which probably was the right thing to do since the beginning. --- unix_test.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/unix_test.go b/unix_test.go index b89886a9..7424356d 100644 --- a/unix_test.go +++ b/unix_test.go @@ -1,3 +1,4 @@ +//go:build !windows // +build !windows // This file contains tests for signal handling on Unix. @@ -23,6 +24,10 @@ var ( ) func TestSignalSentToProcessGroup(t *testing.T) { + task, err := filepath.Abs("./bin/task") + if err != nil { + t.Fatal(err) + } testCases := map[string]struct { args []string sendSigs int @@ -32,7 +37,7 @@ func TestSignalSentToProcessGroup(t *testing.T) { // regression: // - child is terminated, immediately, by "context canceled" (another bug???) "child does not handle sigint: receives sigint and terminates immediately": { - args: []string{"task", "--", SLEEPIT, "default", "-sleep=10s"}, + args: []string{task, "--", SLEEPIT, "default", "-sleep=10s"}, sendSigs: 1, want: []string{ "sleepit: ready\n", @@ -51,7 +56,7 @@ func TestSignalSentToProcessGroup(t *testing.T) { // TODO we need -cleanup=2s only to show reliably the bug; once the fix is committed, // we can use -cleanup=50ms to speed the test up "child intercepts sigint: receives sigint and does cleanup": { - args: []string{"task", "--", SLEEPIT, "handle", "-sleep=10s", "-cleanup=2s"}, + args: []string{task, "--", SLEEPIT, "handle", "-sleep=10s", "-cleanup=2s"}, sendSigs: 1, want: []string{ "sleepit: ready\n", @@ -70,7 +75,7 @@ func TestSignalSentToProcessGroup(t *testing.T) { }, // regression: child receives 2 signal instead of 1 and thus terminates abruptly "child simulates terraform: receives 1 sigint and does cleanup": { - args: []string{"task", "--", SLEEPIT, "handle", "-term-after=2", "-sleep=10s", "-cleanup=50ms"}, + args: []string{task, "--", SLEEPIT, "handle", "-term-after=2", "-sleep=10s", "-cleanup=50ms"}, sendSigs: 1, want: []string{ "sleepit: ready\n",