You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
user@host:~/app$ cat t/suite.t
use warnings;
use File::Spec::Functions qw( catdir );
use FindBin qw( $Bin );
use Test::Class::Moose::Load catdir( $Bin, 'lib/' );
use Test::Class::Moose::Runner;
Test::Class::Moose::Runner->new->runtests;
user@host:~/app$ cat t/lib/A.pm
package t::A;
use Test::Class::Moose;
with qw/t::Role/;
BEGIN { print "IN A\n";}
sub test_hey {
ok 1, "hello";
}
1;
user@host:~/app$ cat t/lib/Role.pm
package t::Role;
use Test::Class::Moose::Role;
BEGIN { print "IN ROLE\n";}
sub test_role {
ok 1, "from role";
}
1;
user@host:~/app$ prove -v t/suite.t
t/suite.t ..
IN A
You can only consume roles, t::Role is not a Moose role at /usr/local/lib/x86_64-linux-gnu/perl/5.20.2/Moose/Exporter.pm line 419
Moose::with('t::Role') called at /home/user/app/t/lib/A.pm line 4
require A.pm at (eval 7) line 1
Test::Class::Moose::Load::BEGIN at /home/user/app/t/lib/A.pm line 0
eval {...} at /home/user/app/t/lib/A.pm line 0
eval 'use A ()' at /usr/local/share/perl/5.20.2/Test/Class/Moose/Load.pm line 54
Test::Class::Moose::Load::_load('Test::Class::Moose::Load', '/home/user/app/t/lib/A.pm', '/home/user/app/t/lib') called at /usr/local/share/perl/5.20.2/Test/Class/Moose/Load.pm line 68
Test::Class::Moose::Load::__ANON__ at /usr/share/perl/5.20/File/Find.pm line 796
File::Find::_find_dir('HASH(0x1e4fb50)', '/home/user/app/t/lib', 3) called at /usr/share/perl/5.20/File/Find.pm line 578
File::Find::_find_opt('HASH(0x1e4fb50)', '/home/user/app/t/lib') called at /usr/share/perl/5.20/File/Find.pm line 1081
File::Find::find('HASH(0x1e4fb50)', '/home/user/app/t/lib') called at /usr/local/share/perl/5.20.2/Test/Class/Moose/Load.pm line 73
Test::Class::Moose::Load::import('Test::Class::Moose::Load', '/home/user/app/t/lib') called at t/suite.t line 6
main::BEGIN at /home/user/app/t/lib/A.pm line 0
eval {...} at /home/user/app/t/lib/A.pm line 0
Compilation failed in require at (eval 7) line 1.
BEGIN failed--compilation aborted at (eval 7) line 1.
BEGIN failed--compilation aborted at t/suite.t line 6.
Dubious, test returned 255 (wstat 65280, 0xff00)
No subtests run
Test Summary Report
-------------------
t/suite.t (Wstat: 65280 Tests: 0 Failed: 0)
Non-zero exit status: 255
Parse errors: No plan found in TAP output
Files=1, Tests=0, 0 wallclock secs ( 0.03 usr 0.00 sys + 0.39 cusr 0.03 csys = 0.45 CPU)
Result: FAIL
user@host:~/app$ mv t/lib/A.pm t/lib/subdir/
user@host:~/app$ prove -v t/suite.t
t/suite.t ..
IN ROLE
IN A
1..1
ok 1 - t::A {
1..2
ok 1 - test_hey {
ok 1 - hello
1..1
}
ok 2 - test_role {
ok 1 - from role
1..1
}
}
ok
All tests successful.
Files=1, Tests=1, 0 wallclock secs ( 0.03 usr 0.01 sys + 0.66 cusr 0.01 csys = 0.71 CPU)
Result: PASS
There is a similar issue with test class inheritance where the child class must be loaded after the parent by forcing it into a subdirectory (found by adding debug statements in Test::Class::Moose::Load::import).
Regardless, very nice framework.
The text was updated successfully, but these errors were encountered:
Thanks for reporting this. I'm not really sure why this is happening. If you can turn this into a PR with a failing test case, that'd make it much easier for me to fix it.
autarch
changed the title
Include order of Roles or Inherited Objects throws Moose error
Moose error can happen because of order in which roles are consumed
Dec 10, 2017
FWIW, I just tried replicating this with the latest Moose & TCM. I used the code you have above and I confirmed that the role was loaded before the class. I did not get the same error.
Can you try with the latest versions of Moose & TCM? I'm inclined to close this bug since it no longer seems to be a thing.
When trying to install Test::Class::[email protected] on an Ubuntu with 5.18.2 I noticed that the test program t/tags.t failed with You can only consume roles, TestsFor::Basic::Role is not a Moose role at /usr/lib/perl5/Moose/Util.pm.
This first failure of this kind is introduced with Test::Class::Moose version 0.85. Version 0.84 installs fine on 5.18.2.
I uploaded my test reports with cpanm-reporter, so they should show up in the CPANTesters matrix soon.
There is a similar issue with test class inheritance where the child class must be loaded after the parent by forcing it into a subdirectory (found by adding debug statements in Test::Class::Moose::Load::import).
Regardless, very nice framework.
The text was updated successfully, but these errors were encountered: