panic in TearDownTest obscures original test panic

Bug #1228105 reported by Roger Peppe
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
gocheck
New
Undecided
Unassigned

Bug Description

I just had a test where something in the test was panicking
and that had the consequence of causing TearDownTest
to panic.

Unfortunately the original panic message or stack trace is never printed
in this case, making the problem hard to diagnose.

Here is a standalone test file that demonstrates the issue:

 package test_test

 import (
  gc "launchpad.net/gocheck"
  "testing"
 )

 func TestPackage(t *testing.T) {
  gc.TestingT(t)
 }

 var _ = gc.Suite(suite{})

 type suite struct{}

 func (suite) TearDownTest(c *gc.C) {
  c.Logf("tear down test")
  panic("panic in TearDownTest")
 }

 func (suite) TestFoo(c *gc.C) {
  c.Logf("testing Foo")
  panic("panic in TestFoo")
 }

This produces this output:

 ----------------------------------------------------------------------
 PANIC: tst_test.go:16: suite.TearDownTest

 tear down test
 ... Panic: panic in TearDownTest (PC=0x413776)

 /home/rog/go/src/pkg/runtime/panic.c:248
   in panic
 tst_test.go:18
   in suite.TearDownTest
 tst_test.go:1
   in suite.TearDownTest.i
 /home/rog/go/src/pkg/runtime/asm_amd64.s:338
   in call16

 ----------------------------------------------------------------------
 PANIC: tst_test.go:21: suite.TestFoo

 testing Foo
 ... Panic: Fixture has panicked (see related PANIC)
 OOPS: 0 passed, 1 FIXTURE-PANICKED, 1 MISSED
 --- FAIL: TestPackage (0.00 seconds)
 FAIL
 FAIL command-line-arguments 0.002s
 go: exit 1

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.