How to detect ActiveState version of perl?
Asked Answered
G

2

9

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.

Gangster answered 5/5, 2016 at 17:17 Comment(1)
FWIW: Config::local_patches() may be of some value. On my machine it returns ActivePerl Build 2201 [299574].Resultant
F
7

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 };
Foreplay answered 5/5, 2016 at 17:55 Comment(1)
These are all great suggestions. Thanks!Gangster
L
4

According to a quick search for activeperl ppm build increase timeout you can report this situation to their mailing list/support and they will manually increase timeout value for builds of your module.

Lauber answered 5/5, 2016 at 19:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.