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

Add debugging to tests and single file configuration #2345

Closed
wants to merge 1 commit into from
Closed

Add debugging to tests and single file configuration #2345

wants to merge 1 commit into from

Conversation

dlsniper
Copy link
Member

Fixes #1855

@zolotov
Copy link
Contributor

zolotov commented Feb 16, 2016

In the PR you rely on delve for building sources. That's why derekparker/delve#423 is blocker for you. Instead of that it's better to separate building and running/debugging binary file logic. In this case delve will have nothing to do with building and we will be able change building-logic in any way we want.

@dlsniper
Copy link
Member Author

You are right. I'll update this accordingly.

@dlsniper
Copy link
Member Author

Note for self: test flags for running a binary are sent with their prefix (-test.run instead of simply -run) but this could be unified regardless of debug mode or not to simplify the process so that regardless of go test or dlv exec <binary> -- we send the same parameters.

@zolotov
Copy link
Contributor

zolotov commented Feb 16, 2016

@dlsniper yep, this is exactly how I see it. The only hard issue here is preprocessing arguments. Note that all following arguments are needed to be processed (not only run): https://github.com/golang/go/blob/master/src/cmd/go/test.go#L126

@dlsniper
Copy link
Member Author

Hi, I'm close to finishing this but I need some help.
Debugging a single file run works, so does the application (as it used to). However the issue is when running the tests under debugging.

The logs:

2016-03-24 23:08:54,248 [ 336834]   INFO -           #com.goide.dlv.DlvVm - OUT: {"method":"RPCServer.CreateBreakpoint","params":[{"file":"/home/florin/golang/src/github.com/dlsniper/u/tmp/mypack/dem_test.go","line":8}],"id":1} 
2016-03-24 23:08:54,248 [ 336834]   INFO -           #com.goide.dlv.DlvVm - OUT: {"method":"RPCServer.Command","params":[{"Name":"continue"}],"id":2} 
2016-03-24 23:08:54,249 [ 336835]   INFO -           #com.goide.dlv.DlvVm - IN: {"id":1,"result":{"id":1,"name":"","addr":4709431,"file":"/home/florin/golang/src/github.com/dlsniper/u/tmp/mypack/dem_test.go","line":8,"functionName":"github.com/dlsniper/u/tmp/mypack_test.TestDemo","Cond":"","continue":false,"stacktrace":0,"goroutine":false,"hitCount":{},"totalHitCount":0},"error":null} 
2016-03-24 23:08:54,253 [ 336839]   INFO -           #com.goide.dlv.DlvVm - IN: {"id":2,"result":{"Threads":null,"exited":true,"exitStatus":0},"error":null} 
2016-03-24 23:08:54,255 [ 336841]   INFO -           #com.goide.dlv.DlvVm - OUT: {"method":"RPCServer.Detach","params":[true],"id":3} 
2016-03-24 23:08:54,267 [ 336853]   INFO -           #com.goide.dlv.DlvVm - IN: {"id":3,"result":0,"error":null} 
2016-03-24 23:08:54,323 [ 336909]   INFO - #com.goide.dlv.DlvDebugProcess - Connection closed 
org.jetbrains.concurrency.Promise$MessageError: Connection closed

and the output:

/usr/local/go1.6/bin/go test -o "/tmp/TestDemo in dem_test.go1go" -c -gcflags "-N -l" github.com/dlsniper/u/tmp/mypack
/home/florin/IdeaProjects/google-go-lang-idea-plugin/build/idea-sandbox/plugins/Go/lib/dlv/linux/dlv --listen=localhost:41587 --headless=true exec "/tmp/TestDemo in dem_test.go1go" -- -test.v -test.run='^TestDemo$'
Testing started at 23:08 ...
PASS

which is flagged as: Test framework quit unexpectedly.

When running the the following commands:

/usr/local/go1.6/bin/go test -o "/tmp/TestDemo in dem_test.gogo" -c -gcflags "-N -l" github.com/dlsniper/u/tmp/mypack
/home/florin/IdeaProjects/google-go-lang-idea-plugin/build/idea-sandbox/plugins/Go/lib/dlv/linux/dlv exec "/tmp/TestDemo in dem_test.gogo" -- -test.v -test.run='^TestDemo$'

with the output:

=== RUN   TestDemo
--- PASS: TestDemo (0.00s)
PASS
Process 16919 has exited with status 0

and setting the breakpoint on the line correctly that works as expected and the debugger stops. So does running the tests without the debugger:

/usr/local/go1.6/bin/go test -o "/tmp/TestDemo in dem_test.gogo" -c -gcflags "-N -l" github.com/dlsniper/u/tmp/mypack
"/tmp/TestDemo in dem_test.gogo" -test.v -test.run='^TestDemo$'

Which has the output:

=== RUN   TestDemo
--- PASS: TestDemo (0.00s)
PASS

Can you please have a look on this? Thank you!

@zolotov
Copy link
Contributor

zolotov commented Mar 25, 2016

Please do not try to implement everything in a single PR, it would take forever until it would be fully reviewed/reworked until merge.
First of all make test run configurations work via building runner with proper separation tool/test parameters. Enabling debugging for tests and reimplementing run file configuration extract into separate PRs. Thanks.

@dlsniper
Copy link
Member Author

Understood. One question. Since I'm reworking this whole run configuration part, would it be also ok if at the end of the process we remove the the separate Go Single File configuration and merge the functionality into the Go Application configuration? I'll submit the first PR to run tests via GoBuildingRunner soon. Thank you.

@dlsniper dlsniper closed this Mar 25, 2016
@dlsniper dlsniper deleted the run-dlv-tests branch March 25, 2016 12:38
@zolotov
Copy link
Contributor

zolotov commented Mar 25, 2016

Since I'm reworking this whole run configuration part, would it be also ok if at the end of the process we remove the the separate Go Single File configuration and merge the functionality into the Go Application configuration?

Sure, I think it's logical continuation of this issue, as well as adding multi-file run configuration

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

Successfully merging this pull request may close these issues.

2 participants