From: Dave Thomas Date: 2000-12-30T15:29:42+09:00 Subject: [ruby-talk:8342] Re: open3 woes [sort of long] Holden Glova writes: > Ok, granted my test is set up to fail, but I wrote this simply to > make sure that the correct data was coming to stdout. Why does it > seem to append the entire contents of the file I pass to > RuntimeInterpreter#invoke to itself? Well, I can't reproduce it here: useless.rb class Useless def meth puts "Useless method in a useless class" end end u = Useless.new() u.meth() t.rb require 'open3' class RuntimeInterpreter def invoke(file) streams = Open3.popen3("ruby -w #{file}") streams.at(1).each() { |line| puts line } end end require 'runit/testcase' class Test_RuntimeInterpreter < RUNIT::TestCase def testInvoke interpreter = RuntimeInterpreter.new() result = interpreter.invoke("../useless.rb") assert(result == "Useless method in a useless class") end end if __FILE__ == $0 require 'runit/cui/testrunner' suite = RUNIT::TestSuite.new suite.add_test(Test_RuntimeInterpreter.suite) RUNIT::CUI::TestRunner.run(suite) end dave[~/tmp 0:26:40] ruby t.rb Test_RuntimeInterpreter#testInvoke F. Time: 0.024983 FAILURES!!! Test Results: Run: 1/1(1 asserts) Failures: 1 Errors: 0 Failures: 1 t.rb:21:in `testInvoke': The condition is (RUNIT::AssertionFailedError) from t.rb:30 dave[~/tmp 0:26:44] cat useless.rb class Useless def meth puts "Useless method in a useless class" end end u = Useless.new() u.meth() I ran it several times with the same result. Are you using rubywin? Dave