Allow store_events to be switched on/off after events have been seen #370

merged 8 commits into from May 3, 2013


None yet
1 participant

schwern commented Apr 23, 2013

These patches allow TB2::History->store_events to be turned on and off after events have been seen. Previously once TB2::History had seen an event it would not allow a switch. This was to protect the user from getting only a partial event list.

No longer storing events is turning out to be an incompatibility problem. Most cases can use the TB2::History statistics methods, but a few cases need the event list. This makes it much easier to turn events on. It's now C<< Test::Builder->history->store_events(1) >> rather than having to grab the state object before any events are run.

The Test::Builder docs have been updated to reflect this change, point the user at the statistics methods instead, and show how to turn event storage on.

This satisfies #315. Now that it can be switched on and off later there's no need to add wrapper methods to Test::Builder. I'd rather people got used to working directly with the history object.

schwern added some commits Apr 22, 2013

Patch Mouse to pass the original value to a trigger.
Moose 2.0801 docs say...

           trigger => $code
               The trigger option is a CODE reference which will be called
               after the value of the attribute is set. The CODE ref is passed
               the instance itself, the updated value, and the original value
               if the attribute was already set.

Mouse doesn't pass in the original value.  I've patched our copy and I'll get
it patched upstream.

This will be handle for triggering changes to event storage when
$history->store_events is flipped.
Allow event storage to be turned on and off in the middle of a test.
This makes it much easier for test authors to turn event storage on
and off, otherwise it has to be done before anyone issues an event.

Updated the docs to make it clearer this is done at their own risk,
that events may be lost, and to encourge the statistical methods.

schwern commented Apr 23, 2013

Mouse trigger patch sent upstream. gfx/p5-Mouse#6


schwern commented May 2, 2013

Warnock'd, so I'm just going to merge it.

schwern added some commits May 3, 2013

Merge branch 'Test-Builder1.5' into history/store_events_switch

TB2::Mouse already has our patch.
Reset event_storage when the event_storage_class changes.
This is a good idea on its own.  It also ensures TB2::History::NoEventStorage
gets loaded after a fork.

schwern added a commit that referenced this pull request May 3, 2013

Merge pull request #370 from schwern/history/store_events_switch
Allow store_events to be switched on/off after events have been seen

@schwern schwern merged commit c227244 into Test-Builder1.5 May 3, 2013

@schwern schwern deleted the history/store_events_switch branch May 3, 2013

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