New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Shouldn't rely on result value returned by DRb to be implicitly convertible to integer #382
Conversation
…rn value of run is IO object proxied by DRb::DRbObject
What ruby version are you running? |
Convert value returned by DRb to integer
Thanks for merging this. FWIW I am running JRuby 1.6.1 but I verified Ruby 1.8 and 1.9 to barf in the same way when int-in-IO-in-DRbObject is passed to exit(). |
Still have this problem. Using latest and get error message |
Can you paste the full backtrace? |
iMac:my_project molfar$ bundle exec spork |
RSpec isn't in that backtrace. I'm not sure where to start looking. Maybe it's more of a spork issue? |
Issue num.1 -->> Spork runs ok, but when I run rspec spec/ --drb - I have no output at all. But spork shows that tests had been running. With --no-drb - everything works ok. Issue num.2 -->> The same no output from rspec spec/ --drb. But spork at this time shows error Exception encountered: TypeError: can't convert DRb::DRbObject to Integer (DRb::DRbObject to_int gives DRb::DRbObject). Without drb everything is ok again. No output means |
This sounds like the other drb issue reported this week. It was an issue with rspec-mocks' marshal extension. There's a fix for it in an rspec-mocks PR. I'd include links but I'm on my phone. Sent from my iPhone On Jun 29, 2013, at 1:37 PM, molfar notifications@github.com wrote:
|
I saw that pull request. And yes, branch fix-rspec-core-issue-950 fixes the issue. DRB error has gone away. But why that patch isnt in maaster branch yet? |
We were trying to figure out how to test it to prevent future regressions. Sent from my iPhone On Jun 29, 2013, at 9:07 PM, molfar notifications@github.com wrote:
|
Convert value returned by DRb to integer --- This commit was imported from rspec/rspec-core@c4427b7.
Hi there,
this fixes a problem that occurs when using rspec 2.6.1 together with spork 0.9.0.rc (and possibly other versions). I am mystified why apparently nobody else is running into this issue, but I can reproduce it like so:
Everything works fine, but a "TypeError: can't convert DRb::DRbObject into Integer" will be raised at the very end. Not a big problem but definitely irritating as it makes it harder to see rspec's "X examples, Y failures" output.
I've had a look at both rspec and spork code and here's what I think happens. Spork runs the tests in a forked child process and marshals/unmarshals the test result (an integer in rspec's case) via an IO object to bridge the parent/child process boundary, then passes the IO object back to rspec proxied by a DRb::DRbObject. The combination of DRbObject and IO object prevents an implicit conversion to integer, causing the TypeError to be raised.
At first I was thinking of fixing this issue in spork code, however this is tricky due to spork's generic architecture. Casting the IO object to an integer or even just a string on the spork side of things feels like it's taking away from spork's genericalness. For example, as far as I can tell it would preclude other spork clients from lazy-loading or incrementally loading a large result value.
In comparison, this fix appears to be straightforward and unintrusive, and in line with Postel's Law. Do you agree?
I thought about including a test case but due to the problem occurring at the shell/rspec process boundary under only very specific circumstances I found it hard to come up with a concise one that doesn't complicate things unnecessarily. If you insist on having a test, could somebody give me a hand with it?