# HG changeset patch # User anatofuz # Date 1597964923 -32400 # Node ID ccc17667ffb2127eb000b01df9acbc640a66273a # Parent 49d57e7fce39cccb1e86f21d12b04b6d50172c71 ... diff -r 49d57e7fce39 -r ccc17667ffb2 src/parallel_execution/lib/Gears/Util.pm --- a/src/parallel_execution/lib/Gears/Util.pm Fri Aug 21 06:35:07 2020 +0900 +++ b/src/parallel_execution/lib/Gears/Util.pm Fri Aug 21 08:08:43 2020 +0900 @@ -16,7 +16,8 @@ my $ir = _parse_base($file_name); unless ($ir->{name}) { - croak "invalid struct name $file_name"; + carp "[WARN] invalid interface name at $file_name"; + return undef; } return $ir; } @@ -252,8 +253,9 @@ sub file_checking { my ($class, $file_name) = @_; unless (-f $file_name) { - croak "invalid filepath :$file_name\n"; + croak "[ERROR] invalid filepath :$file_name\n"; } + return $file_name; } sub slup { @@ -266,18 +268,18 @@ sub find_cbc_sources_from_path { - my $class = shift; - my $find_path = shift // "."; + my ($class, $find_path) = @_; + $find_path //= "."; - my @files; - find( { wanted => sub { push @files, $_ if /\.cbc/ }, no_chdir => 1 }, $find_path); + my @files; find( { wanted => sub { push @files, $_ if /\. +cbc/ }, no_chdir => 1 }, $find_path); return \@files; } sub find_headers_from_path { - my $class = shift; - my $find_path = shift // "."; + my ($class, $find_path) = @_; + $find_path //= "."; my @files; find( { wanted => sub { push @files, $_ if /\.(?:h|dg)/ }, no_chdir => 1 }, $find_path); diff -r 49d57e7fce39 -r ccc17667ffb2 src/parallel_execution/perlTests/README.md --- a/src/parallel_execution/perlTests/README.md Fri Aug 21 06:35:07 2020 +0900 +++ b/src/parallel_execution/perlTests/README.md Fri Aug 21 08:08:43 2020 +0900 @@ -3,5 +3,5 @@ ## USAGE ``` -$prove -v perlTests -Ilib +$prove -Ilib -v perlTests ``` diff -r 49d57e7fce39 -r ccc17667ffb2 src/parallel_execution/perlTests/util.t --- a/src/parallel_execution/perlTests/util.t Fri Aug 21 06:35:07 2020 +0900 +++ b/src/parallel_execution/perlTests/util.t Fri Aug 21 08:08:43 2020 +0900 @@ -1,10 +1,22 @@ #!/usr/bin/env perl use strict; use warnings; +use FindBin; use Test::More; -use_ok "Gears::Util"; +use_ok "Gears::Util"; #use test + +use Gears::Util; +subtest 'file_checking' => sub { + eval { Gears::Util->file_checking("nonexistent_file.c") }; + ok $@ + && like( $@, qr/invalid filepath/ ); + + my $exists_file = "$FindBin::Bin/README.md"; + my $found_file = Gears::Util->file_checking($exists_file); + is $found_file, $exists_file; +}; done_testing;