From 9072d93bb5e9fe520c3e1a7e0a94ae4dc79dccf7 Mon Sep 17 00:00:00 2001 From: jeb228 Date: Fri, 12 Mar 2010 20:52:21 +0000 Subject: [PATCH] NIHVIVO-76 Tweak the output. --- .../acceptance-tests/script/output_manager.rb | 225 +---------------- .../script/output_summary_formatter.rb | 234 +++++++++++++++++- 2 files changed, 239 insertions(+), 220 deletions(-) diff --git a/utilities/acceptance-tests/script/output_manager.rb b/utilities/acceptance-tests/script/output_manager.rb index 7acb1438..a1d8dcc3 100644 --- a/utilities/acceptance-tests/script/output_manager.rb +++ b/utilities/acceptance-tests/script/output_manager.rb @@ -46,10 +46,10 @@ end class Status GOOD = 0 - BAD = 1 - FAIR = 2 + FAIR = 1 + BAD = 2 def self.html_class(status) - return %w{good bad fair}[status] + return %w{good fair bad}[status] end end @@ -91,212 +91,6 @@ class OutputManager FileUtils::copy_file(source, dest) end - # Write the beginning of the summary file. - # This includes the HTML header, and the banner. - # - # f -- a file, already open for output. - # - def write_summary_header(f) - if @osp.overall_status == Status::BAD - overall_status = "FAILURE" - else - overall_status = "SUCCESS" - end - - f.print < - - Summary of Acceptance Tests #{@osp.start_time} - - - - -
- Acceptance test results: 3:45 p.m. March 10, 2010 -
#{overall_status}
-
- -END_HEADER - end - - # Write the first section of the summary file. This section contains - # nested tables with fixed formats, containing overall stats. - # - # f -- a file, already open for output. - # - def write_summary_stats_section(f) - how_many_tests = @osp.tests.length - how_many_pass = 0 - how_many_fail = 0 - how_many_ignore = 0 - @osp.tests.each do |t| - how_many_pass += 1 if t.status == Status::GOOD - how_many_ignore += 1 if t.status == Status::FAIR - how_many_fail += 1 if t.status == Status::BAD - end - - f.print <Summary - - - - - - -
- - - - -
Start time:#{@osp.start_time}
End time#{@osp.end_time}
Elapsed time#{@osp.elapsed_time}
-
- - - - - - -
Suites#{@osp.suites.length}
Total tests#{@osp.tests.length}
Passing tests#{how_many_pass}
Failing tests#{how_many_fail}
Ignored tests#{how_many_ignore}
-
- -END_STATS - end - - # Write a table of failed tests to the summary file, with links - # to the detailed output for each test. - # - # f -- a file, already open for output. - # - def write_summary_failure_section(f) - fails = [] - @osp.tests.each do |t| - fails << t if t.status == Status::BAD - end - - f.print "
Failing tests
\n\n \n" - f.print " \n" - - if fails.empty? - f.print " \n" - f.print " \n" - f.print " \n" - else - fails.each do |t| - f.print " \n" - f.print " \n" - f.print " \n" - f.print " \n" - end - end - - f.print "
Suite nameTest name
No tests failed.
#{t.suite_name}#{t.test_name}
\n\n" - end - - # Write a table of ignored tests to the summary file, with links - # to the detailed output for each test. - # - # f -- a file, already open for output. - # - def write_summary_ignore_section(f) - ignores = [] - @osp.tests.each do |t| - ignores << t if t.status == Status::FAIR - end - - f.print "
Ignored tests
\n\n \n" - f.print " \n" - - if ignores.empty? - f.print " \n" - f.print " \n" - f.print " \n" - else - ignores.each do |t| - f.print " \n" - f.print " \n" - f.print " \n" - f.print " \n" - end - end - - f.print "
Suite nameTest name
No tests ignored.
#{t.suite_name}#{t.test_name}
\n\n" - end - - # Write a table of any error messages or warnings found in the log file. - # - # f -- a file, already open for output. - # - def write_error_messages_section(f) - f.print "
Errors and warnings
\n" - f.print " " - - if @osp.errors.empty? && @osp.warnings.empty? - f.print " " - else - @osp.errors.each() do |e| - f.print " " - end - @osp.warnings.each() do |w| - f.print " " - end - end - f.print "
No errors or warnings
ERROR#{e}
WARN#{w}
\n\n" - end - - # Write a table of the suites to the summary file, with links - # to the detailed output for each suite. - # - # f -- a file, already open for output. - # - def write_summary_suites_section(f) - f.print "
Suites
\n" - f.print " \n" - - @osp.suites.each() do |s| - f.print " \n" - f.print " \n" - f.print " \n" - end - f.print "
#{s.name}
\n\n" - end - - # Write a table of all tests to the summary file, with links - # to the detailed output for each test. - # - # f -- a file, already open for output. - # - def write_summary_all_tests_section(f) - f.print "
All tests
\n\n \n" - f.print " \n" - - if @osp.tests.empty? - f.print " \n" - f.print " \n" - f.print " \n" - else - @osp.tests.each do |t| - f.print " \n" - f.print " \n" - f.print " \n" - f.print " \n" - end - end - - f.print "
Suite nameTest name
No tests.
#{t.suite_name}#{t.test_name}
\n\n" - end - - # Copy the log to the summary file, and close the HTML tags. - # - # f -- a file, already open for output. - # - def write_summary_footer(f) - f.print "
Log
\n
\n"
-    File.open(@log_file) do |log|
-      FileUtils::copy_stream(log, f)
-    end
-    f.print "  
\n\n\n\n" - end - # ------------------------------------------------------------------------------------ public @@ -323,10 +117,14 @@ END_STATS end end + # Where can we find the output for this suite? + # def output_filename(suite_name) File.expand_path("#{suite_name}_output.html", @output_directory) end + # Have we decided to ignore this test if it fails? + # def ignore_test?(suite_name, test_name) false end @@ -339,15 +137,6 @@ END_STATS File.open(@output_summary_file, File::CREAT | File::WRONLY) do |f| osf = OutputSummaryFormatter.new(@osp, @log_file) osf.format(f) - - write_summary_header(f) - write_summary_stats_section(f) - write_error_messages_section(f) - write_summary_failure_section(f) - write_summary_ignore_section(f) - write_summary_suites_section(f) - write_summary_all_tests_section(f) - write_summary_footer(f) end end end \ No newline at end of file diff --git a/utilities/acceptance-tests/script/output_summary_formatter.rb b/utilities/acceptance-tests/script/output_summary_formatter.rb index d7363800..6b38fa1c 100644 --- a/utilities/acceptance-tests/script/output_summary_formatter.rb +++ b/utilities/acceptance-tests/script/output_summary_formatter.rb @@ -32,9 +32,231 @@ class OutputSummaryFormatter private # ------------------------------------------------------------------------------------ # - # Confirm that the output directory parameter is reasonable. + # Write the beginning of the summary file. + # This includes the HTML header, and the banner. # - def sanity_checks_on_parameters() + # f -- a file, already open for output. + # + def write_summary_header(f) + if @osp.overall_status == Status::BAD + status = "FAILURE" + html_class = Status::html_class(Status::BAD) + else + status = "SUCCESS" + html_class = Status::html_class(Status::GOOD) + end + + f.print < + + Summary of Acceptance Tests #{@osp.start_time} + + + + +
+ Acceptance test results: 3:45 p.m. March 10, 2010 +
#{status}
+
+ +END_HEADER + end + + # Write the first section of the summary file. This section contains + # nested tables with fixed formats, containing overall stats. + # + # f -- a file, already open for output. + # + def write_summary_stats_section(f) + how_many_tests = @osp.tests.length + + how_many_pass = 0 + how_many_fail = 0 + how_many_ignore = 0 + @osp.tests.each do |t| + how_many_pass += 1 if t.status == Status::GOOD + how_many_ignore += 1 if t.status == Status::FAIR + how_many_fail += 1 if t.status == Status::BAD + end + + if how_many_pass > 0 + pass_class = Status::html_class(Status::GOOD) + else + pass_class = '' + end + + if how_many_fail > 0 + fail_class = Status::html_class(Status::BAD) + else + fail_class = '' + end + + if how_many_ignore > 0 + ignore_class = Status::html_class(Status::FAIR) + else + ignore_class = '' + end + + f.print <Summary + + + + + + +
+ + + + +
Start time:#{@osp.start_time}
End time#{@osp.end_time}
Elapsed time#{@osp.elapsed_time}
+
+ + + + + + +
Suites#{@osp.suites.length}
Total tests#{@osp.tests.length}
Passing tests#{how_many_pass}
Failing tests#{how_many_fail}
Ignored tests#{how_many_ignore}
+
+ +END_STATS + end + + # Write a table of failed tests to the summary file, with links + # to the detailed output for each test. + # + # f -- a file, already open for output. + # + def write_summary_failure_section(f) + fails = [] + @osp.tests.each do |t| + fails << t if t.status == Status::BAD + end + + f.print "
Failing tests
\n\n \n" + f.print " \n" + + if fails.empty? + f.print " \n" + f.print " \n" + f.print " \n" + else + fails.each do |t| + f.print " \n" + f.print " \n" + f.print " \n" + f.print " \n" + end + end + + f.print "
Suite nameTest name
No tests failed.
#{t.suite_name}#{t.test_name}
\n\n" + end + + # Write a table of ignored tests to the summary file, with links + # to the detailed output for each test. + # + # f -- a file, already open for output. + # + def write_summary_ignore_section(f) + ignores = [] + @osp.tests.each do |t| + ignores << t if t.status == Status::FAIR + end + + f.print "
Ignored tests
\n\n \n" + f.print " \n" + + if ignores.empty? + f.print " \n" + f.print " \n" + f.print " \n" + else + ignores.each do |t| + f.print " \n" + f.print " \n" + f.print " \n" + f.print " \n" + end + end + + f.print "
Suite nameTest name
No tests ignored.
#{t.suite_name}#{t.test_name}
\n\n" + end + + # Write a table of any error messages or warnings found in the log file. + # + # f -- a file, already open for output. + # + def write_error_messages_section(f) + f.print "
Errors and warnings
\n" + f.print " " + + if @osp.errors.empty? && @osp.warnings.empty? + f.print " " + else + @osp.errors.each() do |e| + f.print " " + end + @osp.warnings.each() do |w| + f.print " " + end + end + f.print "
No errors or warnings
ERROR#{e}
WARN#{w}
\n\n" + end + + # Write a table of the suites to the summary file, with links + # to the detailed output for each suite. + # + # f -- a file, already open for output. + # + def write_summary_suites_section(f) + f.print "
Suites
\n" + f.print " \n" + + @osp.suites.each() do |s| + f.print " \n" + f.print " \n" + f.print " \n" + end + f.print "
#{s.name}
\n\n" + end + + # Write a table of all tests to the summary file, with links + # to the detailed output for each test. + # + # f -- a file, already open for output. + # + def write_summary_all_tests_section(f) + f.print "
All tests
\n\n \n" + f.print " \n" + + if @osp.tests.empty? + f.print " \n" + f.print " \n" + f.print " \n" + else + @osp.tests.each do |t| + f.print " \n" + f.print " \n" + f.print " \n" + f.print " \n" + end + end + + f.print "
Suite nameTest name
No tests.
#{t.suite_name}#{t.test_name}
\n\n" + end + + # Copy the log to the summary file, and close the HTML tags. + # + # f -- a file, already open for output. + # + def write_summary_footer(f) + f.print "
Log
\n
\n"
+    File.open(@log_file) do |log|
+      FileUtils::copy_stream(log, f)
+    end
+    f.print "  
\n\n\n\n" end # ------------------------------------------------------------------------------------ @@ -49,5 +271,13 @@ class OutputSummaryFormatter end def format(f) + write_summary_header(f) + write_summary_stats_section(f) + write_error_messages_section(f) + write_summary_failure_section(f) + write_summary_ignore_section(f) + write_summary_suites_section(f) + write_summary_all_tests_section(f) + write_summary_footer(f) end end