Skip to content

Commit

Permalink
_scripts: fix CI on go1.19/linux/386 (go-delve#3100)
Browse files Browse the repository at this point in the history
Go 1.19 is broken on linux/386 with some C compilers, this is a
workaround for our build script. See:

golang/go#52919

Also fix TestBuild if the first message reported by delve is not the
message that indicates the server is listening.
  • Loading branch information
aarzilli authored Aug 15, 2022
1 parent 20df19e commit 97a7455
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 6 deletions.
10 changes: 7 additions & 3 deletions _scripts/make.go
Original file line number Diff line number Diff line change
Expand Up @@ -445,13 +445,17 @@ func testCmdIntl(testSet, testRegex, testBackend, testBuildMode string) {
buildModeFlag = "-test-buildmode=" + testBuildMode
}

env := []string{}
if os.Getenv("CI") != "" {
env = os.Environ()
}

if len(testPackages) > 3 {
env := []string{}
executeq(env, "go", "test", testFlags(), buildFlags(), testPackages, backendFlag, buildModeFlag)
} else if testRegex != "" {
execute("go", "test", testFlags(), buildFlags(), testPackages, "-run="+testRegex, backendFlag, buildModeFlag)
executeq(env, "go", "test", testFlags(), buildFlags(), testPackages, "-run="+testRegex, backendFlag, buildModeFlag)
} else {
execute("go", "test", testFlags(), buildFlags(), testPackages, backendFlag, buildModeFlag)
executeq(env, "go", "test", testFlags(), buildFlags(), testPackages, backendFlag, buildModeFlag)
}
}

Expand Down
7 changes: 7 additions & 0 deletions _scripts/test_linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ elif [ ${version:4:2} -gt 17 ]; then
export GOFLAGS=-buildvcs=false
fi

if [ "$arch" = "386" ]; then
ver=$(go version)
if [ "$ver" = "go version go1.19 linux/386" ]; then
export CGO_CFLAGS='-g -O0 -fno-stack-protector'
fi
fi

set +e
make test
x=$?
Expand Down
9 changes: 7 additions & 2 deletions cmd/dlv/dlv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,13 @@ func TestBuild(t *testing.T) {

scan := bufio.NewScanner(stderr)
// wait for the debugger to start
scan.Scan()
t.Log(scan.Text())
for scan.Scan() {
text := scan.Text()
t.Log(text)
if strings.Contains(text, "API server pid = ") {
break
}
}
go func() {
for scan.Scan() {
t.Log(scan.Text())
Expand Down
7 changes: 6 additions & 1 deletion pkg/proc/test/support.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ func BuildFixture(name string, flags BuildFlags) Fixture {
}

if flags&EnableCGOOptimization == 0 {
os.Setenv("CGO_CFLAGS", "-O0 -g")
if os.Getenv("CI") == "" || os.Getenv("CGO_CFLAGS") == "" {
os.Setenv("CGO_CFLAGS", "-O0 -g")
}
}

fixturesDir := FindFixturesDir()
Expand Down Expand Up @@ -163,6 +165,9 @@ func BuildFixture(name string, flags BuildFlags) Fixture {

cmd := exec.Command("go", buildFlags...)
cmd.Dir = dir
if os.Getenv("CI") != "" {
cmd.Env = os.Environ()
}

// Build the test binary
if out, err := cmd.CombinedOutput(); err != nil {
Expand Down

0 comments on commit 97a7455

Please sign in to comment.