Replacing built in getopt in testrunner for global in build_system.pl

This commit is contained in:
sergiotarxz 2022-12-01 10:52:20 +01:00
parent e420cdeaa3
commit 08abaf6e18

View File

@ -8,7 +8,7 @@ use warnings;
use DB_File; use DB_File;
use Params::ValidationCompiler qw/validation_for/; use Params::ValidationCompiler qw/validation_for/;
use Types::Standard qw/ArrayRef Str/; use Types::Standard qw/ArrayRef Str Bool/;
use Getopt::Long::Descriptive; use Getopt::Long::Descriptive;
use Path::Tiny qw/path/; use Path::Tiny qw/path/;
@ -26,7 +26,13 @@ my $ERROR_CODE_SOME_TEST_FAILED = 500;
params => { params => {
test_files => { test_files => {
type => ArrayRef [Str], type => ArrayRef [Str],
} },
clean => {
type => Bool,
},
halt => {
type => Bool,
},
} }
); );
@ -39,6 +45,8 @@ my $ERROR_CODE_SOME_TEST_FAILED = 500;
my $test_files = $params{test_files}; my $test_files = $params{test_files};
$self->{test_files} = [@$test_files]; $self->{test_files} = [@$test_files];
$self->_options->{halt} = $params{halt};
$self->_options->{clean} = $params{clean};
return $self; return $self;
} }
@ -48,27 +56,10 @@ sub _options {
my $self = shift; my $self = shift;
if ( !defined $self->{options} ) { if ( !defined $self->{options} ) {
$self->{options} = {}; $self->{options} = {};
$self->_getopt;
} }
return $self->{options}; return $self->{options};
} }
sub _getopt {
my $self = shift;
my ( $opt, $usage ) = describe_options(
'./test_runner.pl %o',
[ 'clean|c', "Cleans the previously succeded tests", ],
[ 'halt|h', "Halts on error", ],
[],
[ 'help', "print usage message and exit", { shortcircuit => 1 } ],
);
print( $usage->text ), die if $opt->help;
my $options = $self->_options;
$options->{halt} = $opt->halt;
$options->{clean} = $opt->clean;
}
sub run { sub run {
my $self = shift; my $self = shift;
if ( $self->_options->{clean} ) { if ( $self->_options->{clean} ) {