@@ -4,13 +4,36 @@ import (
4
4
"context"
5
5
"os"
6
6
"os/exec"
7
+ "path/filepath"
7
8
"strings"
8
9
"testing"
9
10
"time"
10
11
11
12
"github.com/stretchr/testify/require"
12
13
)
13
14
15
+ // findProjectRoot finds the project root by looking for go.mod file
16
+ func findProjectRoot (t * testing.T ) string {
17
+ cwd , err := os .Getwd ()
18
+ require .NoError (t , err , "Failed to get current working directory" )
19
+
20
+ // Start from current directory and walk up until we find go.mod
21
+ dir := cwd
22
+ for {
23
+ goModPath := filepath .Join (dir , "go.mod" )
24
+ if _ , err := os .Stat (goModPath ); err == nil {
25
+ return dir
26
+ }
27
+
28
+ parent := filepath .Dir (dir )
29
+ if parent == dir {
30
+ // Reached filesystem root
31
+ t .Fatalf ("Could not find go.mod file starting from %s" , cwd )
32
+ }
33
+ dir = parent
34
+ }
35
+ }
36
+
14
37
// getNamespaceName gets the single network namespace name
15
38
// Fails if there are 0 or multiple namespaces
16
39
func getNamespaceName (t * testing.T ) string {
@@ -37,9 +60,12 @@ func getNamespaceName(t *testing.T) string {
37
60
}
38
61
39
62
func TestBoundaryIntegration (t * testing.T ) {
63
+ // Find project root by looking for go.mod file
64
+ projectRoot := findProjectRoot (t )
65
+
40
66
// Build the boundary binary
41
67
buildCmd := exec .Command ("go" , "build" , "-o" , "/tmp/boundary-test" , "./cmd/..." )
42
- buildCmd .Dir = "/home/coder/boundary"
68
+ buildCmd .Dir = projectRoot
43
69
err := buildCmd .Run ()
44
70
require .NoError (t , err , "Failed to build boundary binary" )
45
71
0 commit comments