-while (@ARGV > 0 && $ARGV[0] =~ /^-/)
- {
- my($arg) = shift @ARGV;
- if ($optargs eq '')
- {
- if ($arg eq "-DEBUG") { $debug = 1; $cr = "\n"; next; }
- if ($arg eq "-DIFF") { $cf = "diff -u"; next; }
- if ($arg eq "-CONTINUE"){$force_continue = 1;
- $more = "cat";
- next; }
- if ($arg eq "-UPDATE") { $force_update = 1; next; }
- if ($arg eq "-NOIPV4") { $have_ipv4 = 0; next; }
- if ($arg eq "-NOIPV6") { $have_ipv6 = 0; next; }
- if ($arg eq "-KEEP") { $save_output = 1; next; }
- if ($arg eq "-SLOW") { $slow = 1; next; }
- if ($arg eq "-VALGRIND") { $valgrind = 1; next; }
- if ($arg =~ /^-FLAVOU?R$/) { $flavour = shift; next; }
- }
- $optargs .= " $arg";
- }
+Getopt::Long::Configure qw(no_getopt_compat);
+GetOptions(
+ 'debug' => sub { $debug = 1; $cr = "\n" },
+ 'diff' => sub { $cf = 'diff -u' },
+ 'continue' => sub { $force_continue = 1; $more = 'cat' },
+ 'update' => \$force_update,
+ 'ipv4!' => \$have_ipv4,
+ 'ipv6!' => \$have_ipv6,
+ 'keep' => \$save_output,
+ 'slow' => \$slow,
+ 'valgrind' => \$valgrind,
+ 'range=s{2}' => \my @range_wanted,
+ 'test=i@' => \my @tests_wanted,
+ 'flavor|flavour=s' => \$flavour,
+ 'help' => sub { pod2usage(-exit => 0) },
+ 'man' => sub {
+ pod2usage(
+ -exit => 0,
+ -verbose => 2,
+ -noperldoc => system('perldoc -V 2>/dev/null 1>&2')
+ );
+ },
+) or pod2usage;
+
+($parm_exim, @ARGV) = Exim::Runtest::exim_binary(@ARGV);
+print "Exim binary is `$parm_exim'\n" if defined $parm_exim;
+
+
+my @wanted = sort numerically uniq
+ @tests_wanted ? @tests_wanted : (),
+ @range_wanted ? $range_wanted[0] .. $range_wanted[1] : (),
+ @ARGV ? @ARGV == 1 ? $ARGV[0] :
+ $ARGV[1] eq '+' ? $ARGV[0]..($ARGV[0] >= 9000 ? TEST_SPECIAL_TOP : TEST_TOP) :
+ 0+$ARGV[0]..0+$ARGV[1] # add 0 to cope with test numbers starting with zero
+ : ();
+@wanted = 1..TEST_TOP if not @wanted;