From cefff85a054d64f124aa1f3e91b9425695aa210b Mon Sep 17 00:00:00 2001 From: James O'Doherty Date: Fri, 22 May 2026 10:51:00 -0400 Subject: Update Makefile and README to standardize build/test process and lauch fuzzer --- tests/e2e/test_helpers.go | 42 +++++++++--------------------------------- 1 file changed, 9 insertions(+), 33 deletions(-) (limited to 'tests/e2e/test_helpers.go') diff --git a/tests/e2e/test_helpers.go b/tests/e2e/test_helpers.go index 34aae3f..0ae83aa 100644 --- a/tests/e2e/test_helpers.go +++ b/tests/e2e/test_helpers.go @@ -1,45 +1,21 @@ package e2e import ( + "fmt" "os" - "os/exec" - "path/filepath" - "runtime" ) // GetBinaryPath resolves the path to the wg-wrap binary. -// It checks the current directory, then the project root, then the system PATH. -func GetBinaryPath() string { - binaryName := "wg-wrap" - if runtime.GOOS == "windows" { - binaryName += ".exe" +// It prioritizes the WG_WRAP_BIN environment variable. +func GetBinaryPath() (string, error) { + path := os.Getenv("WG_WRAP_BIN") + if path == "" { + return "", fmt.Errorf("WG_WRAP_BIN environment variable not set") } - // 1. Check current working directory - if _, err := os.Stat(binaryName); err == nil { - abs, _ := filepath.Abs(binaryName) - return abs + if _, err := os.Stat(path); err != nil { + return "", fmt.Errorf("binary not found at path %s: %w", path, err) } - // 2. Check common project root relative paths - // Since go test can be run from root or package dir, we try both. - candidates := []string{ - filepath.Join("..", "..", binaryName), // from tests/e2e - filepath.Join("..", binaryName), // from tests/ - binaryName, // from root - } - for _, c := range candidates { - if _, err := os.Stat(c); err == nil { - abs, _ := filepath.Abs(c) - return abs - } - } - - // 3. Check system PATH - path, err := exec.LookPath(binaryName) - if err == nil { - return path - } - - return binaryName + return path, nil } -- cgit v1.2.3