| 1 |
#!/ns/tools/bin/perl5 |
| 2 |
# This Source Code Form is subject to the terms of the Mozilla Public |
| 3 |
# License, v. 2.0. If a copy of the MPL was not distributed with this |
| 4 |
# file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 5 |
|
| 6 |
|
| 7 |
# mkhtml.pl cruises through your $MOZ_SRC/mozilla/js/tests/ subdirectories, |
| 8 |
# and for any .js file it finds, creates an HTML file that includes: |
| 9 |
# $MOZ_SRC/mozilla/js/tests/$suite/shell.js, $ |
| 10 |
# MOZ_SRC/mozilla/js/tests/$suite/browser.js, |
| 11 |
# and the test.js file. |
| 12 |
# |
| 13 |
# |
| 14 |
|
| 15 |
$moz_src = $ENV{"MOZ_SRC"} || |
| 16 |
die ("You need to set your MOZ_SRC environment variable.\n"); |
| 17 |
|
| 18 |
$test_home = $moz_src ."/js/tests/"; |
| 19 |
|
| 20 |
opendir (TEST_HOME, $test_home); |
| 21 |
@__suites = readdir (TEST_HOME); |
| 22 |
closedir TEST_HOME; |
| 23 |
|
| 24 |
foreach (@__suites ) { |
| 25 |
if ( -d $_ && $_ !~ /\./ && $_ !~ 'CVS' ) { |
| 26 |
$suites[$#suites+1] = $_; |
| 27 |
} |
| 28 |
} |
| 29 |
if ( ! $ARGV[0] ) { |
| 30 |
die ( "Specify a directory: ". join(" ", @suites) ."\n" ); |
| 31 |
} |
| 32 |
|
| 33 |
$js_test_dir = $moz_src . "/js/tests/" . $ARGV[0] ."/"; |
| 34 |
|
| 35 |
print "Generating html files for the tests in $js_test_dir\n"; |
| 36 |
|
| 37 |
$shell_js = $js_test_dir . "shell.js"; |
| 38 |
$browser_js = $js_test_dir . "browser.js"; |
| 39 |
|
| 40 |
# cd to the test directory |
| 41 |
chdir $js_test_dir || |
| 42 |
die "Couldn't chdir to js_test_dir, which is $js_test_dir\n"; |
| 43 |
|
| 44 |
print ( "js_test_dir is $js_test_dir\n" ); |
| 45 |
|
| 46 |
# read the test directory |
| 47 |
opendir ( JS_TEST_DIR, $js_test_dir ); |
| 48 |
# || die "Couldn't open js_test_dir, which is $js_test_dir\n"; |
| 49 |
@js_test_dir_items = readdir( JS_TEST_DIR ); |
| 50 |
# || die "Couldn't read js_test_dir, which is $js_test_dir\n"; |
| 51 |
closedir( JS_TEST_DIR ); |
| 52 |
|
| 53 |
print ("The js_test_dir_items are: " . join( ",", @js_test_dir_items ) . "\n"); |
| 54 |
|
| 55 |
# figure out which of the items are directories |
| 56 |
foreach $js_test_subdir ( @js_test_dir_items ) { |
| 57 |
if ( -d $js_test_subdir ) { |
| 58 |
|
| 59 |
$js_test_subdir = $js_test_dir ."/" . $js_test_subdir; |
| 60 |
chdir $js_test_subdir |
| 61 |
|| die "Couldn't chdir to js_test_subdir $js_test_subdir\n"; |
| 62 |
print "Just chdir'd to $js_test_subdir \n"; |
| 63 |
|
| 64 |
opendir( JS_TEST_SUBDIR, $js_test_subdir ); |
| 65 |
@subdir_tests = readdir( JS_TEST_SUBDIR ); |
| 66 |
closedir( JS_TEST_SUBDIR ); |
| 67 |
|
| 68 |
foreach ( @subdir_tests ) { |
| 69 |
$js_test = $_; |
| 70 |
|
| 71 |
if ( $_ =~ /\.js$/ ) { |
| 72 |
s/\.js$/\.html/; |
| 73 |
print $_ ."\n"; |
| 74 |
open( HTML_TEST, "> $_") |
| 75 |
|| die "Can't open html file $test_html\n"; |
| 76 |
print HTML_TEST |
| 77 |
'<script src=./../shell.js></script>'; |
| 78 |
print HTML_TEST |
| 79 |
'<script src=./../browser.js></script>'; |
| 80 |
print HTML_TEST |
| 81 |
'<script src=./' . $js_test. '></script>'; |
| 82 |
close HTML_TEST; |
| 83 |
} |
| 84 |
} |
| 85 |
} |
| 86 |
chdir $js_test_dir; |
| 87 |
} |
| 88 |
|