Skip to content

Commit

Permalink
00-load.t: Improve file find logic
Browse files Browse the repository at this point in the history
We were generating false positives if the
path had "Biodiverse" in it more than once.
This led to failing tests.
  • Loading branch information
shawnlaffan committed Aug 1, 2023
1 parent cc7face commit c4bad7d
Showing 1 changed file with 22 additions and 18 deletions.
40 changes: 22 additions & 18 deletions t/00-load.t
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use Test2::V0;

#my @files;
use FindBin qw { $Bin };
use File::Spec;
use Path::Tiny qw /path/;

Check failure on line 12 in t/00-load.t

View workflow job for this annotation

GitHub Actions / perl

Use of uninitialized value $Alien::sqlite::VERSION in sprintf
use File::Find;
use List::Util qw /max/;

Expand All @@ -27,11 +27,14 @@ BEGIN {
# list of files
our @files;

my $cwd = Path::Tiny->cwd;

sub Wanted {
# only operate on Perl modules
return if $_ !~ m/\.pm$/;
my $filename = $File::Find::name;


my $filename = path($File::Find::name)->relative($cwd);

return if $filename !~ m/Biodiverse/;
return if $filename =~ m/Task/; # ignore Task files
return if $filename =~ m/Bundle/; # ignore Bundle files
Expand All @@ -40,16 +43,17 @@ sub Wanted {
# ignore GUI files
return if !$ENV{BD_TEST_GUI} && $filename =~ m/GUI/;

$filename =~ s/\.pm$//;
if ($filename =~ /((?:App\/)?Biodiverse.*)$/) {
if ($filename =~ m|((?:App/)?Biodiverse(?:X?).*)$|) {
$filename = $1;
}
$filename =~ s/\.pm$//;
$filename =~ s{/}{::}g;

push @files, $filename;
};


my $lib_dir = File::Spec->catfile( $Bin, '..', 'lib' );
my $lib_dir = path ( $Bin, '..', 'lib' );
find ( \&Wanted, $lib_dir );


Expand All @@ -65,22 +69,22 @@ diag '';
diag 'Aliens:';
my %alien_versions;
my @aliens = qw /
Alien::gdal Alien::geos::af Alien::sqlite
Alien::proj Alien::libtiff Alien::spatialite
Alien::freexl
Alien::gdal Alien::geos::af Alien::sqlite
Alien::proj Alien::libtiff Alien::spatialite
Alien::freexl
/;
my $longest_name = max map {length} @aliens;
foreach my $alien (@aliens) {
eval "require $alien; 1";
if ($@) {
#diag "$alien not installed";
diag sprintf "%-${longest_name}s: not installed", $alien;
next;
#diag "$alien not installed";
diag sprintf "%-${longest_name}s: not installed", $alien;
next;
}
diag sprintf "%-${longest_name}s: version:%7s, install type: %s",
$alien,
$alien->version // 'unknown',
$alien->install_type;
$alien,
$alien->version // 'unknown',
$alien->install_type;
$alien_versions{$alien} = $alien->version;
}

Expand All @@ -99,11 +103,11 @@ my $locale_is_comma;
BEGIN {
use POSIX qw /locale_h/;
my $locale_values = localeconv();
$locale_is_comma = $locale_values->{decimal_point} eq ',';
$locale_is_comma = $locale_values->{decimal_point} eq ',';
}
use constant LOCALE_USES_COMMA_RADIX => $locale_is_comma;
diag "Radix char is "
. (LOCALE_USES_COMMA_RADIX ? '' : 'not ')
. 'a comma.';
. (LOCALE_USES_COMMA_RADIX ? '' : 'not ')
. 'a comma.';

done_testing();

0 comments on commit c4bad7d

Please sign in to comment.