Description: Search for gitlab-workhorse binaries also in the environment in PATH variable
Author: Nilesh Patra <npatra974@gmail.com>
Last-Update: 2021-01-26
--- a/workhorse/internal/testhelper/testhelper.go
+++ b/workhorse/internal/testhelper/testhelper.go
@@ -14,6 +14,7 @@
 	"runtime"
 	"syscall"
 	"testing"
+	"os/exec"
 
 	"github.com/dlclark/regexp2"
 	"github.com/golang-jwt/jwt/v5"
@@ -106,8 +107,11 @@
 	rootDir := RootDir()
 
 	for _, exe := range workhorseExecutables {
-		if _, err := os.Stat(path.Join(rootDir, exe)); os.IsNotExist(err) {
-			return fmt.Errorf("cannot find executable %s. Please run 'make prepare-tests'", exe)
+		_, err := exec.LookPath(exe)
+		if err != nil {
+			if _, rootdirerr := os.Stat(path.Join(rootDir, exe)); os.IsNotExist(rootdirerr) {
+				return fmt.Errorf("cannot find executable %s. Please run 'make prepare-tests'", exe)
+			}
 		}
 	}
 
