]>
git.saurik.com Git - apple/javascriptcore.git/blob - tests/mozilla/mklistpage.pl
3 # The contents of this file are subject to the Netscape Public
4 # License Version 1.1 (the "License"); you may not use this file
5 # except in compliance with the License. You may obtain a copy of
6 # the License at http://www.mozilla.org/NPL/
8 # Software distributed under the License is distributed on an "AS
9 # IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
10 # implied. See the License for the specific language governing
11 # rights and limitations under the License.
13 # The Original Code is JavaScript Core Tests.
15 # The Initial Developer of the Original Code is Netscape
16 # Communications Corporation. Portions created by Netscape are
17 # Copyright (C) 1997-1999 Netscape Communications Corporation. All
20 # Alternatively, the contents of this file may be used under the
21 # terms of the GNU Public License (the "GPL"), in which case the
22 # provisions of the GPL are applicable instead of those above.
23 # If you wish to allow use of your version of this file only
24 # under the terms of the GPL and not to allow others to use your
25 # version of this file under the NPL, indicate your decision by
26 # deleting the provisions above and replace them with the notice
27 # and other provisions required by the GPL. If you do not delete
28 # the provisions above, a recipient may use your version of this
29 # file under either the NPL or the GPL.
34 # Creates the meat of a test suite manager page, requites menuhead.html and menufoot.html
35 # to create the complete page. The test suite manager lets you choose a subset of tests
36 # to run under the runtests2.pl script.
39 local $lxr_url = "http://lxr.mozilla.org/mozilla/source/js/tests/";
40 local $suite_path = $ARGV[0] || "./";
41 local $uid = 0; # radio button unique ID
42 local $html = ""; # html output
43 local $javascript = ""; # script output
47 print (&scriptTag
($javascript) . "\n");
51 local $i, @suite_list;
53 if (!($suite_path =~ /\/$/)) {
54 $suite_path = $suite_path . "/";
57 @suite_list = sort(&get_subdirs
($suite_path));
59 $javascript .= "suites = new Object();\n";
61 $html .= "<h3>Test Suites:</h3>\n";
62 $html .= "<center>\n";
63 $html .= " <input type='button' value='Select All' " .
64 "onclick='selectAll();'> ";
65 $html .= " <input type='button' value='Select None' " .
66 "onclick='selectNone();'> ";
69 $html .= "<table border='1'>\n";
70 foreach $suite (@suite_list) {
71 local @readme_text = ("No description available.");
72 if (open (README
, $suite_path . $suite . "/README")) {
73 @readme_text = <README
>;
76 $html .= "<tr><td><a href='\#SUITE_$suite'>$suite</a></td>" .
77 "<td>@readme_text</td>";
78 $html .= "<td><input type='button' value='Select All' " .
79 "onclick='selectAll(\"$suite\");'> ";
80 $html .= "<input type='button' value='Select None' " .
81 "onclick='selectNone(\"$suite\");'></td>";
82 $html .= "<td><input readonly name='SUMMARY_$suite'></td>";
85 $html .= "</table>\n";
86 $html .= "<td><input readonly name='TOTAL'></td>";
90 foreach $i (0 .. $#suite_list) {
91 local $prev_href = ($i > 0) ? "\#SUITE_" . $suite_list[$i - 1] : "";
92 local $next_href = ($i < $#suite_list) ? "\#SUITE_" . $suite_list[$i + 1] : "";
93 &process_suite
($suite_path, $suite_list[$i], $prev_href, $next_href);
101 # Append detail from a 'suite' directory (eg: ecma, ecma_2, js1_1, etc.), calling
102 # process_test_dir for subordinate categories.
105 local ($suite_path, $suite, $prev_href, $next_href) = @_;
106 local $i, @test_dir_list;
109 $javascript .= "suites[\"$suite\"] = {testDirs: {}};\n";
111 @test_dir_list = sort(&get_subdirs
($test_home . $suite));
114 $html .= " <a name='SUITE_$suite'></a><hr><dt><big><big><b>$suite " .
115 "(" . ($#test_dir_list + 1) . " Sub-Categories)</b></big></big><br>\n";
116 $html .= " <input type='button' value='Select All' " .
117 "onclick='selectAll(\"$suite\");'>\n";
118 $html .= " <input type='button' value='Select None' " .
119 "onclick='selectNone(\"$suite\");'> " .
120 "[ <a href='\#top_of_page'>Top of page</a> ";
122 $html .= " | <a href='$prev_href'>Previous Suite</a> ";
125 $html .= " | <a href='$next_href'>Next Suite</a> ";
129 $html .= " <dd>\n <dl>\n";
131 foreach $i (0 .. $#test_dir_list) {
132 local $prev_href = ($i > 0) ? "\#TESTDIR_" . $suite . $test_dir_list[$i - 1] :
134 local $next_href = ($i < $#test_dir_list) ?
135 "\#TESTDIR_" . $suite . $test_dir_list[$i + 1] : "";
136 &process_test_dir
($suite_path . $suite . "/", $test_dir_list[$i], $suite,
137 $prev_href, $next_href);
145 # Append detail from a test directory, calling process_test for subordinate js files
147 sub process_test_dir
{
148 local ($test_dir_path, $test_dir, $suite, $prev_href, $next_href) = @_;
150 @test_list = sort(&get_js_files
($test_dir_path . $test_dir));
152 $javascript .= "suites[\"$suite\"].testDirs[\"$test_dir\"] = {tests: {}};\n";
154 $html .= " <a name='TESTDIR_$suite$test_dir'></a>\n";
155 $html .= " <dt><big><b>$test_dir (" . ($#test_list + 1) .
156 " tests)</b></big><br>\n";
157 $html .= " <input type='button' value='Select All' " .
158 "onclick='selectAll(\"$suite\", \"$test_dir\");'>\n";
159 $html .= " <input type='button' value='Select None' " .
160 "onclick='selectNone(\"$suite\", \"$test_dir\");'> ";
161 $html .= "[ <a href='\#SUITE_$suite'>Top of $suite Suite</a> ";
163 $html .= "| <a href='$prev_href'>Previous Category</a> ";
166 $html .= " | <a href='$next_href'>Next Category</a> ";
173 foreach $test (@test_list) {
174 &process_test
($test_dir_path . $test_dir, $test);
182 # Append detail from a single JavaScript file.
185 local ($test_dir_path, $test) = @_;
190 open (TESTCASE
, $test_dir_path . "/" . $test) ||
191 die ("Error opening " . $test_dir_path . "/" . $test);
194 if (/.*TITLE\s+\=\s+\"(.*)\"/) {
201 $javascript .= "suites[\"$suite\"].testDirs[\"$test_dir\"].tests" .
202 "[\"$test\"] = \"radio$uid\"\n";
203 $html .= " <input type='radio' value='$test' name='radio$uid' ".
204 "onclick='return onRadioClick(\"radio$uid\");'>" .
205 "<a href='$lxr_url$suite/$test_dir/$test' target='other_window'>" .
206 "$test</a> $title<br>\n";
212 return ("<script langugage='JavaScript'>@_</script>");
217 # given a directory, return an array of all subdirectories
223 if (!($dir =~ /\/$/)) {
227 opendir (DIR
, $dir) || die ("couldn't open directory $dir: $!");
228 local @testdir_contents = readdir(DIR
);
231 foreach (@testdir_contents) {
232 if ((-d
($dir . $_)) && ($_ ne 'CVS') && ($_ ne '.') && ($_ ne '..')) {
233 @subdirs[$#subdirs + 1] = $_;
241 # given a directory, return an array of all the js files that are in it.
244 local ($test_subdir) = @_;
245 local @js_file_array;
247 opendir ( TEST_SUBDIR
, $test_subdir) || die ("couldn't open directory " .
249 @subdir_files = readdir( TEST_SUBDIR
);
250 closedir( TEST_SUBDIR
);
252 foreach ( @subdir_files ) {
253 if ( $_ =~ /\.js$/ ) {
254 $js_file_array[$#js_file_array+1] = $_;
258 return @js_file_array;