File: generate.pl

package info (click to toggle)
thunderbird 1%3A60.9.0-1~deb10u1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 2,339,424 kB
  • sloc: cpp: 5,457,040; ansic: 2,360,385; python: 596,167; asm: 340,963; java: 326,296; xml: 258,830; sh: 84,445; makefile: 23,701; perl: 17,317; objc: 3,768; yacc: 1,766; ada: 1,681; lex: 1,364; pascal: 1,264; cs: 879; exp: 527; php: 436; lisp: 258; ruby: 153; awk: 152; sed: 53; csh: 27
file content (106 lines) | stat: -rw-r--r-- 5,771 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/usr/bin/perl -w
##############################################################################
# W3C Test Suite Generator                                                   #
##############################################################################
package main;
use strict;
use diagnostics;
use XML::Parser; # DEPENDENCY
use lib '.';
use utils::parser;
use utils::helpers;
use utils::generators;

# check arguments
# if argument 1 is '-v' then print out the value of second argument, which will be one of:
#  - DESTINATION_TYPES
#  - SHELL_TYPES
#  - TEST_TYPES

if (scalar(@ARGV) == 1 and ($ARGV[0] eq '-h' or $ARGV[0] eq '--help')) {
    print "Syntax: generateTests.pl -v VARIABLE_NAME or generateTests.pl test1.xml test2,xml ...\n";
    return 0;
} elsif (scalar(@ARGV) > 0 and $ARGV[0] eq '-v') {
    if (scalar(@ARGV) == 2) {
        print $utils::helpers::types{$ARGV[1]};
        exit 0;
    } else {
        my @vars = keys(%utils::helpers::types);
        local $" = '\', \'';
        print "You must specify which variable to display in the form '-v VARIABLE_NAME',\nwhere VARIABLE_NAME is one of '@vars'.\n";
        exit 1;
    }
}

# otherwise, process arguments as filenames:
my %cache = %{&utils::helpers::readCache()};
while (scalar(@ARGV)) {
    # read file
    local $/ = undef;
    my $file = <>;
    close(ARGV);
    # print status
    my $filename = $ARGV;
    $filename =~ s/\.[a-z]+$//o; # remove extension
    print "parsing $filename...\n";
    # process file
    $cache{$filename} = XML::Parser->new(Style => 'utils::parser', Namespaces => 1, ErrorContext => 1)->parse($file);
    die "$filename: modulename/number attributes wrong ('$cache{$filename}->{modulename}-$cache{$filename}->{number}')\n" if $filename ne "$cache{$filename}->{modulename}-$cache{$filename}->{number}";
}
&utils::helpers::writeCache(\%cache);

print "generating tests...\n";
# ...and generate the tests
&utils::generators::generateTopIndex(\%cache); # points to mini test index and all test type indexes
foreach my $destinationType (split ' ', $utils::helpers::types{'DESTINATION_TYPES'}) {
    my @destinationTests = &utils::helpers::shortlistTestsForDestination($destinationType,
                                                                         [ sort {
                                                                             my $na = $cache{$a}->{'number'};
                                                                             my $nb = $cache{$b}->{'number'};
                                                                             for my $n ($na, $nb) {
                                                                                 $n =~ m/^([0-9]*(?:\.[0-9]+)?)/o;
                                                                                 $n = $1;
                                                                             }
                                                                             if (($na ne '') and ($nb ne '')) {
                                                                                 return (($na <=> $nb) or ($cache{$a}->{'number'} cmp $cache{$b}->{'number'}) or ($a cmp $b));
                                                                             } else {
                                                                                 return (($cache{$a}->{'number'} cmp $cache{$b}->{'number'}) or ($a cmp $b));
                                                                             }
                                                                         } keys(%cache) ], \%cache);
    # generate primary index
    &utils::generators::generateSubIndex($destinationType, \@destinationTests, \%cache); # points to mini test index and all test type indexes
    # generate complete mini test index
    &utils::generators::generateMiniTestIndex($destinationType, \@destinationTests, \%cache); # points to all mini tests
    # generate mini tests
    foreach my $testIndex (0..$#destinationTests) {
        # generate mini test and CSS if needed
        &utils::generators::generateMiniTest($destinationType, \@destinationTests, \%cache, $testIndex);
    }
    # generate flat tests and shells
    foreach my $testType (split ' ', $utils::helpers::types{'TEST_TYPES'}) {
        my @finalTestList = &utils::helpers::shortlistTestsForTypes($testType, \@destinationTests, \%cache);
        # generate test type index
        &utils::generators::generateTestTypeIndex($destinationType, $testType, \@finalTestList, \%cache); # points to flat test index and each shell index
        # generate flat test index
        &utils::generators::generateFlatTestIndex($destinationType, $testType, \@finalTestList, \%cache); # points to flat tests
        foreach my $shell (split ' ', $utils::helpers::types{'SHELL_TYPES'}) {
            # generate shell index
            &utils::generators::generateShellTestIndex($destinationType, $testType, $shell, \@finalTestList, \%cache); # points to shell tests
        }
        foreach my $testIndex (0..$#finalTestList) {
            # generate flat test
            &utils::generators::generateFlatTest($destinationType, $testType, \@finalTestList, \%cache, $testIndex);
            foreach my $shell (split ' ', $utils::helpers::types{'SHELL_TYPES'}) {
                # generate shell
                &utils::generators::generateShell($destinationType, $testType, $shell, \@finalTestList, \%cache, $testIndex);
            }
        }
    }
}
# generate latest changes log
foreach my $test (sort { $a->{date} cmp $b->{date} } values %cache) {
  print "$test->{date} ($test->{rev}): $test->{modulename}-$test->{number} - $test->{def}\n";
}
print "done\n";

##############################################################################