Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't get godebug test to work on Terraform codebase #80

Open
jzohrab opened this issue Feb 22, 2016 · 0 comments
Open

Can't get godebug test to work on Terraform codebase #80

jzohrab opened this issue Feb 22, 2016 · 0 comments

Comments

@jzohrab
Copy link

jzohrab commented Feb 22, 2016

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 test say godebug test [-godebugwork] [-instrument pkgs...], implying that I needed to add an -instrument terraform as the package is not main. I tried running with and without this extra flag, neither worked.
  • my initial godebug test attempts required me to go get a 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 get the 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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant