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

testing: panic during Example function omits stack trace #2691

Closed
gopherbot opened this issue Jan 12, 2012 · 5 comments
Closed

testing: panic during Example function omits stack trace #2691

gopherbot opened this issue Jan 12, 2012 · 5 comments
Milestone

Comments

@gopherbot
Copy link

@gopherbot gopherbot commented Jan 12, 2012

by raul.san@sent.com:

The exampe functions are masking the errors.

===
import "testing"
import "fmt"

func TestNone(t *testing.T) {}

func Example_ff() {
        var a map[int][]string
        a[1][10] = "foo"

        fmt.Println(a[1])
}

===
$ gotest
PASS

8c6f3122826c+ tip (last weekly)
Ubuntu 11.10, AMD64 


Related to
http://groups.google.com/group/golang-nuts/browse_thread/thread/6f43e7b5a7c82251
@rsc

This comment has been minimized.

Copy link
Contributor

@rsc rsc commented Jan 12, 2012

Comment 1:

What you have written is correct behavior:
a test that does not call t.Error or t.Fatal is a
passing test, so TestNone is a passing test.
You have no output comment in the example to check
against, so the example just needs to build, not run.
So everything here is okay, so the test should print PASS.
Did you have something else in mind?

Status changed to WaitingForReply.

@gopherbot

This comment has been minimized.

Copy link
Author

@gopherbot gopherbot commented Jan 12, 2012

Comment 2 by raul.san@sent.com:

I added TestNone for that it does not show the warning (due to don't use a test
function). Sorry! Now, the next one is more clear:
===
import "testing"
import "fmt"
// nothing
func Example_ff() {
        var a map[int][]string
        a[1][10] = "foo"
        fmt.Println(a[1])
}
===
$ gotest
testing: warning: no tests to run
--- FAIL: Example_ff
panic: runtime error: index out of range
gotest: "./6.out" failed: exit status 1
* * *
===
import "testing"
import "fmt"
// nothing
func TestConst(t *testing.T) {
        var a map[int][]string
        a[1][10] = "foo"
        fmt.Println(a[1])
}
===
$ gotest
panic: runtime error: index out of range
goroutine 2 [running]:
github.com/kless/GoJscript/gojs.TestConst()
    /home/neo/Pub/Projects/Go/GoJscript/gojs/gojs_test.go:27 +0x63
testing.tRunner(0xf840000c40, 0x590fe0, 0x0, 0x0)
    /var/tmp/go/src/pkg/testing/testing.go:198 +0x41
created by testing.RunTests
    /var/tmp/go/src/pkg/testing/testing.go:275 +0x772
goroutine 1 [chan receive]:
testing.RunTests(0x400c00, 0x590fe0, 0x100000001, 0xf84002cc01, 0x40673f, ...)
    /var/tmp/go/src/pkg/testing/testing.go:276 +0x795
testing.Main(0x400c00, 0x590fe0, 0x100000001, 0x59eda8, 0x0, ...)
    /var/tmp/go/src/pkg/testing/testing.go:211 +0x62
main.main()
    /home/neo/Pub/Projects/Go/GoJscript/gojs/_testmain.go:29 +0x91
gotest: "./6.out" failed: exit status 2
* * * 
Note: that the example functions doesn't show all error message (the stack) like is done
with the test functions
@rsc

This comment has been minimized.

Copy link
Contributor

@rsc rsc commented Jan 12, 2012

Comment 3:

Labels changed: added priority-go1, removed priority-triage.

Owner changed to @adg.

Status changed to Accepted.

@robpike

This comment has been minimized.

Copy link
Contributor

@robpike robpike commented Jan 13, 2012

Comment 4:

Owner changed to builder@golang.org.

@robpike

This comment has been minimized.

Copy link
Contributor

@robpike robpike commented Jan 19, 2012

Comment 5:

This issue was closed by revision d888ab8.

Status changed to Fixed.

@rsc rsc added this to the Go1 milestone Apr 10, 2015
@rsc rsc removed the priority-go1 label Apr 10, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.