Commit | Line | Data |
1ed25f9e |
1 | my $has_threads; |
2 | BEGIN { eval ' |
3 | use 5.008001; |
4 | use threads; |
5 | use threads::shared; |
6 | $has_threads = 1; |
7 | ' } |
8 | |
85ccab9a |
9 | use strict; |
10 | use warnings; |
1ed25f9e |
11 | no warnings 'once'; |
85ccab9a |
12 | use FindBin qw($Bin); |
13 | use File::Spec::Functions; |
14 | use File::Spec::Unix (); # need this for %INC munging |
15 | use Test::More; |
16 | use lib 't/lib'; |
17 | |
18 | BEGIN { |
716410c9 |
19 | local $ENV{DEVEL_HIDE_VERBOSE} = 0; |
85ccab9a |
20 | eval { require Devel::Hide }; |
21 | if ($@) { |
22 | eval { require Sub::Name }; |
23 | plan skip_all => "Devel::Hide required for this test in presence of Sub::Name" |
24 | if ! $@; |
25 | } |
26 | else { |
27 | Devel::Hide->import('Sub/Name.pm'); |
28 | } |
29 | require Class::Accessor::Grouped; |
30 | } |
31 | |
ed606987 |
32 | |
85ccab9a |
33 | # rerun the regular 3 tests under the assumption of no Sub::Name |
ed606987 |
34 | our $SUBTESTING = 1; |
35 | for my $tname (qw/accessors.t accessors_ro.t accessors_wo.t/) { |
36 | |
1ed25f9e |
37 | my $pass = 1; |
38 | share($pass) if $has_threads; |
39 | |
40 | my $todo = sub { |
41 | note "\nTesting $tname without Sub::Name (pass @{[ $pass ++ ]})\n\n"; |
85ccab9a |
42 | |
2f4e57f4 |
43 | my ($tfn) = catfile($Bin, $tname) =~ /(.+)/; |
85ccab9a |
44 | |
45 | delete $INC{$_} for ( |
5808b224 |
46 | qw/AccessorGroups.pm AccessorGroupsRO.pm AccessorGroupsSubclass.pm AccessorGroupsParent.pm AccessorGroupsWO.pm/, |
85ccab9a |
47 | File::Spec::Unix->catfile ($tfn), |
48 | ); |
49 | |
50 | local $SIG{__WARN__} = sub { warn @_ unless $_[0] =~ /subroutine .+ redefined/i }; |
51 | |
52 | do($tfn); |
1ed25f9e |
53 | }; |
85ccab9a |
54 | |
1ed25f9e |
55 | if ($has_threads) { |
56 | threads->create(sub { |
57 | threads->create(sub { |
58 | $todo->() for (1,2) } |
59 | )->join; |
60 | $todo->() for (1,2); |
61 | })->join for (1,2) |
62 | } |
63 | else { |
64 | $todo->() for (1, 2); |
ed606987 |
65 | } |
85ccab9a |
66 | } |
67 | |
68 | done_testing; |