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.
32 # Robert Ginda <rginda@netscape.com>
34 # Second cut at runtests.pl script originally by
35 # Christine Begle (cbegle@netscape.com)
40 use Getopt
::Mixed
"nextOption";
42 my $os_type = &get_os_type
;
43 my $unixish = (($os_type ne "WIN") && ($os_type ne "MAC"));
44 my $path_sep = ($os_type eq "MAC") ? ":" : "/";
45 my $win_sep = ($os_type eq "WIN")? &get_win_sep
: "";
46 my $redirect_command = ($os_type ne "MAC") ? " 2>&1" : "";
48 # command line option defaults
51 my $opt_classpath = "";
52 my $opt_rhino_opt = 0;
55 my $opt_engine_type = "";
56 my $opt_engine_params = "";
57 my $opt_user_output_file = 0;
58 my $opt_output_file = "";
59 my @opt_test_list_files;
60 my @opt_neg_list_files;
61 my $opt_shell_path = "";
62 my $opt_java_path = "";
63 my $opt_bug_url = "http://bugzilla.mozilla.org/show_bug.cgi?id=";
64 my $opt_console_failures = 0;
65 my $opt_lxr_url = "./"; # "http://lxr.mozilla.org/mozilla/source/js/tests/";
66 my $opt_exit_munge = ($os_type ne "MAC") ? 1 : 0;
69 # command line option definition
70 my $options = "a=s arch>a b=s bugurl>b c=s classpath>c e=s engine>e f=s file>f " .
71 "h help>h i j=s javapath>j k confail>k l=s list>l L=s neglist>L " .
72 "o=s opt>o p=s testpath>p s=s shellpath>s t trace>t u=s lxrurl>u " .
75 if ($os_type eq "MAC") {
76 $opt_suite_path = `directory`;
77 $opt_suite_path =~ s/[\n\r]//g;
78 $opt_suite_path .= ":";
80 $opt_suite_path = "./";
86 my ($engine_command, $html, $failures_reported, $tests_completed,
89 my @test_list = &get_test_list
;
91 if ($#test_list == -1) {
92 die ("Nothing to test.\n");
96 # on unix, ^C pauses the tests, and gives the user a chance to quit but
97 # report on what has been done, to just quit, or to continue (the
98 # interrupted test will still be skipped.)
99 # windows doesn't handle the int handler they way we want it to,
100 # so don't even pretend to let the user continue.
101 $SIG{INT
} = 'int_handler';
111 while ($opt_engine_type = pop (@opt_engine_list)) {
112 dd
("Testing engine '$opt_engine_type'");
114 $engine_command = &get_engine_command
;
117 $failures_reported = 0;
118 $tests_completed = 0;
122 &execute_tests
(@test_list);
124 my $exec_time = (time - $start_time);
125 my $exec_hours = int($exec_time / 60 / 60);
126 $exec_time -= $exec_hours * 60 * 60;
127 my $exec_mins = int($exec_time / 60);
128 $exec_time -= $exec_mins * 60;
129 my $exec_secs = ($exec_time % 60);
131 if ($exec_hours > 0) {
132 $exec_time_string = "$exec_hours hours, $exec_mins minutes, " .
133 "$exec_secs seconds";
134 } elsif ($exec_mins > 0) {
135 $exec_time_string = "$exec_mins minutes, $exec_secs seconds";
137 $exec_time_string = "$exec_secs seconds";
140 if (!$opt_user_output_file) {
141 $opt_output_file = &get_tempfile_name
;
150 my (@test_list) = @_;
151 my ($test, $shell_command, $line, @output, $path);
152 my $file_param = " -f ";
153 my ($last_suite, $last_test_dir);
155 # Don't run any shell.js files as tests; they are only utility files
156 @test_list = grep (!/shell\.js$/, @test_list);
158 &status
("Executing " . ($#test_list + 1) . " test(s).");
159 foreach $test (@test_list) {
160 my ($suite, $test_dir, $test_file) = split($path_sep, $test);
161 # *-n.js is a negative test, expect exit code 3 (runtime error)
162 my $expected_exit = ($test =~ /\-n\.js$/) ? 3 : 0;
163 my ($got_exit, $exit_signal);
168 # user selected [Q]uit from ^C handler.
173 # Append the shell.js files to the shell_command if they're there.
174 # (only check for their existance if the suite or test_dir has changed
175 # since the last time we looked.)
176 if ($last_suite ne $suite || $last_test_dir ne $test_dir) {
177 $shell_command = $opt_arch . " ";
179 $shell_command .= &xp_path
($engine_command) . " -s ";
181 $path = &xp_path
($opt_suite_path . $suite . "/shell.js");
183 $shell_command .= $file_param . $path;
186 $path = &xp_path
($opt_suite_path . $suite . "/" .
187 $test_dir . "/shell.js");
189 $shell_command .= $file_param . $path;
192 $last_suite = $suite;
193 $last_test_dir = $test_dir;
196 $path = &xp_path
($opt_suite_path . $test);
198 print ($shell_command . $file_param . $path . "\n");
199 &dd
("executing: " . $shell_command . $file_param . $path);
201 open (OUTPUT
, $shell_command . $file_param . $path .
202 $redirect_command . " |");
206 @output = grep (!/js\>/, @output);
208 if ($opt_exit_munge == 1) {
209 # signal information in the lower 8 bits, exit code above that
210 $got_exit = ($? >> 8);
211 $exit_signal = ($? & 255);
213 # user says not to munge the exit code
222 foreach $line (@output) {
224 # watch for testcase to proclaim what exit code it expects to
225 # produce (0 by default)
226 if ($line =~ /expect(ed)?\s*exit\s*code\s*\:?\s*(\d+)/i) {
228 &dd
("Test case expects exit code $expected_exit");
232 if ($line =~ /failed!/i) {
233 $failure_lines .= $line;
236 # and watch for bugnumbers
237 # XXX This only allows 1 bugnumber per testfile, should be
238 # XXX modified to allow for multiple.
239 if ($line =~ /bugnumber\s*\:?\s*(.*)/i) {
244 # and watch for status
245 if ($line =~ /status/i) {
246 $status_lines .= $line;
252 @output = ("Testcase produced no output!");
255 if ($got_exit != $expected_exit) {
256 # full testcase output dumped on mismatched exit codes,
257 &report_failure
($test, "Expected exit code " .
258 "$expected_exit, got $got_exit\n" .
259 "Testcase terminated with signal $exit_signal\n" .
260 "Complete testcase output was:\n" .
261 join ("\n",@output), $bug_number);
262 } elsif ($failure_lines) {
263 # only offending lines if exit codes matched
264 &report_failure
($test, "$status_lines\n".
265 "Failure messages were:\n$failure_lines",
269 &dd
("exit code $got_exit, exit signal $exit_signal.");
276 my ($list_name, $neglist_name);
277 my $completion_date = localtime;
278 my $failure_pct = int(($failures_reported / $tests_completed) * 10000) /
280 &dd
("Writing output to $opt_output_file.");
282 if ($#opt_test_list_files == -1) {
283 $list_name = "All tests";
284 } elsif ($#opt_test_list_files < 10) {
285 $list_name = join (", ", @opt_test_list_files);
287 $list_name = "($#opt_test_list_files test files specified)";
290 if ($#opt_neg_list_files == -1) {
291 $neglist_name = "(none)";
292 } elsif ($#opt_test_list_files < 10) {
293 $neglist_name = join (", ", @opt_neg_list_files);
295 $neglist_name = "($#opt_neg_list_files skip files specified)";
298 open (OUTPUT
, "> $opt_output_file") ||
299 die ("Could not create output file $opt_output_file");
303 "<title>Test results, $opt_engine_type</title>\n" .
305 "<body bgcolor='white'>\n" .
306 "<a name='tippy_top'></a>\n" .
307 "<h2>Test results, $opt_engine_type</h2><br>\n" .
308 "<p class='results_summary'>\n" .
309 "Test List: $list_name<br>\n" .
310 "Skip List: $neglist_name<br>\n" .
311 ($#test_list + 1) . " test(s) selected, $tests_completed test(s) " .
312 "completed, $failures_reported failures reported " .
313 "($failure_pct% failed)<br>\n" .
314 "Engine command line: $engine_command<br>\n" .
315 "OS type: $os_type<br>\n");
317 if ($opt_engine_type =~ /^rhino/) {
318 open (JAVAOUTPUT
, $opt_java_path . "java -fullversion " .
319 $redirect_command . " |");
320 print OUTPUT
<JAVAOUTPUT
>;
326 ("Testcase execution time: $exec_time_string.<br>\n" .
327 "Tests completed on $completion_date.<br><br>\n");
329 if ($failures_reported > 0) {
331 ("[ <a href='#fail_detail'>Failure Details</a> | " .
332 "<a href='#retest_list'>Retest List</a> | " .
333 "<a href='menu.html'>Test Selection Page</a> ]<br>\n" .
335 "<a name='fail_detail'></a>\n" .
336 "<h2>Failure Details</h2><br>\n<dl>" .
338 "</dl>\n[ <a href='#tippy_top'>Top of Page</a> | " .
339 "<a href='#fail_detail'>Top of Failures</a> ]<br>\n" .
341 "<a name='retest_list'></a>\n" .
342 "<h2>Retest List</h2><br>\n" .
343 "# Retest List, $opt_engine_type, " .
344 "generated $completion_date.\n" .
345 "# Original test base was: $list_name.\n" .
346 "# $tests_completed of " . ($#test_list + 1) .
347 " test(s) were completed, " .
348 "$failures_reported failures reported.\n" .
349 join ("\n", @failed_tests) );
351 # "[ <a href='#tippy_top'>Top of Page</a> | " .
352 # "<a href='#retest_list'>Top of Retest List</a> ]<br>\n");
355 ("<h1>Whoop-de-doo, nothing failed!</h1>\n");
358 #print OUTPUT "</body>";
362 &status
("Wrote results to '$opt_output_file'.");
364 if ($opt_console_failures) {
365 &status
("$failures_reported test(s) failed");
371 my ($option, $value, $lastopt);
373 &dd
("checking command line options.");
375 Getopt
::Mixed
::init
($options);
376 $Getopt::Mixed
::order
= $Getopt::Mixed
::RETURN_IN_ORDER
;
378 while (($option, $value) = nextOption
()) {
380 if ($option eq "a") {
381 &dd
("opt: running with architecture $value.");
383 $opt_arch = "arch -$value";
385 } elsif ($option eq "b") {
386 &dd
("opt: setting bugurl to '$value'.");
387 $opt_bug_url = $value;
389 } elsif ($option eq "c") {
390 &dd
("opt: setting classpath to '$value'.");
391 $opt_classpath = $value;
393 } elsif (($option eq "e") || (($option eq "") && ($lastopt eq "e"))) {
394 &dd
("opt: adding engine $value.");
395 push (@opt_engine_list, $value);
397 } elsif ($option eq "f") {
399 die ("Output file cannot be null.\n");
401 &dd
("opt: setting output file to '$value'.");
402 $opt_user_output_file = 1;
403 $opt_output_file = $value;
405 } elsif ($option eq "h") {
408 } elsif ($option eq "j") {
409 if (!($value =~ /[\/\\]$/)) {
412 &dd
("opt: setting java path to '$value'.");
413 $opt_java_path = $value;
415 } elsif ($option eq "k") {
416 &dd
("opt: displaying failures on console.");
417 $opt_console_failures=1;
419 } elsif ($option eq "l" || (($option eq "") && ($lastopt eq "l"))) {
421 &dd
("opt: adding test list '$value'.");
422 push (@opt_test_list_files, $value);
424 } elsif ($option eq "L" || (($option eq "") && ($lastopt eq "L"))) {
426 &dd
("opt: adding negative list '$value'.");
427 push (@opt_neg_list_files, $value);
429 } elsif ($option eq "o") {
430 $opt_engine_params = $value;
431 &dd
("opt: setting engine params to '$opt_engine_params'.");
433 } elsif ($option eq "p") {
434 $opt_suite_path = $value;
436 if ($os_type eq "MAC") {
437 if (!($opt_suite_path =~ /\:$/)) {
438 $opt_suite_path .= ":";
441 if (!($opt_suite_path =~ /[\/\\]$/)) {
442 $opt_suite_path .= "/";
446 &dd
("opt: setting suite path to '$opt_suite_path'.");
448 } elsif ($option eq "s") {
449 $opt_shell_path = $value;
450 &dd
("opt: setting shell path to '$opt_shell_path'.");
452 } elsif ($option eq "t") {
453 &dd
("opt: tracing output. (console failures at no extra charge.)");
454 $opt_console_failures = 1;
457 } elsif ($option eq "u") {
458 &dd
("opt: setting lxr url to '$value'.");
459 $opt_lxr_url = $value;
461 } elsif ($option eq "x") {
462 &dd
("opt: turning off exit munging.");
473 Getopt
::Mixed
::cleanup
();
475 if ($#opt_engine_list == -1) {
476 die "You must select a shell to test in.\n";
482 # print the arguments that this script expects
486 ("\nusage: $0 [<options>] \n" .
487 "(-a|--arch) <arch> run with a specific architecture on mac\n" .
488 "(-b|--bugurl) Bugzilla URL.\n" .
489 " (default is $opt_bug_url)\n" .
490 "(-c|--classpath) Classpath (Rhino only.)\n" .
491 "(-e|--engine) <type> ... Specify the type of engine(s) to test.\n" .
492 " <type> is one or more of\n" .
493 " (squirrelfish|smopt|smdebug|lcopt|lcdebug|xpcshell|" .
494 "rhino|rhinoi|rhinoms|rhinomsi|rhino9|rhinoms9).\n" .
495 "(-f|--file) <file> Redirect output to file named <file>.\n" .
497 "results-<engine-type>-<date-stamp>.html)\n" .
498 "(-h|--help) Print this message.\n" .
499 "(-j|--javapath) Location of java executable.\n" .
500 "(-k|--confail) Log failures to console (also.)\n" .
501 "(-l|--list) <file> ... List of tests to execute.\n" .
502 "(-L|--neglist) <file> ... List of tests to skip.\n" .
503 "(-o|--opt) <options> Options to pass to the JavaScript engine.\n" .
504 " (Make sure to quote them!)\n" .
505 "(-p|--testpath) <path> Root of the test suite. (default is ./)\n" .
506 "(-s|--shellpath) <path> Location of JavaScript shell.\n" .
507 "(-t|--trace) Trace script execution.\n" .
508 "(-u|--lxrurl) <url> Complete URL to tests subdirectory on lxr.\n" .
509 " (default is $opt_lxr_url)\n" .
510 "(-x|--noexitmunge) Don't do exit code munging (try this if it\n" .
511 " seems like your exit codes are turning up\n" .
512 " as exit signals.)\n");
518 # get the shell command used to start the (either) engine
520 sub get_engine_command
{
524 if ($opt_engine_type eq "rhino") {
525 &dd
("getting rhino engine command.");
528 $retval = &get_rhino_engine_command
;
529 } elsif ($opt_engine_type eq "rhinoi") {
530 &dd
("getting rhinoi engine command.");
533 $retval = &get_rhino_engine_command
;
534 } elsif ($opt_engine_type eq "rhino9") {
535 &dd
("getting rhino engine command.");
538 $retval = &get_rhino_engine_command
;
539 } elsif ($opt_engine_type eq "rhinoms") {
540 &dd
("getting rhinoms engine command.");
543 $retval = &get_rhino_engine_command
;
544 } elsif ($opt_engine_type eq "rhinomsi") {
545 &dd
("getting rhinomsi engine command.");
548 $retval = &get_rhino_engine_command
;
549 } elsif ($opt_engine_type eq "rhinoms9") {
550 &dd
("getting rhinomsi engine command.");
553 $retval = &get_rhino_engine_command
;
554 } elsif ($opt_engine_type eq "xpcshell") {
555 &dd
("getting xpcshell engine command.");
556 $retval = &get_xpc_engine_command
;
557 } elsif ($opt_engine_type =~ /^lc(opt|debug)$/) {
558 &dd
("getting liveconnect engine command.");
559 $retval = &get_lc_engine_command
;
560 } elsif ($opt_engine_type =~ /^sm(opt|debug)$/) {
561 &dd
("getting spidermonkey engine command.");
562 $retval = &get_sm_engine_command
;
563 } elsif ($opt_engine_type =~ /^ep(opt|debug)$/) {
564 &dd
("getting epimetheus engine command.");
565 $retval = &get_ep_engine_command
;
566 } elsif ($opt_engine_type eq "squirrelfish") {
567 &dd
("getting squirrelfish engine command.");
568 $retval = &get_squirrelfish_engine_command
;
570 die ("Unknown engine type selected, '$opt_engine_type'.\n");
573 $retval .= " $opt_engine_params";
575 &dd
("got '$retval'");
582 # get the shell command used to run rhino
584 sub get_rhino_engine_command
{
585 my $retval = $opt_java_path . ($opt_rhino_ms ? "jview " : "java ");
587 if ($opt_shell_path) {
588 $opt_classpath = ($opt_classpath) ?
589 $opt_classpath . ":" . $opt_shell_path :
593 if ($opt_classpath) {
594 $retval .= ($opt_rhino_ms ? "/cp:p" : "-classpath") . " $opt_classpath ";
597 $retval .= "org.mozilla.javascript.tools.shell.Main";
599 if ($opt_rhino_opt) {
600 $retval .= " -opt $opt_rhino_opt";
608 # get the shell command used to run xpcshell
610 sub get_xpc_engine_command
{
612 my $m5_home = @ENV{"MOZILLA_FIVE_HOME"} ||
613 die ("You must set MOZILLA_FIVE_HOME to use the xpcshell" ,
614 (!$unixish) ? "." : ", also " .
615 "setting LD_LIBRARY_PATH to the same directory may get rid of " .
616 "any 'library not found' errors.\n");
618 if (($unixish) && (!@ENV{"LD_LIBRARY_PATH"})) {
619 print STDERR
"-#- WARNING: LD_LIBRARY_PATH is not set, xpcshell may " .
620 "not be able to find the required components.\n";
623 if (!($m5_home =~ /[\/\\]$/)) {
627 $retval = $m5_home . "xpcshell";
629 if ($os_type eq "WIN") {
633 $retval = &xp_path
($retval);
635 if (($os_type ne "MAC") && !(-x
$retval)) {
636 # mac doesn't seem to deal with -x correctly
637 die ($retval . " is not a valid executable on this system.\n");
645 # get the shell command used to run squirrelfish
647 sub get_squirrelfish_engine_command
{
650 if ($opt_shell_path) {
651 # FIXME: Quoting the path this way won't work with paths with quotes in
652 # them. A better fix would be to use the multi-parameter version of
653 # open(), but that doesn't work on ActiveState Perl.
654 $retval = "\"" . $opt_shell_path . "\"";
656 die "Please specify a full path to the squirrelfish testing engine";
663 # get the shell command used to run spidermonkey
665 sub get_sm_engine_command
{
668 # Look for Makefile.ref style make first.
669 # (On Windows, spidermonkey can be made by two makefiles, each putting the
670 # executable in a diferent directory, under a different name.)
672 if ($opt_shell_path) {
673 # if the user provided a path to the shell, return that.
674 $retval = $opt_shell_path;
678 if ($os_type eq "MAC") {
679 $retval = $opt_suite_path . ":src:macbuild:JS";
681 $retval = $opt_suite_path . "../src/";
682 opendir (SRC_DIR_FILES
, $retval);
683 my @src_dir_files = readdir(SRC_DIR_FILES
);
684 closedir (SRC_DIR_FILES
);
686 my ($dir, $object_dir);
687 my $pattern = ($opt_engine_type eq "smdebug") ?
688 'DBG.OBJ' : 'OPT.OBJ';
690 # scan for the first directory matching
691 # the pattern expected to hold this type (debug or opt) of engine
692 foreach $dir (@src_dir_files) {
693 if ($dir =~ $pattern) {
699 if (!$object_dir && $os_type ne "WIN") {
700 die ("Could not locate an object directory in $retval " .
701 "matching the pattern *$pattern. Have you built the " .
705 if (!(-x
$retval . $object_dir . "/js.exe") && ($os_type eq "WIN")) {
706 # On windows, you can build with js.mak as well as Makefile.ref
707 # (Can you say WTF boys and girls? I knew you could.)
708 # So, if the exe the would have been built by Makefile.ref isn't
709 # here, check for the js.mak version before dying.
710 if ($opt_shell_path) {
711 $retval = $opt_shell_path;
712 if (!($retval =~ /[\/\\]$/)) {
716 if ($opt_engine_type eq "smopt") {
717 $retval = "../src/Release/";
719 $retval = "../src/Debug/";
723 $retval .= "jsshell.exe";
726 $retval .= $object_dir . "/js";
727 if ($os_type eq "WIN") {
733 $retval = &xp_path
($retval);
735 } # (user provided a path)
738 if (($os_type ne "MAC") && !(-x
$retval)) {
739 # mac doesn't seem to deal with -x correctly
740 die ($retval . " is not a valid executable on this system.\n");
748 # get the shell command used to run epimetheus
750 sub get_ep_engine_command
{
753 if ($opt_shell_path) {
754 # if the user provided a path to the shell, return that -
755 $retval = $opt_shell_path;
764 $dir = $opt_suite_path . "../../js2/src/";
766 if ($os_type eq "MAC") {
768 # On the Mac, the debug and opt builds lie in the same directory -
774 } elsif ($os_type eq "WIN") {
775 $os = "winbuild/Epimetheus/";
778 $exe = "Epimetheus.exe";
782 $opt = ""; # <<<----- XXX THIS IS NOT RIGHT! CHANGE IT!
787 if ($opt_engine_type eq "epdebug") {
788 $retval = $dir . $os . $debug . $exe;
790 $retval = $dir . $os . $opt . $exe;
793 $retval = &xp_path
($retval);
795 }# (user provided a path)
798 if (($os_type ne "MAC") && !(-x
$retval)) {
799 # mac doesn't seem to deal with -x correctly
800 die ($retval . " is not a valid executable on this system.\n");
807 # get the shell command used to run the liveconnect shell
809 sub get_lc_engine_command
{
812 if ($opt_shell_path) {
813 $retval = $opt_shell_path;
815 if ($os_type eq "MAC") {
816 die "Don't know how to run the lc shell on the mac yet.\n";
818 $retval = $opt_suite_path . "../src/liveconnect/";
819 opendir (SRC_DIR_FILES
, $retval);
820 my @src_dir_files = readdir(SRC_DIR_FILES
);
821 closedir (SRC_DIR_FILES
);
823 my ($dir, $object_dir);
824 my $pattern = ($opt_engine_type eq "lcdebug") ?
825 'DBG.OBJ' : 'OPT.OBJ';
827 foreach $dir (@src_dir_files) {
828 if ($dir =~ $pattern) {
835 die ("Could not locate an object directory in $retval " .
836 "matching the pattern *$pattern. Have you built the " .
840 $retval .= $object_dir . "/";
842 if ($os_type eq "WIN") {
843 $retval .= "lcshell.exe";
845 $retval .= "lcshell";
849 $retval = &xp_path
($retval);
851 } # (user provided a path)
854 if (($os_type ne "MAC") && !(-x
$retval)) {
855 # mac doesn't seem to deal with -x correctly
856 die ("$retval is not a valid executable on this system.\n");
865 if ("\n" eq "\015") {
869 my $uname = `uname -a`;
871 if ($uname =~ /WIN/) {
877 &dd
("get_os_type returning '$uname'.");
886 if ($#opt_test_list_files > -1) {
889 &dd
("getting test list from user specified source.");
891 foreach $list_file (@opt_test_list_files) {
892 push (@test_list, &expand_user_test_list
($list_file));
895 &dd
("no list file, groveling in '$opt_suite_path'.");
897 @test_list = &get_default_test_list
($opt_suite_path);
900 if ($#opt_neg_list_files > -1) {
902 my $orig_size = $#test_list + 1;
903 my $actually_skipped;
905 &dd
("getting negative list from user specified source.");
907 foreach $list_file (@opt_neg_list_files) {
908 push (@neg_list, &expand_user_test_list
($list_file));
911 @test_list = &subtract_arrays
(\
@test_list, \
@neg_list);
913 $actually_skipped = $orig_size - ($#test_list + 1);
915 &dd
($actually_skipped . " of " . $orig_size .
916 " tests will be skipped.");
917 &dd
((($#neg_list + 1) - $actually_skipped) . " skip tests were " .
918 "not actually part of the test list.");
928 # reads $list_file, storing non-comment lines into an array.
929 # lines in the form suite_dir/[*] or suite_dir/test_dir/[*] are expanded
930 # to include all test files under the specified directory
932 sub expand_user_test_list
{
933 my ($list_file) = @_;
937 # Trim off the leading path separator that begins relative paths on the Mac.
938 # Each path will get concatenated with $opt_suite_path, which ends in one.
942 # We will call expand_test_list_entry(), which does pattern-matching on $list_file.
943 # This will make the pattern-matching the same as it would be on Linux/Windows -
945 if ($os_type eq "MAC") {
946 $list_file =~ s/^$path_sep//;
949 if ($list_file =~ /\.js$/ || -d
$opt_suite_path . $list_file) {
951 push (@retval, &expand_test_list_entry
($list_file));
955 open (TESTLIST
, $list_file) ||
956 die("Error opening test list file '$list_file': $!\n");
961 # It's not a comment, so process it
962 push (@retval, &expand_test_list_entry
($_));
976 # Currently expect all paths to be RELATIVE to the top-level tests directory.
977 # One day, this should be improved to allow absolute paths as well -
979 sub expand_test_list_entry
{
983 if ($entry =~ /\.js$/) {
984 # it's a regular entry, add it to the list
985 if (-f
$opt_suite_path . $entry) {
986 push (@retval, $entry);
988 status
("testcase '$entry' not found.");
990 } elsif ($entry =~ /(.*$path_sep[^\*][^$path_sep]*)$path_sep?\*?$/) {
991 # Entry is in the form suite_dir/test_dir[/*]
992 # so iterate all tests under it
993 my $suite_and_test_dir = $1;
994 my @test_files = &get_js_files
($opt_suite_path .
995 $suite_and_test_dir);
998 foreach $i (0 .. $#test_files) {
999 $test_files[$i] = $suite_and_test_dir . $path_sep .
1003 splice (@retval, $#retval + 1, 0, @test_files);
1005 } elsif ($entry =~ /([^\*][^$path_sep]*)$path_sep?\*?$/) {
1006 # Entry is in the form suite_dir[/*]
1007 # so iterate all test dirs and tests under it
1009 my @test_dirs = &get_subdirs
($opt_suite_path . $suite);
1012 foreach $test_dir (@test_dirs) {
1013 my @test_files = &get_js_files
($opt_suite_path . $suite .
1014 $path_sep . $test_dir);
1017 foreach $i (0 .. $#test_files) {
1018 $test_files[$i] = $suite . $path_sep . $test_dir . $path_sep .
1022 splice (@retval, $#retval + 1, 0, @test_files);
1026 die ("Dont know what to do with list entry '$entry'.\n");
1034 # Grovels through $suite_path, searching for *all* test files. Used when the
1035 # user doesn't supply a test list.
1037 sub get_default_test_list
{
1038 my ($suite_path) = @_;
1039 my @suite_list = &get_subdirs
($suite_path);
1043 foreach $suite (@suite_list) {
1044 my @test_dir_list = get_subdirs
($suite_path . $suite);
1047 foreach $test_dir (@test_dir_list) {
1048 my @test_list = get_js_files
($suite_path . $suite . $path_sep .
1052 foreach $test (@test_list) {
1053 $retval[$#retval + 1] = $suite . $path_sep . $test_dir .
1064 # generate an output file name based on the date
1066 sub get_tempfile_name
{
1067 my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =
1068 &get_padded_time
(localtime);
1071 if ($os_type ne "MAC") {
1072 $rv = "results-" . $year . "-" . $mon . "-" . $mday . "-" . $hour .
1073 $min . $sec . "-" . $opt_engine_type;
1075 $rv = "res-" . $year . $mon . $mday . $hour . $min . $sec . "-" .
1079 return $rv . ".html";
1082 sub get_padded_time
{
1083 my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = @_;
1086 $mon = &zero_pad
($mon);
1088 $mday= &zero_pad
($mday);
1089 $sec = &zero_pad
($sec);
1090 $min = &zero_pad
($min);
1091 $hour = &zero_pad
($hour);
1093 return ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst);
1100 $string = ($string < 10) ? "0" . $string : $string;
1104 sub subtract_arrays
{
1105 my ($whole_ref, $part_ref) = @_;
1106 my @whole = @$whole_ref;
1107 my @part = @$part_ref;
1110 foreach $line (@part) {
1111 @whole = grep (!/$line/, @whole);
1119 # Convert unix path to mac style.
1123 my @path_elements = split ("/", $path);
1127 foreach $i (0 .. $#path_elements) {
1128 if ($path_elements[$i] eq ".") {
1129 if (!($rv =~ /\:$/)) {
1132 } elsif ($path_elements[$i] eq "..") {
1133 if (!($rv =~ /\:$/)) {
1138 } elsif ($path_elements[$i] ne "") {
1139 $rv .= $path_elements[$i] . ":";
1150 # Convert unix path to win style.
1155 if ($path_sep ne $win_sep) {
1156 $path =~ s/$path_sep/$win_sep/g;
1163 # Windows shells require "/" or "\" as path separator.
1164 # Find out the one used in the current Windows shell.
1167 my $path = $ENV{"PATH"} || $ENV{"Path"} || $ENV{"path"};
1173 # Convert unix path to correct style based on platform.
1178 if ($os_type eq "MAC") {
1179 return &unix_to_mac
($path);
1180 } elsif($os_type eq "WIN") {
1181 return &unix_to_win
($path);
1191 my @a = split /(\d+)/, $aa;
1192 my @b = split /(\d+)/, $bb;
1197 return $a <=> $b if $a =~ /^\d/ && $b =~ /^\d/ && $a != $b;
1198 return $a cmp $b if $a ne $b;
1205 # given a directory, return an array of all subdirectories
1211 if ($os_type ne "MAC") {
1212 if (!($dir =~ /\/$/)) {
1216 if (!($dir =~ /\:$/)) {
1220 opendir (DIR
, $dir) || die ("couldn't open directory $dir: $!");
1221 my @testdir_contents = sort numericcmp
readdir(DIR
);
1224 foreach (@testdir_contents) {
1225 if ((-d
($dir . $_)) && ($_ ne 'CVS') && ($_ ne '.') && ($_ ne '..')) {
1226 @subdirs[$#subdirs + 1] = $_;
1234 # given a directory, return an array of all the js files that are in it.
1237 my ($test_subdir) = @_;
1238 my (@js_file_array, @subdir_files);
1240 opendir (TEST_SUBDIR
, $test_subdir) || die ("couldn't open directory " .
1241 "$test_subdir: $!");
1242 @subdir_files = sort numericcmp
readdir(TEST_SUBDIR
);
1243 closedir( TEST_SUBDIR
);
1245 foreach (@subdir_files) {
1246 if ($_ =~ /\.js$/) {
1247 $js_file_array[$#js_file_array+1] = $_;
1251 return @js_file_array;
1254 sub report_failure
{
1255 my ($test, $message, $bug_number) = @_;
1258 $failures_reported++;
1260 $message =~ s/\n+/\n/g;
1263 if ($opt_console_failures) {
1265 print STDERR
("*-* Testcase $test failed:\nBug Number $bug_number".
1268 print STDERR
("*-* Testcase $test failed:\n$message\n");
1272 $message =~ s/\n/<br>\n/g;
1273 $html .= "<a name='failure$failures_reported'></a>";
1276 $bug_line = "<a href='$opt_bug_url$bug_number' target='other_window'>".
1277 "Bug Number $bug_number</a>";
1281 $test =~ /\/?([^\
/]+\/[^\
/]+\/[^\
/]+)$/;
1284 "Testcase <a target='other_window' href='$opt_lxr_url$test'>$1</a> " .
1285 "failed</b> $bug_line<br>\n";
1288 "Testcase $test failed</b> $bug_line<br>\n";
1292 if ($failures_reported > 1) {
1293 $html .= "<a href='#failure" . ($failures_reported - 1) . "'>" .
1294 "Previous Failure</a> | ";
1297 $html .= "<a href='#failure" . ($failures_reported + 1) . "'>" .
1298 "Next Failure</a> | " .
1299 "<a href='#tippy_top'>Top of Page</a> ]<br>\n" .
1300 "<tt>$message</tt><br>\n";
1302 @failed_tests[$#failed_tests + 1] = $test;
1309 print ("-*- ", @_ , "\n");
1316 print ("-#- ", @_ , "\n");
1324 print ("\n*** User Break: Just [Q]uit, Quit and [R]eport, [C]ontinue ?");
1326 } until ($resp =~ /[QqRrCc]/);
1328 if ($resp =~ /[Qq]/) {
1329 print ("User Exit. No results were generated.\n");
1331 } elsif ($resp =~ /[Rr]/) {