Test-More / TB2

Test::Builder version 2, the next generation of building testing modules in Perl
Other
1 stars 0 forks source link

Replace TB2::Mouse #70

Open schwernbot opened 10 years ago

schwernbot commented 10 years ago

From: @schwern Date: Wednesday Apr 24, 2013 at 19:43 GMT Orig: https://github.com/Test-More/test-more/issues/376

TB2::Mouse is a copy of Mouse::Tiny with all the package names s{Mouse}{TB2::Mouse} to avoid interfering with Mouse. It was chosen because...

TB2::Mouse allowed TB2 to be much better designed with far more aggressive use of objects and roles than if it had been done in pure Perl.

There are problems...

  1. Test::More is 5-6x slower to load than 0.98.
  2. TB2 roles can only be consumed by TB2::Mouse users exposing our implementation
  3. The core isn't going to be happy about having a copy of Mouse

1 and 2 are major problems. 3 I'm less concerned about, if 1 and 2 can be solved then we can mitigate 3.

Because each .t file is loading Test::More, the extra load time noticeably impacts test performance.

Because any consumers of our roles must write use TB2::Mouse; with "..."; this exposes what OO system we're using and we will never be able to change it. This is an unacceptable exposure of internals. All existing role implementations suffer from this.

Even though it's unacceptable for final release, TB2::Mouse has been left in because it works for now and there are more pressing problems to fix. We're approaching release, so it's time to work on this.

A replacement MUST

A replacement SHOULD

Nice to haves...

The requirements are negotiable.

schwernbot commented 10 years ago

From: @dakkar Date: Wednesday Apr 24, 2013 at 20:25 GMT Orig: https://github.com/Test-More/test-more/issues/376#issuecomment-16962411

I think the "standard" answer nowadays is Moo. It was certainly designed to be compile-time perfomant, "bundle-able" (mostly via fatpacker), and Moose-compatible.

To avoid exposing the internal OO implementation, there's relatively little you can do: how do you add an attribute to a class consuming a TB2 role, without using the same OO system? (IIRC, Moo interoperates with Moose also in that it allows Moose classes/roles to consume Moo roles).

I don't know about changing the namespace, but we may ask.

schwernbot commented 10 years ago

From: @schwern Date: Wednesday Apr 24, 2013 at 21:24 GMT Orig: https://github.com/Test-More/test-more/issues/376#issuecomment-16967113

I've written down the criterion because a lot of people say "you can use X!" Rather than argue for each X, now people can step up and show that X will fix our needs.

Which is to say, if someone wants to take on converting the whole thing to Moo and demonstrate it passes the criterion (or negotiate criterion as unnecessary), let's see it!

mst has been working on a Moo compiler with Test::Builder as a target and has my criterion, but I don't know where that project lives.

Exposing the OO implementation is not an option. I don't want to be stuck in 2023 with an OO system choice I made in 2013. I have ideas about how to fix the role problem by writing an adapter which knows how to talk between the various role implementations. In addition, a role meta protocol could be established so all the role implementations have similar methods for composition. The question of attributes is tricky but IMO surmountable. This is not a requirement I want to have for Test::Builder1.5 but it is unfortunately necessary to protect its future.