Building on SimonPratt's work:
#!/usr/bin/perl
use strict;
use warnings;
use Getopt::Long;
my $VERBOSE;
my @TESTSUITES;
my %TESTCASES_hash;
my @TESTCASES;
GetOptions (
"testsuite=s" => \@TESTSUITES,
"verbose" => \$VERBOSE
);
# Often it is useful to allow comma-separated lists of values as well
+as multiple occurrences of the options.
@TESTSUITES = split(/\s*,\s*/,join(',', @TESTSUITES));
open my $fh, '<', 'an.ini' or die "Failed to open an.ini for reading:
+$! <$^E>\n";
my (%settings, $head);
while (chomp(my $line = <$fh>)) {
if ($line =~ /^\s*\[([^\[\]]+)\]\s*$/) {
$head = $1;
}
elsif ($line !~ /^\s*$/) {
push @{$settings{$head}}, $line;
}
}
close $fh;
for my $suite (@TESTSUITES){
for my $test (@{$settings{$suite}}){
$TESTCASES_hash{$test}++;
}
}
@TESTCASES = sort keys %TESTCASES_hash;
use Data::Dumper; print Dumper \%settings; print Dumper \@TESTCASES;
for my $testcase (@TESTCASES){
# now iterate through your testcases
}
Which would work like:
./an.pl -t Test_suit_name
./an.pl -t Test_suit_name -t AnotherTest_suit_name
./an.pl -t Test_suit_name,AnotherTest_suit_name
latter two are the same, multiple testsuites are merged to produce a bigger list of testcases.
Hope this extra push in the back helps you... |