Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect ActiveState version of perl?

One of my CPAN modules is not available on ActivePerl through its ppm utility. Apparently my unit testing for this module is too thorough and ActiveState's build process times out when it attempts to build it.

So what I would like to do in my tests is to detect when my module is being built on ActivePerl, and if so, to provide the build process with a smaller and faster set of tests.

One way I've found to do this is:

($is_activestate) = grep /provided by ActiveState/, qx($^X -v)

but I'm wondering if there is a more lightweight option. An environment variable that is always (and only) set in ActivePerl? Something in Config? Any other suggestions?

UPDATE: Looks like $ENV{ACTIVESTATE_PPM_BUILD} is set during these builds.

like image 308
mob Avatar asked May 05 '16 17:05

mob


People also ask

Is ActiveState Perl free?

ActiveState's Perl downloads are free, but there are some limits on use: you can use no more than one “active runtime” for free.

What is the difference between ActivePerl and Strawberry Perl?

Both are great and work the same. Strawberry Perl is known for being able to build XS modules, but you can do that with ActivePerl too if you just install the Visual Studio SDK (or the free Express version).


1 Answers

Checking if it's running under an ActivePerl build is not optimal. Ideally, you want to check if it's running in ActiveState's build environment. I would dump the env in t/00-use.t to see if they set some variable indicating this.

info("$_=$ENV{$_}") for sort keys %ENV;

You could also contact ActiveState and ask them what they recommend.


Alternatively, you could make it so the slowest tests only run on demand (e.g. when a certain environment is present). 5 minutes of testing might seem a bit excessive to others as well.


As for checking if you're running an ActiveState build, here are some possibilities:

  • use Config; print Config::local_patches(); returns a string that includes ActivePerl Build.
  • $Config{cf_email} is set to [email protected]
  • The ActivePerl::Config module exists.
  • The ActivePerl::PPM module exists.

Could always check all of them.

use Config qw( %Config );

my $is_activeperl = 0;
$is_activeperl ||= eval { Config::local_patches() =~ /ActivePerl/i };
$is_activeperl ||= $Config{cf_email} =~ /ActiveState/i;
$is_activeperl ||= eval { require ActivePerl::Config };
$is_activeperl ||= eval { require ActivePerl::PPM };
like image 136
ikegami Avatar answered Nov 06 '22 02:11

ikegami