From 08abaf6e18540d4b8bc2fabd143a9ecbc743bea7 Mon Sep 17 00:00:00 2001 From: sergiotarxz Date: Thu, 1 Dec 2022 10:52:20 +0100 Subject: [PATCH] Replacing built in getopt in testrunner for global in build_system.pl --- lib/LPSC/Builder/TestRunner.pm | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/lib/LPSC/Builder/TestRunner.pm b/lib/LPSC/Builder/TestRunner.pm index eafce4f..21d2ae4 100644 --- a/lib/LPSC/Builder/TestRunner.pm +++ b/lib/LPSC/Builder/TestRunner.pm @@ -8,7 +8,7 @@ use warnings; use DB_File; use Params::ValidationCompiler qw/validation_for/; -use Types::Standard qw/ArrayRef Str/; +use Types::Standard qw/ArrayRef Str Bool/; use Getopt::Long::Descriptive; use Path::Tiny qw/path/; @@ -26,7 +26,13 @@ my $ERROR_CODE_SOME_TEST_FAILED = 500; params => { test_files => { 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}; $self->{test_files} = [@$test_files]; + $self->_options->{halt} = $params{halt}; + $self->_options->{clean} = $params{clean}; return $self; } @@ -48,27 +56,10 @@ sub _options { my $self = shift; if ( !defined $self->{options} ) { $self->{options} = {}; - $self->_getopt; } 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 { my $self = shift; if ( $self->_options->{clean} ) {