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

Add a config event? #186

Closed
schwern opened this issue Nov 8, 2011 · 0 comments
Closed

Add a config event? #186

schwern opened this issue Nov 8, 2011 · 0 comments

Comments

@schwern
Copy link
Contributor

schwern commented Nov 8, 2011

Currently, Test::Builder configures the TAP formatter directly. Things like whether it should use test numbers, whether it should show the TAP version or the header and so on.

This is dicey for several reasons...

  • The formatter may not be a TAP formatter and it doesn't always check.
  • Some changes are relevant to multiple types of formatters... some are not.
  • It's calling non-standard methods.
  • History and other event watchers do not see these changes which constitute special state changes.

It might make sense to instead have a Config event which contains key/value pairs to be configured.

# Signal not to use test numbers
my $config = Test::Builder2::Event::Config->new( use_test_numbers => 0 );

Each watcher can decide what to do with that information in accept_config. We can build up what various keys and values mean.

In addition, a Config event can contain special instructions for certain types of watchers. For example, this would indicate information only of interest to formatters.

my $config = Test::Builder2::Event::Config->for_class( "Test::Builder2::Formatter" => { use_test_numbers => 0 });

Passing stuff into new is equivalent to calling for_class( "UNIVERSAL" => \%args ).

EventWatchers would ask the Config event for what is of interest to it.

my $args = $config->for_me($self);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant