Skip to content

"garble test" doesn't work with reflection #966

@huibeu

Description

@huibeu

Output of garble version:

mvdan.cc/garble v0.14.2

Build settings:
      -buildmode exe
       -compiler gc
  DefaultGODEBUG gotestjsonbuildtext=1,multipathtcp=0,randseednop=0,rsa1024min=0,tlsmlkem=0,x509rsacrt=0,x509usepolicies=0
     CGO_ENABLED 1
          GOARCH amd64
            GOOS linux
         GOAMD64 v1

Output of go env in your module/workspace:

AR='ar'
CC='gcc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='g++'
GCCGO='gccgo'
GO111MODULE=''
GOAMD64='v1'
GOARCH='amd64'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/root/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/root/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build1753113114=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/dev/null'
GOMODCACHE='/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/root/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='local'
GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.24.5'
GOWORK=''
PKG_CONFIG='pkg-config'

What did you do?

go test gives errors, even when running tests on the std packages.

# This works
go test reflect
go test encoding/xml
go test encoding/json

# This gives failing tests and build errors
garble test reflect
garble test encoding/xml
garble test encoding/json

I did not see any issues when running code with garble run or garble build.

What did you see happen?

garble test reflect

# reflect.test
list flag: not found
FAIL	reflect [build failed]
FAIL
exit status 1

garble test encoding/xml

--- FAIL: TestMarshal (0.00s)
    --- FAIL: TestMarshal/2 (0.00s)
        ozLy15Wlr.go:1: marshal(&bvuKzfAhE4.Jp9cjKXs{MmON2eeJ:true}):
            have `<Jp9cjKXs><MmON2eeJ>true</MmON2eeJ></Jp9cjKXs>`
            want `<Plain><V>true</V></Plain>`
[...]
FAIL
FAIL	encoding/xml	3.234s
FAIL
exit status 1

garble test encoding/json

# encoding/json.test
list internal/fuzz: not found
FAIL	encoding/json [build failed]
FAIL
exit status 1

What did you expect to see?

I expected the output to look similar to running the tests with go test:

$ go test reflect
ok  	reflect	0.279s
$ go test encoding/xml
ok  	encoding/xml	3.360s
$ go test encoding/json
ok  	encoding/json	0.378s

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions