Adding "AddCleanup" to gocheck

Tim Penhey tim.penhey at canonical.com
Sun Aug 18 22:24:21 UTC 2013


On 17/08/13 02:49, Gustavo Niemeyer wrote:
> Hey Tim,
> 
> On Fri, Aug 16, 2013 at 2:16 AM, Tim Penhey <tim.penhey at canonical.com> wrote:
>> This method seems to create a callback for each test, but it also seems
>> to me that the SetUpTest, TearDownTest, and the test method itself are
>> run with different instances of C, is that right or am I misreading the
>> code?
> 
> IIRC, the instance is the same for these. It's not the same for
> SetUpSuite, though.

Well, as I see it, a test is called with "forkTest", which has a call
back method that takes a *C.

Inside this method, the test setup and tear down are called using:
  runner.runFixtureWithPanic
this calls
  runner.runFixture
which calls
  runner.runFunc
which does the forkCall
which creates a new C for the dispatcher.


>> This is then executed after the TearDownTest, but before the test is
>> marked as completed.  So the place I wanted to add it was to make a
>> defer call just prior to:
> 
> That ordering seems non-intuitive. SetUpTest runs before the test, and
> AddCleanup would run in the test. Why would the cleanup routine run
> *after* the TearDownTest?

I was just looking to emulate the behaviour of the python
implementation.  I've asked lifeless when it runs and why it runs there,
and will pass on info :-)

Tim



More information about the Juju-dev mailing list