summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorYves Orton <demerphq@gmail.com>2023-03-19 18:58:11 +0100
committerYves Orton <demerphq@gmail.com>2023-03-22 02:53:47 +0800
commit03d84c69373359fcef54157b6459b1ce357daf09 (patch)
treecdc0ae3aa36e288809fbef769268dcd9baa3a7d5 /t
parent8312884dcdcc6d91617ebb943c385021054627d0 (diff)
downloadperl-03d84c69373359fcef54157b6459b1ce357daf09.tar.gz
t/TEST - rework poor mans getopt
Less cryptic and repetitive code.
Diffstat (limited to 't')
-rwxr-xr-xt/TEST33
1 files changed, 24 insertions, 9 deletions
diff --git a/t/TEST b/t/TEST
index 7c56a9acb3..bc6b6319bf 100755
--- a/t/TEST
+++ b/t/TEST
@@ -130,21 +130,36 @@ our $show_elapsed_time = $ENV{HARNESS_TIMER} || 0;
# Cheesy version of Getopt::Std. We can't replace it with that, because we
# can't rely on require working.
{
+ my %opt_vars = (
+ benchmark => \$::benchmark,
+ core => \$::core,
+ v => \$::verbose,
+ torture => \$::torture,
+ utf8 => \$::with_utf8,
+ utf16 => \$::with_utf16,
+ taintwarn => \$::taintwarn,
+ );
+
my @argv = ();
foreach my $idx (0..$#ARGV) {
- push( @argv, $ARGV[$idx] ), next unless $ARGV[$idx] =~ /^-(\S+)$/;
- $::benchmark = 1 if $1 eq 'benchmark';
- $::core = 1 if $1 eq 'core';
- $::verbose = 1 if $1 eq 'v';
- $::torture = 1 if $1 eq 'torture';
- $::with_utf8 = 1 if $1 eq 'utf8';
- $::with_utf16 = 1 if $1 eq 'utf16';
- $::taintwarn = 1 if $1 eq 'taintwarn';
- if ($1 =~ /^deparse(,.+)?$/) {
+ my $opt;
+ if ($ARGV[$idx] =~ /^-?-(\S+)$/) {
+ $opt = $1;
+ } else {
+ push @argv, $ARGV[$idx];
+ next;
+ }
+ if (my $ref = $opt_vars{$opt}) {
+ $$ref = 1;
+ }
+ elsif ($opt =~ /^deparse(,.+)?$/) {
$::deparse = 1;
$::deparse_opts = $1;
_process_deparse_config();
}
+ else {
+ die "Unknown option '$opt'\n";
+ }
}
@ARGV = @argv;
}