From f4b791db8cdc0a54054bbd64c3ac5e8585cb5bca Mon Sep 17 00:00:00 2001 From: "rginda%netscape.com" Date: Fri, 19 Nov 1999 00:56:17 +0000 Subject: [PATCH] HTML output is in, script generally useful. Not tested on win32 or mac yet. git-svn-id: svn://10.0.0.236/trunk@53929 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/js/tests/runtests2.pl | 100 +++++++++++++++++++++++++++++----- 1 file changed, 85 insertions(+), 15 deletions(-) diff --git a/mozilla/js/tests/runtests2.pl b/mozilla/js/tests/runtests2.pl index 4d5223a1bff..98bf81b41f0 100755 --- a/mozilla/js/tests/runtests2.pl +++ b/mozilla/js/tests/runtests2.pl @@ -61,17 +61,15 @@ local $html = ""; local @failed_tests; local $os_type = &get_os_type; local @test_list = &get_test_list; +local $failures_reported = 0; +local $tests_completed = 0; &dd ("output file is '$opt_output_file'"); $SIG{INT} = 'int_handler'; &execute_tests (@test_list); - -&dd ("============================================================="); -&dd ($html); -&dd ("============================================================="); -&dd (join ("\n", @failed_tests)); +&write_results; sub execute_tests { local (@test_list) = @_; @@ -120,8 +118,9 @@ sub execute_tests { foreach $line (@output) { - if ($line =~ /expected\s*exit\s*code\s*\:?\s*(\n+)/i) { + if ($line =~ /expect(ed)?\s*exit\s*code\s*\:?\s*(\n+)/i) { $expected_exit = $1; + &dd ("Test case expects exit code $expect_exit"); } if ($line =~ /failed!/i) { @@ -142,13 +141,63 @@ sub execute_tests { "Complete testcase output was:\n" . join ("\n",reverse(@output))); } elsif ($failure_lines) { - &report_failure ($test, $failure_lines); + &report_failure ($test, "Failure messages were:\n" . $failure_lines); } &dd ("exit code $got_exit, exit signal $exit_signal."); - + + $tests_completed++; } } + +sub write_results { + local $list_name = ($opt_test_list_file) ? + "List '$opt_test_list_file'" : "All tests"; + local ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = + &get_padded_localtime; + + &dd ("Writing output to $opt_output_file."); + + open (OUTPUT, "> $opt_output_file") || + die ("Could not create output file $opt_output_file"); + + print OUTPUT + ("\n" . + "Test results, $opt_engine_type, $list_name\n" . + "\n" . + "\n" . + "\n" . + "

Test results, $opt_engine_type, $list_name


\n" . + "

\n" . + ($#test_list + 1) . "test(s) selected, $tests_completed test(s) " . + "completed, $failures_reported failures reported " . + "(" . (($failures_reported / $tests_completed) * 100) . "% failed)
\n" . + "[ Failure Details | " . + "Retest List | " . + "Test Selection Page ]
\n" . + "


\n" . + "\n" . + "

Failure Details


\n
" . + $html . + "
\n[ Top of Page | " . + "Top of Failures ]
\n" . + "
\n
\n" .
+     "\n" .
+     "

Retest List


\n" . + "# Retest List, $opt_engine_type, " . + "generated $year $mon $mday $hour:$min.\n" . + "# Original test base was: $list_name.\n" . + "# $tests_completed of $#test_list test(s) were completed, " . + "$failures_reported failures reported.\n" . + join ("\n", @failed_tests) . + "
\n" . + "[ Top of Page | " . + "Top of Retest List ]
\n" . + ""); + + close (OUTPUT); + +} sub parse_args { local $option, $value; @@ -543,14 +592,35 @@ sub get_js_files { sub report_failure { local ($test, $message) = @_; - - $test =~ /[^\/]+\/[^\/]+\/[^\/]+$/; + + $failures_reported++; dd ("<> Testcase $test failed:\n$message"); - #$message =~ s/\n/
\n/g; - $html .= "

". - "Testcase $test failed
\n" . - "

$message
"; + + $message =~ s/\n/
\n/g; + $html .= ""; + if ($opt_lxr_url) { + $test =~ /\/?([^\/]+\/[^\/]+\/[^\/]+)$/; + $test = $1; + $html .= "
". + "Testcase $1 " . + "failed
\n"; + } else { + $html .= "
". + "Testcase $test failed
\n"; + } + + $html .= " [ "; + if ($failures_reported > 1) { + $html .= "" . + "Previous Failure | "; + } + + $html .= "" . + "Next Failure | " . + "Top of Page ]
\n" . + "$message
\n"; + @failed_tests[$#failed_tests + 1] = $test; } @@ -567,7 +637,7 @@ sub int_handler { local $resp; do { - print ("\n** User Break: [Q]uit Now, Quit and [R]eport, [C]ontinue ?"); + print ("\n** User Break: Just [Q]uit, Quit and [R]eport, [C]ontinue ?"); $resp = ; } until ($resp =~ /[QqRrCc]/);