test debugging woes

68 views
Skip to first unread message

tomd...@google.com

unread,
Nov 17, 2017, 1:54:53 AM11/17/17
to golang-nuts
Hello!

I'm debugging a strange test failure, and with the magic of printf debugging (t.Logf) have been adding bits to the test itself to get a sense of what's wrong. The bad bahaviour is happening deep in library code, in a function which returns nil for one of six reasons... I threw some log.Fatalf() statements in that code in my citc to see what breaks, but it's not showing up in the test logs at all.  Probably I'm making bad life decisions; what, go community, am I supposed to be doing here?

Alex Buchanan

unread,
Nov 17, 2017, 11:00:28 AM11/17/17
to golang-nuts
Some ideas:

- I assume the code isn't public? If it is, you might share it
- Are you running `go test -v` for verbose logging?
- Try fmt.Printf
- Try adding printing lines at points down the stack leading up to the point you think is failing, to make sure the code is actually running.
- Put a log line before each return in said function

DV

unread,
Nov 17, 2017, 12:54:32 PM11/17/17
to golang-nuts
I wish I could help you, but your description of the problem could not be more vague. Your post can be rewritten as "problem pls help".

What library is this? Is it on GitHub? Can we look at it? What section of code is returning nil? Is nil the problem? Or is there a panic? What's your code look like? How are you invoking 'go test'? What's a "citc"? That's just some of the questions that sprang into my mind in the first 5 seconds of reading your question.

depa...@redhat.com

unread,
Nov 17, 2017, 1:29:09 PM11/17/17
to golang-nuts
You could try using Delve (https://github.com/derekparker/delve) to actually step through and inspect the process during execution to avoid having to put print statements everywhere. Similar to the Go command, you can run `dlv test` and begin stepping through your test binary.


On Thursday, November 16, 2017 at 10:54:53 PM UTC-8, Tom Denton wrote:
Reply all
Reply to author
Forward
0 new messages