Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: How to syntax-check Catalyst code which throws 'Invalid CODE attributes' errors?

by bliako (Monsignor)
on Jun 09, 2021 at 07:05 UTC ( [id://11133684]=note: print w/replies, xml ) Need Help??


in reply to How to syntax-check Catalyst code which throws 'Invalid CODE attributes' errors?

Nuke the Attributes pragma.

echo "package Attributes;1" > /tmp/Attributes.pm perl -c -I/tmp file-to-test.pl

5' EDIT: I don't know Catalyst or Moose, so if it's attributes you meant, just lowercase the above. And make sure -I/tmp is before any other -I

Update:

# file ./strict.pm package strict;1
perl -I. -Mstrict -e '$x=42' perl -Mstrict -e '$x=42' ouch!

bw, bliako

Replies are listed 'Best First'.
Re^2: How to syntax-check Catalyst code which throws 'Invalid CODE attributes' errors?
by LittleJack (Beadle) on Jun 10, 2021 at 01:36 UTC

    Great! That did it, thanks so much.

    Lower case 'attributes' is what was required, for the record.

      That’s punting a class of Catalyst errors though. Perl allows weird syntax in the “attributes” slot so you’ll only know if they’re bug-free if they go through Catalyst. I would always recommend using regular TAP style testing too. Every time you stray from standard practices you accrue unnecessary technical debt.

      Example tests–

      #!/usr/bin/env perl use strict; use warnings; use Test::More; use Catalyst::Test "MyApp"; # Closest to what you’re already doing. use_ok "MyApp::Controller::Foo"; # More what I would suggest because it’s testing how the # code is called and what it truly does. ok request("/foo")->is_success, "GET /foo is successful"; done_testing(2);

      To get a full list of the action/path endpoints you might want to test, like /foo above, you can run–

      env CATALYST_DEBUG=1 ./script/myapp_server.pl

      You might have trouble if you have tightly coupled models or something. It’s easy to change the configuration to mock/test DBs though. The common way, but your app might not be set up that way, is to have a myapp_test.yml/myapp_test.conf file that overrides the production/deployment models or config (in myapp.yml/myapp.conf).

        I posted the above method as a *generic* means of nuking or mocking packages (thanks choroba) and, now it seems, pragmata. It's open to criticism with respect to its usage to this particular scenario, and Catalyst, of which I have no experience.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11133684]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (2)
As of 2024-04-25 05:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found