Project

General

Profile

Bug #1555

Inaccessible 'io' parameter in Test::Unit::UI::Console::TestRunner.initialize(x,y,io)

Added by howardk (Howard Kapustein) over 10 years ago. Updated about 8 years ago.

Status:
Rejected
Priority:
Normal
Assignee:
-
Target version:
ruby -v:
ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32]
[ruby-core:23668]

Description

=begin
Console::TestRunner supports an io parameter to send output to an IO object, but Autorunner has no way to control it!

test/unit/ui/console/testrunner.rb contains the Test::Unit::UI::Console::TestRunnner class with a 3-parm initalizer
But Test::Unit::AutoRunner has no option to specify an alternative destination for io,
and even if it did, run is only called with 2 parameters!

I need to redirect test output to a file, and the console testrunner supports this, but the autorunner machinery doesn't use it. The fix is simple, but requires 2 files to change.

Console::TestRunner defines a 3rd, optional 'io' parameter, obviously meant to support redirecting output to an arbitrary io object.
The autorunner machinery is fine for me (I don't need a whole custom autorunner), but needs an option to direct output elsewhere (e.g. a file). I added a new attribute, output_io, set via the new --output option, and the critical change
def run
...
result.run(@suite, @output_level).passed?
end
to
result.run(@suite, @output_level, @output_io).passed?

But run calls the TestRunner thru Test::Unit::UI::run() - we need to alter test\unit\ui\testrunnerutilities.rb to accept this 3rd parm and pass it along, i.e. change
def run(suite, output_level=NORMAL)
return new(suite, output_level).start
end
to
def run(suite, output_level=NORMAL, io=STDOUT)
return new(suite, output_level, io).start
end

I've attached modified files, diff against 1.8.6 to see the exact changes.

I don't see how Console TestRunner's io parameter is accessible - w/o writing a custom AutoRunner, just to control this one option. A heavyweight solution with ugly maintenance and sync implications. But if I've missed something, by all means, please point it out.
=end


Files

autorunner.rb (7.23 KB) autorunner.rb Add --output option and 3rd parm to run() howardk (Howard Kapustein), 06/02/2009 03:52 PM
testrunnerutilities.rb (1.19 KB) testrunnerutilities.rb Add optional 3rd parm to run() howardk (Howard Kapustein), 06/02/2009 03:52 PM

History

#1

Updated by ujihisa (Tatsuhiro Ujihisa) almost 10 years ago

  • Status changed from Open to Assigned
  • Assignee set to zenspider (Ryan Davis)

=begin

=end

Updated by zenspider (Ryan Davis) about 8 years ago

  • Status changed from Assigned to Open
  • Assignee deleted (zenspider (Ryan Davis))

I don't maintain test/unit.

You might prefer to try minitest, which already supports an io object.

Updated by naruse (Yui NARUSE) about 8 years ago

  • Status changed from Open to Rejected
  • Priority changed from 5 to Normal

1.8 is dying; use 1.9.

Also available in: Atom PDF