Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support external perlcritic command? #16

Open
iynehz opened this issue Feb 7, 2018 · 2 comments
Open

Support external perlcritic command? #16

iynehz opened this issue Feb 7, 2018 · 2 comments

Comments

@iynehz
Copy link

iynehz commented Feb 7, 2018

At my workplace we have a special Perl package installation and usage mechanism that, we install CPAN packages to non-standard paths and we need to explicitly specify the paths of all the dependency packages (like by PERL5LIB or @INC) before using them. So when we develop/build/test our internal Perl library, the exact list of its dependencies are decided. This causes an annoying problem with Test::Perl::Critic that, if we use Test::Perl::Critic in our tests, we would need to add its dependencies, most of which are indirectly introduced by Perl::Critic, into the list. If there be the option to use an external perlcritic command, we would be able to decouple the non-trivial list of dependencies of Perl::Critic from that of our own libraries, and have our re-engineered perlcritic command to handle its own dependencies.

I know it sounds like a non-standard requirement. But I would like to bring it up for discussion here and hope it can be implemented in Test::Perl::Critic. In case you don't have interest, I will write a new module myself and put onto CPAN.

@thaljef
Copy link
Member

thaljef commented Feb 10, 2018

Unlike your other unit tests, Test::Perl::Critic doesn't actually load any of your libraries; it just sees them as files. So T::P::C doesn't need to have the same module environment as your libraries. So unless I misunderstand the gist of your request, I think you can already do what you want. You just have to invoke the T::P::C test script separately.

@iynehz
Copy link
Author

iynehz commented Feb 12, 2018

@thaljef Let me explain it in more details.

At my workplace Perl modules are not located naturally, and basically every package has a different lib path. The Perl interpreter by default does not see any non-core modules. When I test my library, I need to explicitly manipulate @INC, like hardcoding use lib in my test files, or more generically via prove's -I option or changing PERL5LIB, to specify the exact locations of my library dependencies. And those lib paths are my test dependencies.

Now I am re-engineering DZIL for my workplace as an internal build tool for Perl projects. With that thing I have Dist::Zilla::Plugin::Test::Perl::Critic for generating an additional test file that calls T::P::C. But because of the special environment as I explained above, when I "prove" this T::P::C test file, I will also need to explicitly inject T::P::C's dependencies, as otherwise the test file cannot run. If I don't re-engineer Dist::Zilla::Plugin::Test::Perl::Critic to change the auto-generated test file, then I would need to add dependencies of T::P::C into prove's -I option or PERL5LIB. But that change is possible to affect all test files, including my library's own test files.

As indicated above, an alternative approach for me can be to re-engineer Dist::Zilla::Plugin::Test::Perl::Critic to hack its generated test file. But as our perlcritic is already re-engineered, it would be great if T::P::C itself can support external perlciritic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants