From: Holden Glova Date: 2000-12-30T15:44:14+09:00 Subject: [ruby-talk:8343] Re: open3 woes [sort of long] -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Sat, 30 Dec 2000 19:29, I think Dave Thomas wrote: > 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? Nope this is on a Debian GNU Linux. Strange that your output doesn't produe the String from Useless#meth. That is what was happening to me when i was using backquotes `ruby -w #{file} 2>&1`. I'm totally stumped. Would it make any difference the fact that my testcase is in a separate file? I noticed that for some reason this makes a difference for me when i'm using backquotes - - I don't know why, but my it will work just fine if I use backquotes and the test is in the same source file, but move the test into a separate source file and a separate directory and it fails. I'm already bald, yet I find myself constantly reaching for hair to pull out. Please help a desparate bald man :) FWIW: Thanks for taking the time to try and simulate my problem. - -- Signed, Holden Glova -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.4 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE6TYOczrxa+Gy/b/4RAsEhAJ4qAQxRT0BdRTIY3ncgArcYiWFklwCfcdUR FxWp8Xt+z1QlO7F5CvGnHeI= =s9v2 -----END PGP SIGNATURE-----