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