Alien-PCRE2

 view release on metacpan or  search on metacpan

t/02_pcre2_config.t  view on Meta::CPAN

use strict;
use warnings;
our $VERSION = 0.027_000;

use Test2::V0;
use Test::Alien;
use Alien::PCRE2;
use File::Spec;  # for splitpath() and catpath()
use Env qw( @PATH );
use IPC::Cmd qw(can_run);
use English qw(-no_match_vars);  # for $OSNAME
use Capture::Tiny qw( capture_merged );
use Data::Dumper;  # DEBUG

plan(24);

# load alien
alien_ok('Alien::PCRE2', 'Alien::PCRE2 loads successfully and conforms to Alien::Base specifications');

my $pcre2_bin_dirs = [ Alien::PCRE2->bin_dir() ];
diag "\n\n", q{<<< DEBUG >>> in t/02_pcre2_config.t, have $pcre2_bin_dirs = '}, Dumper($pcre2_bin_dirs), q{'}, "\n\n";

subtest 'Check bin_dir permissions' => sub {
    skip_all 'No bin_dir for system install' if Alien::PCRE2->install_type('system');
    # test pcre2 directory permissions
    foreach my $pcre2_bin_dir (@{$pcre2_bin_dirs}) {
        ok(defined $pcre2_bin_dir, 'Alien::PCRE2->bin_dir() element is defined');
        isnt($pcre2_bin_dir, q{}, 'Alien::PCRE2->bin_dir() element is not empty');
        ok(-e $pcre2_bin_dir, 'Alien::PCRE2->bin_dir() element exists');
        ok(-r $pcre2_bin_dir, 'Alien::PCRE2->bin_dir() element is readable');
        ok(-d $pcre2_bin_dir, 'Alien::PCRE2->bin_dir() element is a directory');
    }
};

# check if `pcre2-config` can be run, if so get path to binary executable
my $pcre2_path = undef;
# DEV NOTE, CORRELATION #ap002: Windows hack, shell script `pcre2-config` not found as executable
if ($OSNAME eq 'MSWin32') {
#    $pcre2_path = can_run('pcre2-config');
    $pcre2_path = can_run('pcre2grep');
}
else {
    $pcre2_path = can_run('pcre2-config');
}
diag "\n\n", q{<<< DEBUG >>> in t/02_pcre2_config.t, have $pcre2_path = '}, $pcre2_path, q{'}, "\n\n";
ok(defined $pcre2_path, 'pcre2-config binary path is defined');
isnt($pcre2_path, q{}, 'pcre2-config binary path is not empty');

# split pcre2-config executable file from directory containing it
(my $pcre2_volume, my $pcre2_directories, my $pcre2_file) = File::Spec->splitpath($pcre2_path);
my $pcre2_directory = File::Spec->catpath($pcre2_volume, $pcre2_directories, q{});
diag "\n\n", q{<<< DEBUG >>> in t/02_pcre2_config.t, have $pcre2_directory = '}, $pcre2_directory, q{'}, "\n\n";

# DEV NOTE, CORRELATION #ap002: Windows hack, shell script `pcre2-config` not found as executable
if ($OSNAME eq 'MSWin32') {
    $pcre2_path = File::Spec->catpath($pcre2_volume, $pcre2_directories, q{pcre2-config});
diag "\n\n", q{<<< DEBUG >>> in t/02_pcre2_config.t, have WINDOWS HACK $pcre2_path = '}, $pcre2_path, q{'}, "\n\n";
}

# test pcre2 directory permissions
ok(defined $pcre2_directory, 'can_run() binary directory is defined');
isnt($pcre2_directory, q{}, 'can_run() binary directory is not empty');
ok(-e $pcre2_directory, 'can_run() binary directory exists');
ok(-r $pcre2_directory, 'can_run() binary directory is readable');
ok(-d $pcre2_directory, 'can_run() binary directory is a directory');

# test pcre2 executable permissions
ok(-e $pcre2_path, 'pcre2-config binary path exists');
ok(-r $pcre2_path, 'pcre2-config binary path is readable');
ok(-f $pcre2_path, 'pcre2-config binary path is a file');

# DEV NOTE, CORRELATION #ap002: Windows hack, shell script `pcre2-config` not found as executable
SKIP: {



( run in 1.088 second using v1.01-cache-2.11-cpan-63c85eba8c4 )