ctrlo / GADS

Globally Accessible Data Store
GNU Affero General Public License v3.0
4 stars 7 forks source link

Failure with latst D2/D2::P::DBIC #8

Open ribasushi opened 7 years ago

ribasushi commented 7 years ago

( I really hope this is not another red herring this time, please double check my oneliner before doing anything else)

During last test passes I upgraded my deps, and it seems this line is no longer valid:

~$ perl -e 'use Dancer2::Plugin::DBIC qw(schema resultset rset)'
Specific subroutines cannot be exported from plugin at -e line 1.
BEGIN failed--compilation aborted at -e line 1.

Here is the complete version list:

~$ perl -MModule::Versions::Report -e 'use Dancer2::Plugin::DBIC qw(schema resultset rset)'
Specific subroutines cannot be exported from plugin at -e line 1.
BEGIN failed--compilation aborted at -e line 1.

Perl v5.16.2 under linux 
 Modules in memory:
  Attribute;
  Attribute::Handlers v0.96;
  Attribute::Handlers::_TEST_;
  Attribute::Handlers::UNIVERSAL;
  attributes v0.19;
  B v1.35;
  B::AV;
  B::BINOP;
  B::BM;
  B::COP;
  B::CV;
  B::Deparse;
  B::FM;
  B::GV;
  B::HE;
  B::HV;
  B::IO;
  B::IV;
  B::LISTOP;
  B::LOGOP;
  B::LOOP;
  B::MAGIC;
  B::NULL;
  B::NV;
  B::OBJECT;
  B::OP;
  B::PADOP;
  B::PMOP;
  B::PV;
  B::PVIV;
  B::PVLV;
  B::PVMG;
  B::PVNV;
  B::PVOP;
  B::REGEXP;
  B::RHE;
  B::RV;
  B::Section;
  B::SPECIAL;
  B::SV;
  B::SVOP;
  B::UNOP;
  base v2.18;
  Carp v1.36;
  Carp::Heavy v1.36;
  Class;
  Class::Method;
  Class::Method::Modifiers v2.06;
  Class::MOP;
  Class::XSAccessor v1.19;
  Class::XSAccessor::Array;
  Class::XSAccessor::Heavy v1.19;
  Config;
  constant v1.27;
  CORE;
  CORE::GLOBAL;
  Cwd;
  Dancer2;
  Dancer2::Core v0.201000;
  Dancer2::Core::DSL v0.201000;
  Dancer2::Core::Hook v0.201000;
  Dancer2::Core::Response;
  Dancer2::Core::Response::Delayed v0.201000;
  Dancer2::Core::Role;
  Dancer2::Core::Role::DSL v0.201000;
  Dancer2::Core::Role::Hookable v0.201000;
  Dancer2::Core::Route;
  Dancer2::Core::Types v0.201000;
  Dancer2::FileUtils v0.201000;
  Dancer2::Plugin v0.201000;
  Dancer2::Plugin::DBIC v0.0014;
  Dancer2::Serializer;
  Dancer2::Serializer::Dumper;
  Dancer2::Serializer::JSON;
  Dancer2::Serializer::YAML;
  Data;
  Data::Dumper;
  DB;
  DBICx;
  DBICx::Sugar v0.0001;
  DBIx;
  DBIx::Class;
  DBIx::Class::Schema;
  Devel;
  Devel::GlobalDestruction v0.11;
  Devel::GlobalDestruction::XS;
  Devel::LexAlias;
  Devel::TypeTiny;
  Devel::TypeTiny::Perl56Compat;
  Devel::TypeTiny::Perl58Compat;
  DynaLoader v1.14;
  Error;
  Error::TypeTiny;
  Error::TypeTiny::Assertion;
  Error::TypeTiny::Compilation;
  Eval;
  Eval::TypeTiny v1.000005;
  Eval::TypeTiny::Sandbox;
  Exporter v5.72;
  Exporter::Heavy v5.72;
  Exporter::Tiny v0.038;
  fields;
  File;
  File::Basename v2.84;
  File::Spec v3.47;
  File::Spec::Unix v3.47;
  Internals;
  IO;
  IO::File;
  IO::Handle;
  IO::Seekable;
  List;
  List::Util v1.45;
  List::Util::_Pair;
  MacPerl;
  maybe;
  maybe::next;
  Memoize v1.02;
  Method;
  Method::Generate;
  Method::Generate::Accessor;
  Method::Generate::Accessor::_Generated;
  Method::Generate::BuildAll;
  Method::Generate::Constructor;
  Method::Generate::DemolishAll;
  Mo;
  Mo::builder v0.31;
  Mo::default v0.31;
  Module;
  Module::Load v0.32;
  Module::Runtime v0.014;
  Module::Versions;
  Module::Versions::Report v1.06;
  Moo v2.002004;
  Moo::_mro;
  Moo::_strictures;
  Moo::_Utils;
  Moo::HandleMoose;
  Moo::HandleMoose::_TypeMap;
  Moo::HandleMoose::AuthorityHack;
  Moo::HandleMoose::FakeMetaClass;
  Moo::Object;
  Moo::Role v2.002004;
  Moo::Role::SUPER;
  Moo::sification;
  Moose;
  Moose::Meta;
  Moose::Meta::TypeCoercion;
  Moose::Meta::TypeConstraint;
  Moose::Meta::TypeConstraint::Class;
  Moose::Meta::TypeConstraint::Enum;
  Moose::Util;
  Moose::Util::TypeConstraints;
  Mouse;
  Mouse::Meta;
  Mouse::Meta::TypeConstraint;
  Mouse::Util;
  Mouse::Util::TypeConstraints;
  mro v1.09;
  MRO;
  MRO::Compat;
  next;
  Object;
  overload v1.18;
  overload::numbers;
  overloading v0.02;
  PerlIO;
  PerlIO::Layer;
  re v0.19_01;
  Regexp;
  Role;
  Role::Tiny v2.000003;
  Role::Tiny::__GUARD__;
  Safe;
  Safe::Isa v1.000004;
  Scalar;
  Scalar::Util v1.45;
  strict v1.07;
  strictures;
  Sub;
  Sub::Defer v2.002004;
  Sub::Exporter;
  Sub::Exporter::Progressive v0.001011;
  Sub::Name v0.14;
  Sub::Quote v2.002004;
  Sub::Util v1.45;
  Term;
  Term::Cap;
  threads;
  Type;
  Type::Coercion v1.000005;
  Type::Coercion::FromMoose;
  Type::Library v1.000005;
  Type::Library::SUPER;
  Type::Registry;
  Type::Registry::DWIM;
  Type::Tie;
  Type::Tie::ARRAY;
  Type::Tie::HASH;
  Type::Tie::SCALAR;
  Type::Tiny v1.000005;
  Type::Tiny::_HalfOp;
  Type::Tiny::Class v1.000005;
  Type::Tiny::Class::SUPER;
  Type::Tiny::Duck;
  Type::Tiny::Enum v1.000005;
  Type::Tiny::Enum::SUPER;
  Type::Tiny::Intersection;
  Type::Tiny::Role;
  Type::Tiny::SUPER;
  Type::Tiny::Union;
  Type::Tiny::XS;
  Type::Tiny::XS::Util;
  Type::Utils v1.000005;
  Types;
  Types::Standard v1.000005;
  Types::Standard::_Stringable;
  Types::Standard::Dict;
  Types::Standard::HashRef;
  Types::Standard::LazyLoad;
  Types::Standard::Map;
  Types::TypeTiny v1.000005;
  UNIVERSAL;
  utf8 v1.09;
  Validation;
  Validation::Class;
  Validation::Class::Directive;
  Validation::Class::Directive::Filters;
  vars v1.02;
  version;
  VMS;
  VMS::Filespec;
  warnings v1.13;
  warnings::register v1.02;
  Win32;
  XSLoader v0.16;
  YAML v1.18;
  YAML::Dumper;
  YAML::Dumper::Base;
  YAML::Error;
  YAML::Mo;
  YAML::Mo::builder;
  YAML::Mo::default;
  YAML::Mo::Object;
  YAML::Node;
  YAML::Tag;
  yaml_mapping;
  yaml_scalar;
  yaml_sequence;
[at Fri Jul 22 15:45:43 2016 (local) / Fri Jul 22 13:45:43 2016 (GMT)]
ribasushi commented 7 years ago

The actual fail-case is:

rabbit@Ahasver:~/devel/GADS$ git rev-parse HEAD
e42be1115566d453210f655be33f21a98600d6f4

rabbit@Ahasver:~/devel/GADS$ prove -I /home/rabbit/devel/sqlt/lib -lr t/001_base.t 
t/001_base.t .. 1/1 
#   Failed test 'use GADS;'
#   at t/001_base.t line 5.
#     Tried to use 'GADS'.
#     Error:  Specific subroutines cannot be exported from plugin at /home/rabbit/devel/GADS/lib/GADS.pm line 72.
# BEGIN failed--compilation aborted at /home/rabbit/devel/GADS/lib/GADS.pm line 72.
# Compilation failed in require at t/001_base.t line 5.
# BEGIN failed--compilation aborted at t/001_base.t line 5.
# Looks like you failed 1 test of 1.
t/001_base.t .. Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/1 subtests 

Test Summary Report
-------------------
t/001_base.t (Wstat: 256 Tests: 1 Failed: 1)
  Failed test:  1
  Non-zero exit status: 1
Files=1, Tests=1,  1 wallclock secs ( 0.03 usr  0.00 sys +  1.41 cusr  0.07 csys =  1.51 CPU)
Result: FAIL
abeverley commented 7 years ago

Thanks @ribasushi , absolutely correct. Fixed in 7399819.

ribasushi commented 7 years ago

Hm... master still fails tests for me with the above fix included. Latest D2, Moo, and whatever plugins you list in Makefile.PL:

rabbit@Ahasver:~/devel/GADS$ prove -I /home/rabbit/devel/sqlt/lib -l t/001_base.t 
t/001_base.t .. No Auth::Extensible realms configured with which to authenticate user at /home/rabbit/perl5/perlbrew/perls/5.16.2/lib/site_perl/5.16.2/Dancer2/Plugin/Auth/Extensible.pm line 1188.
Array found where operator expected at /home/rabbit/devel/GADS/lib/GADS.pm line 86, at end of line
    (Missing operator before ?)
String found where operator expected at /home/rabbit/devel/GADS/lib/GADS.pm line 1367, near "__"An email address must be specified for the new user""
String found where operator expected at /home/rabbit/devel/GADS/lib/GADS.pm line 1371, near "__"Please enter a valid email address for the new user""
String found where operator expected at /home/rabbit/devel/GADS/lib/GADS.pm line 1764, near "__"You do not have permission to create a child record""
t/001_base.t .. 1/1 
#   Failed test 'use GADS;'
#   at t/001_base.t line 5.
#     Tried to use 'GADS'.
#     Error:  syntax error at /home/rabbit/devel/GADS/lib/GADS.pm line 86, near "panic @_"
# syntax error at /home/rabbit/devel/GADS/lib/GADS.pm line 1367, near "__"An email address must be specified for the new user""
# syntax error at /home/rabbit/devel/GADS/lib/GADS.pm line 1371, near "__"Please enter a valid email address for the new user""
# syntax error at /home/rabbit/devel/GADS/lib/GADS.pm line 1695, near "process sub "
# Global symbol "$to_write" requires explicit package name at /home/rabbit/devel/GADS/lib/GADS.pm line 1695.
# syntax error at /home/rabbit/devel/GADS/lib/GADS.pm line 1695, near ") }"
# Global symbol "$failed" requires explicit package name at /home/rabbit/devel/GADS/lib/GADS.pm line 1697.
# syntax error at /home/rabbit/devel/GADS/lib/GADS.pm line 1699, near "}"
# Global symbol "$record" requires explicit package name at /home/rabbit/devel/GADS/lib/GADS.pm line 1701.
# Global symbol "$failed" requires explicit package name at /home/rabbit/devel/GADS/lib/GADS.pm line 1702.
# Global symbol "$failed" requires explicit package name at /home/rabbit/devel/GADS/lib/GADS.pm line 1705.
# /home/rabbit/devel/GADS/lib/GADS.pm has too many errors.
# Compilation failed in require at t/001_base.t line 5.
# BEGIN failed--compilation aborted at t/001_base.t line 5.
# Looks like you failed 1 test of 1.
t/001_base.t .. Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/1 subtests 
abeverley commented 7 years ago

That looks like the Log::Report functions haven't been imported properly. Is that definitely the latest version? The latest version of D2 will require the latest version of Log::Report (not sure how to make that a dependency failure, maybe I should just bump the version in GADS).

ribasushi commented 7 years ago

Bah, indeed wasn't latest Log::Report. Sorry for the noise. As far as "how to" - yes, generally requiring both latest D2 and latest L::R in your GADS Makefile.PL is the easiest way forward. That is unless you have a reason to work on older D2 versions (which is rarely the case for end-user-app level stuff).

ribasushi commented 7 years ago

I will keep my "older but clearly passing Makefile.PL" inc around for when you get a moment to update your Makefile.PL, will retest then

ribasushi commented 7 years ago

Confirmed - on a fresh 5.24.0 (with an empty @INC), after nudging some of the deps with cpanm -n (due to their own broken tests), your own tests decidedly fail with "all newest" as such:

./t/001_base.t ............ No Auth::Extensible realms configured with which to authenticate user at /home/rabbit/perl5/perlbrew/perls/5.24.0/lib/site_perl/5.24.0/Dancer2/Plugin/Auth/Extensible.pm line 185.
Plugin DSL method 'hook' is deprecated. Use '$self->app->add_hook' instead'.
 at /home/rabbit/devel/GADS/lib/GADS.pm line 74.
Plugin DSL method 'hook' is deprecated. Use '$self->app->add_hook' instead'.
 at /home/rabbit/devel/GADS/lib/GADS.pm line 74.
./t/001_base.t ............ 1/1 
#   Failed test 'use GADS;'
#   at ./t/001_base.t line 5.
#     Tried to use 'GADS'.
#     Error:  No schemas are configured at /home/rabbit/perl5/perlbrew/perls/5.24.0/lib/site_perl/5.24.0/DBICx/Sugar.pm line 46.
# Compilation failed in require at ./t/001_base.t line 5.
# BEGIN failed--compilation aborted at ./t/001_base.t line 5.
# Looks like you failed 1 test of 1.
./t/001_base.t ............ Dubious, test returned 1 (wstat 256, 0x100)
abeverley commented 7 years ago

Thanks for the bug report. It turns out that I always had a valid config.yml in my app directory structure, so that's why the tests never failed for me.

I've worked out how to place a test config.yml and read it from the tests that are failing. However, I also need to do a $schema->deploy as GADS assumes a deployed database is available (I realise I can hack that, but as I add tests I will need a deployed schema anyway).

So, question: in t/002_index_route.t I now have:

BEGIN {
    $ENV{DANCER_CONFDIR} = 't/lib';
    $ENV{DANCER_ENVIRONMENT} = 'config';
}

use Dancer2;
use Dancer2::Plugin::DBIC;
schema->deploy;
use GADS;
use Test::More tests => 2;
use Plack::Test;

my $app = GADS->to_app;
is( ref $app, 'CODE', 'Got app' );

my $test = Plack::Test->create($app);
my $res  = $test->request( GET '/' );

ok( $res->is_success, '[GET /] successful' );

How can I pass the schema object into $app? The problem is that the database for the tests is a dbi:SQLite:dbname=:memory:, so when it's initially deployed above, the app that is then created does not know about it.

ribasushi commented 7 years ago

I will look into this later today, will get back to you. Reopen the ticket if you don't mind - less chance I forget about it.

abeverley commented 7 years ago

Thanks, reopened.

abeverley commented 7 years ago

As far as "how to" - yes, generally requiring both latest D2 and latest L::R in your GADS Makefile.PL is the easiest way forward.

Thanks, that's what I've done in 006c4a8e.

ribasushi commented 7 years ago

How can I pass the schema object into $app?

@abeverley did the above ever get sorted? Or didn't have a chance to look yet?

abeverley commented 7 years ago

How can I pass the schema object into $app?

@abeverley did the above ever get sorted? Or didn't have a chance to look yet?

I did have a quick look at it, but I really couldn't see any way of doing what I want. Within the app, everything is instantiated from new

Unless there's an easy solution, I'll probably bypass the test or put in a hacky workaround, as the test is fairly minor compared to the rest of the tests.