X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Faccessors_pp.t;h=de43239c432c946c4855f002228dde64c08aa91d;hb=1ed25f9e8d107a7311c579da0d23afa253c01268;hp=3fed3aadb51983474a3aa74767676acfceab976d;hpb=716410c9f5a5c13adac8709cff08d5cdd5e7f163;p=p5sagit%2FClass-Accessor-Grouped.git diff --git a/t/accessors_pp.t b/t/accessors_pp.t index 3fed3aa..de43239 100644 --- a/t/accessors_pp.t +++ b/t/accessors_pp.t @@ -1,5 +1,14 @@ +my $has_threads; +BEGIN { eval ' + use 5.008001; + use threads; + use threads::shared; + $has_threads = 1; +' } + use strict; use warnings; +no warnings 'once'; use FindBin qw($Bin); use File::Spec::Functions; use File::Spec::Unix (); # need this for %INC munging @@ -20,22 +29,40 @@ BEGIN { require Class::Accessor::Grouped; } + # rerun the regular 3 tests under the assumption of no Sub::Name +our $SUBTESTING = 1; for my $tname (qw/accessors.t accessors_ro.t accessors_wo.t/) { - subtest "$tname without Sub::Name (pass $_)" => sub { + my $pass = 1; + share($pass) if $has_threads; + + my $todo = sub { + note "\nTesting $tname without Sub::Name (pass @{[ $pass ++ ]})\n\n"; + my $tfn = catfile($Bin, $tname); delete $INC{$_} for ( - qw/AccessorGroups.pm AccessorGroupsRO.pm AccessorGroupsSubclass.pm AccessorGroupsWO.pm/, + qw/AccessorGroups.pm AccessorGroupsRO.pm AccessorGroupsSubclass.pm AccessorGroupsParent.pm AccessorGroupsWO.pm/, File::Spec::Unix->catfile ($tfn), ); local $SIG{__WARN__} = sub { warn @_ unless $_[0] =~ /subroutine .+ redefined/i }; do($tfn); + }; - } for (1 .. 2); + if ($has_threads) { + threads->create(sub { + threads->create(sub { + $todo->() for (1,2) } + )->join; + $todo->() for (1,2); + })->join for (1,2) + } + else { + $todo->() for (1, 2); + } } done_testing;