2 # Copyright 2002 Patrik Stridvall
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 use vars
qw($VERSION @ISA @EXPORT @EXPORT_OK);
29 @EXPORT_OK = qw($tests);
33 use config qw($current_dir $wine_dir $winapi_dir);
34 use options qw($options);
35 use output qw($output);
38 $Exporter::ExportLevel++;
40 $Exporter::ExportLevel--;
42 $tests = 'tests'->new;
45 sub parse_tests_file($);
49 my $class = ref($proto) || $proto;
51 bless ($self, $class);
53 $self->parse_tests_file();
58 sub parse_tests_file($) {
61 my $file = "tests.dat";
63 my $tests = \%{$self->{TESTS}};
65 $output->lazy_progress($file);
71 open(IN, "< $winapi_dir/$file") || die "$winapi_dir/$file: $!\n";
73 s/^\s*?(.*?)\s*$/$1/; # remove whitespace at beginning and end of line
74 s/^(.*?)\s*#.*$/$1/; # remove comments
75 /^$/ && next; # skip empty lines
77 if (/^%%%\s*(\S+)$/) {
79 } elsif (/^%%\s*(\w+)$/) {
81 } elsif (/^%\s*(\w+)$/) {
84 if (!exists($$tests{$test_dir}{$test}{$section})) {
85 $$tests{$test_dir}{$test}{$section} = [];
87 push @{$$tests{$test_dir}{$test}{$section}}, $_;
89 $output->write("$file:$.: parse error: '$_'\n");
99 my $tests = \%{$self->{TESTS}};
101 my $test_dir = shift;
104 if (defined($test_dir)) {
105 foreach my $test (sort(keys(%{$$tests{$test_dir}}))) {
109 foreach my $test_dir (sort(keys(%$tests))) {
110 foreach my $test (sort(keys(%{$$tests{$test_dir}}))) {
115 return sort(keys(%tests));
118 sub get_test_dirs($$) {
121 my $tests = \%{$self->{TESTS}};
126 if (defined($test)) {
127 foreach my $test_dir (sort(keys(%$tests))) {
128 if (exists($$tests{$test_dir}{$test})) {
129 $test_dirs{$test_dir}++;
133 foreach my $test_dir (sort(keys(%$tests))) {
134 $test_dirs{$test_dir}++;
138 return sort(keys(%test_dirs));
141 sub get_sections($$$) {
144 my $tests = \%{$self->{TESTS}};
146 my $test_dir = shift;
150 if (defined($test_dir)) {
151 if (defined($test)) {
152 foreach my $section (sort(keys(%{$$tests{$test_dir}{$test}}))) {
153 $sections{$section}++;
156 foreach my $test (sort(keys(%{$$tests{$test_dir}}))) {
157 foreach my $section (sort(keys(%{$$tests{$test_dir}{$test}}))) {
158 $sections{$section}++;
162 } elsif (defined($test)) {
163 foreach my $test_dir (sort(keys(%$tests))) {
164 foreach my $section (sort(keys(%{$$tests{$test_dir}{$test}}))) {
165 $sections{$section}++;
169 foreach my $test_dir (sort(keys(%$tests))) {
170 foreach my $test (sort(keys(%{$$tests{$test_dir}}))) {
171 foreach my $section (sort(keys(%{$$tests{$test_dir}{$test}}))) {
172 $sections{$section}++;
178 return sort(keys(%sections));
181 sub get_section($$$$) {
184 my $tests = \%{$self->{TESTS}};
186 my $test_dir = shift;
190 my $array = $$tests{$test_dir}{$test}{$section};
191 if (defined($array)) {