From 665c1265cc27662d50f3e2dc09efe28c1e6604e8 Mon Sep 17 00:00:00 2001 From: Nick Gauthier Date: Thu, 25 Mar 2010 12:21:26 -0400 Subject: [PATCH] added listener documentation --- lib/hydra/listener/minimal_output.rb | 4 ++++ lib/hydra/listener/report_generator.rb | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/lib/hydra/listener/minimal_output.rb b/lib/hydra/listener/minimal_output.rb index 9e72dba..9d7c0a4 100644 --- a/lib/hydra/listener/minimal_output.rb +++ b/lib/hydra/listener/minimal_output.rb @@ -4,14 +4,18 @@ module Hydra #:nodoc: # of testing and outputs a ./F/E per file. As well as # full error output, if any. class MinimalOutput < Hydra::Listener::Abstract + # output a starting message def testing_begin(files) @output.write "Hydra Testing:\n#{files.inspect}\n" end + # output a finished message def testing_end @output.write "\nHydra Completed\n" end + # For each file, just output a . for a successful file, or the + # Failure/Error output from the tests def file_end(file, output) @output.write output end diff --git a/lib/hydra/listener/report_generator.rb b/lib/hydra/listener/report_generator.rb index 53e5ae9..01f4fc0 100644 --- a/lib/hydra/listener/report_generator.rb +++ b/lib/hydra/listener/report_generator.rb @@ -2,20 +2,25 @@ module Hydra #:nodoc: module Listener #:nodoc: # Output a textual report at the end of testing class ReportGenerator < Hydra::Listener::Abstract + # Initialize a new report def testing_begin(files) @report = { } end + # Log the start time of a file def file_begin(file) @report[file] ||= { } @report[file]['start'] = Time.now.to_f end + # Log the end time of a file and compute the file's testing + # duration def file_end(file, output) @report[file]['end'] = Time.now.to_f @report[file]['duration'] = @report[file]['end'] - @report[file]['start'] end + # output the report def testing_end YAML.dump(@report, @output) @output.close