http://qs1969.pair.com?node_id=11133677


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

That looks like exactly what I need, thank you. However I'm not quite understanding how I would use your inline example in my real-life situation, where I'm doing something like this:

perl -I /some/path/perl5 -c Path/To/lib/Controller/Foo.pm

How can I include your use parent code in that command?

  • Comment on Re^2: How to syntax-check Catalyst code which throws 'Invalid CODE attributes' errors?
  • Select or Download Code

Replies are listed 'Best First'.
Re^3: How to syntax-check Catalyst code which throws 'Invalid CODE attributes' errors?
by Your Mother (Archbishop) on Jun 09, 2021 at 05:50 UTC

    You can do that but I think you’re probably going to be happier testing the application itself instead of components; or testing the components from within the application. Controllers need to have a notion of the Catalyst context. Essentially, they don’t even properly exist except as part of a request dispatch. A controller endpoint cannot naturally do anything outside of that.

    What you’re doing is akin to trying to check subs inside a script instead of the script itself. It can be done but it’s weird given the, well, context of the code. Catalyst controllers aren’t code that can be run alone, only within and by the app. Side-note: models and views differ here. Catalyst only adds configuration and access affordances for those.

    Catalyst testing is really extremely good and flexible. Only Mojo is better, easier. It doesn’t require any (system, standalone, external) server or special environment or anything.

      I totally understand your point about not testing one file at a time but I'm in a tricky situation with source control which means I really need to to test things in isolation sometimes. I simply need to test for basic things like typos at one point in the lifecycle. So ... how would I do that?