Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Sub::Attribute is now required and not optional.

  • Loading branch information...
commit 3a23f877af7d0228175aeb5c7c40beb61cf5c18f 1 parent 9ae848f
@Ovid Ovid authored
View
3  Changes
@@ -1,5 +1,8 @@
Revision history for Perl distribution Test-Class-Moose
+0.51
+ - Sub::Attribute is now required and not optional.
+
0.50 2013-03-14
- :Test and :Tests attributes have been added.
- TAP::Stream is now in its own distribution and thus removed from
View
38 lib/Test/Class/Moose.pm
@@ -9,6 +9,7 @@ use Carp;
use List::Util qw(shuffle);
use List::MoreUtils qw(uniq);
use namespace::autoclean;
+use Sub::Attribute;
use Test::Builder;
use Test::Most;
@@ -20,6 +21,11 @@ use Test::Class::Moose::Report::Method;
use Test::Class::Moose::AttributeRegistry;
sub __create_attributes {
+
+ # XXX sharing this behavior here because my first attempt at creating a
+ # role was a complete failure. MooseX::MethodAttributes can help here, but
+ # I have to parse the attributes manually (as far as I can tell) and I
+ # don't have the simple declarative style any more.
return <<'DECLARE_ATTRIBUTES';
sub Tags : ATTR_SUB {
my ( $class, $symbol, undef, undef, $data, undef, $file, $line ) = @_;
@@ -54,7 +60,7 @@ sub __create_attributes {
my ( $class, $symbol, undef, undef, undef, undef, $file, $line ) = @_;
if ( $symbol eq 'ANON' ) {
- die "Cannot add plans to anonymous subs at file $file, line $line\n";
+ croak("Cannot add plans to anonymous subs at file $file, line $line");
}
my $method = *{$symbol}{NAME};
@@ -77,7 +83,7 @@ sub __create_attributes {
my ( $class, $symbol, undef, undef, $data, undef, $file, $line ) = @_;
if ( $symbol eq 'ANON' ) {
- die "Cannot add plans to anonymous subs at file $file, line $line\n";
+ croak("Cannot add plans to anonymous subs at file $file, line $line");
}
my $method = *{$symbol}{NAME};
@@ -101,18 +107,8 @@ DECLARE_ATTRIBUTES
}
BEGIN {
- class_has '__attributes_unavailable' => (
- is => 'rw',
- isa => 'Str',
- default => '',
- writer => '_set___attributes_unavailable',
- );
- eval "use Sub::Attribute";
- __PACKAGE__->_set___attributes_unavailable($@);
- unless (__PACKAGE__->__attributes_unavailable) {
- eval __PACKAGE__->__create_attributes;
- __PACKAGE__->_set___attributes_unavailable($@);
- }
+ eval __PACKAGE__->__create_attributes;
+ croak($@) if $@;
}
has 'test_configuration' => (
@@ -146,11 +142,9 @@ sub import {
package $caller;
use Moose;
use Test::Most;
+use Sub::Attribute;
END
- unless ($class->__attributes_unavailable) {
- $preamble .= "use Sub::Attribute;\n";
- }
eval $preamble;
croak($@) if $@;
strict->import;
@@ -176,16 +170,6 @@ around 'BUILDARGS' => sub {
sub BUILD {
my $self = shift;
- my $config = $self->test_configuration;
- if ( ( $config->include_tags or $config->exclude_tags )
- and $self->__attributes_unavailable )
- {
- my $reason = $self->__attributes_unavailable;
- carp("Attributes not available: $reason");
- $config->clear_include_tags;
- $config->clear_exclude_tags;
- }
-
# stash that name lest something change it later. Paranoid?
$self->test_class( $self->meta->name );
}
View
21 lib/Test/Class/Moose/Role.pm
@@ -5,14 +5,13 @@ package Test::Class::Moose::Role;
use 5.10.0;
use Carp;
+use Sub::Attribute;
use Test::Class::Moose::AttributeRegistry;
BEGIN {
require Test::Class::Moose;
- eval "use Sub::Attribute";
- unless ( Test::Class::Moose->__attributes_unavailable ) {
- eval Test::Class::Moose->__create_attributes;
- }
+ eval Test::Class::Moose->__create_attributes;
+ croak($@) if $@;
}
sub import {
@@ -23,19 +22,15 @@ sub import {
package $caller;
use Moose::Role;
use Test::Most;
+use Sub::Attribute;
END
- unless ( Test::Class::Moose->__attributes_unavailable ) {
- $preamble .= "use Sub::Attribute;\n";
- }
eval $preamble;
croak($@) if $@;
- unless ( Test::Class::Moose->__attributes_unavailable ) {
- no strict "refs";
- *{"$caller\::Tags"} = \&Tags;
- *{"$caller\::Test"} = \&Test;
- *{"$caller\::Tests"} = \&Tests;
- }
+ no strict "refs";
+ *{"$caller\::Tags"} = \&Tags;
+ *{"$caller\::Test"} = \&Test;
+ *{"$caller\::Tests"} = \&Tests;
}
1;
View
6 t/plans.t
@@ -30,12 +30,6 @@ use Carp::Always;
use Test::Class::Moose::Load qw(t/planlib);
-BEGIN {
- # some plans are set via attributes
- plan skip_all => 'Sub::Attribute not available. Cannot test tags'
- if Test::Class::Moose->__attributes_unavailable;
-}
-
my $test_suite = Test::Class::Moose->new;
subtest 'run the test suite' => sub {
my $builder = Test::Builder->new;
View
2  t/taglib/TestsFor/Basic/Role.pm
@@ -8,12 +8,10 @@ sub test_in_a_role {
pass "This is picked up from role";
}
-
sub in_a_role_with_tags : Tags(first){
fail "We should never see this test";
}
-
sub test_in_a_role_with_tags : Tags(second){
pass "We should see this test";
}
View
6 t/tags.t
@@ -1,14 +1,10 @@
#!/usr/bin/env perl
-use Test::Most 'bail';
+use Test::Most;
use lib 'lib';
use Test::Class::Moose (); # prevents us from inheriting from it
sub registry () { 'Test::Class::Moose::AttributeRegistry' }
-BEGIN {
- plan skip_all => 'Sub::Attribute not available. Cannot test tags'
- if Test::Class::Moose->__attributes_unavailable;
-}
use Test::Class::Moose::Load qw(t/taglib);
subtest 'Multiple included tags' => sub {
Please sign in to comment.
Something went wrong with that request. Please try again.