Can't get `godebug test` to work on Terraform codebase
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 2.5k
- Forks
- 102
- PR merge metrics
- No merged PRs in 30d
Description
Hello, I can't figure out how to run godebug test with https://github.com/hashicorp/terraform, what appears to me to be a non-trivial Go codebase. I'm not sure if I'm misusing godebug, or if this is a current limitation of the project.
I'm new to Go and would like to contribute a feature to Terraform that will require rather deep understanding of the code, so tracing through tests seemed like a good start. I added _ = "breakpoint to terraform/context_plan_test.go and attempted to run godebug test, but that didn't work.
Some initial notes:
- the docs and
godebug help testsaygodebug test [-godebugwork] [-instrument pkgs...], implying that I needed to add an-instrument terraformas the package is notmain. I tried running with and without this extra flag, neither worked. - my initial godebug test attempts required me to
go geta bunch of packages - sorry can't reproduce that for you just yet without blowing everything away and retrying (which I can do if needed)
Here is what I've tried:
- plain godebug test: breakpoint not used
~/Documents/Projects/go/src/github.com/hashicorp/terraform$ godebug test
PASS
- instrument with short path: fails
~/Documents/Projects/go/src/github.com/hashicorp/terraform$ godebug test -instrument terraform
cannot find package "terraform" in any of:
/Users/jzohrab/Documents/Projects/go/src/github.com/hashicorp/terraform/vendor/terraform (vendor tree)
/usr/local/go/src/terraform (from $GOROOT)
/Users/jzohrab/Documents/Projects/go/src/terraform (from $GOPATH)
- instrument with full path: fails missing packages
~/Documents/Projects/go/src/github.com/hashicorp/terraform $godebug test -instrument github.com/hashicorp/terraform/terraform
/var/folders/5m/2_dhdx4x5z94fb0zqgt32w5mph99p1/T/godebug033311833/src/github.com/hashicorp/terraform/terraform/eval_variable.go:6:2: cannot find package "github.com/hashicorp/errwrap" in any of:
/usr/local/go/src/github.com/hashicorp/errwrap (from $GOROOT)
/var/folders/5m/2_dhdx4x5z94fb0zqgt32w5mph99p1/T/godebug033311833/src/github.com/hashicorp/errwrap (from $GOPATH)
/Users/jzohrab/Documents/Projects/go/src/github.com/hashicorp/errwrap
/var/folders/5m/2_dhdx4x5z94fb0zqgt32w5mph99p1/T/godebug033311833/src/github.com/hashicorp/terraform/terraform/context.go:11:2: cannot find package "github.com/hashicorp/go-multierror" in any of:
/usr/local/go/src/github.com/hashicorp/go-multierror (from $GOROOT)
/var/folders/5m/2_dhdx4x5z94fb0zqgt32w5mph99p1/T/godebug033311833/src/github.com/hashicorp/go-multierror (from $GOPATH)
/Users/jzohrab/Documents/Projects/go/src/github.com/hashicorp/go-multierror
/var/folders/5m/2_dhdx4x5z94fb0zqgt32w5mph99p1/T/godebug033311833/src/github.com/hashicorp/terraform/terraform/interpolate.go:12:2: cannot find package "github.com/hashicorp/hil/ast" in any of:
/usr/local/go/src/github.com/hashicorp/hil/ast (from $GOROOT)
/var/folders/5m/2_dhdx4x5z94fb0zqgt32w5mph99p1/T/godebug033311833/src/github.com/hashicorp/hil/ast (from $GOPATH)
/Users/jzohrab/Documents/Projects/go/src/github.com/hashicorp/hil/ast
/var/folders/5m/2_dhdx4x5z94fb0zqgt32w5mph99p1/T/godebug033311833/src/github.com/hashicorp/terraform/terraform/eval_variable.go:8:2: cannot find package "github.com/mitchellh/mapstructure" in any of:
/usr/local/go/src/github.com/mitchellh/mapstructure (from $GOROOT)
/var/folders/5m/2_dhdx4x5z94fb0zqgt32w5mph99p1/T/godebug033311833/src/github.com/mitchellh/mapstructure (from $GOPATH)
/Users/jzohrab/Documents/Projects/go/src/github.com/mitchellh/mapstructure
go getthe failing packages and retry instrument with full path: fails with many errors deep in the code
go get github.com/hashicorp/errwrap
go get github.com/hashicorp/go-multierror
go get github.com/hashicorp/hil/ast
go get github.com/mitchellh/mapstructure
~/Documents/Projects/go/src/github.com/hashicorp/terraform $godebug test -instrument github.com/hashicorp/terraform/terraform
[start of many errors]
open /usr/local/go/src/runtime/chan.go: too many open files
open /usr/local/go/src/runtime/compiler.go: too many open files
open /usr/local/go/src/runtime/complex.go: too many open files
open /usr/local/go/src/runtime/cpuprof.go: too many open files
... [snip] ...
/usr/local/go/src/runtime/signal1_unix.go:117:8: undeclared name: sigtable
/usr/local/go/src/runtime/signal1_unix.go:118:13: undeclared name: _SigNotify
/usr/local/go/src/runtime/signal1_unix.go:122:14: undeclared name: _SigHandling
/usr/local/go/src/runtime/signal1_unix.go:123:15: undeclared name: _SigHandling
... [snip] ...
couldn't load packages due to errors: github.com/hashicorp/terraform/plugin, runtime/trace, runtime/pprof and 33 more
Re the -instrument flag and packages: I read the godebug docs and created a toy project (https://github.com/jzohrab/godebugissue) to try out godebug on a project with different directories and packages, following what I could grok from Terraform code layout. My test debugging for this toy project worked with plain godebug test, even though the test itself was in the subdir package. Maybe I'm misreading the docs -- does the use of the -instrument flag need further notes, or have I missed something obvious? (I'm new to Go, so that's possible).
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the godebug test documentation and godebug help test, then reproduce the commands against Terraform using terraform/context_plan_test.go. Compare the results with the linked toy project and investigate the dependency, package, and open-file errors. Done means establishing whether this is a godebug limitation or misuse and documenting or fixing the supported behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100