Source ostruct from the 0.3.0 gem#6426
Conversation
An updated release of ostruct is available in 0.3.0, so we can start sourcing this from the gem. See ruby/ostruct#11. See jruby#5576. See jruby#6161.
|
@marcandre I am seeing failures in both MRI's tests and in ruby/spec. First I saw this in the MRI 2.6 version of the ostruct test: Updating that to use the test from the gem repo, the failure changes to: CRuby does not fail this, so I will try to dig deeper. However, CRuby fails the spec in exactly the same way. Here's JRuby: And CRuby: I do not know if the MRI suite and ruby/spec failures are related. |
|
It occurs to me now the test_ostruct failure is expecting a specific line in the stack trace, which is likely a behavioral difference on JRuby or a bad test. The spec failure looks like a real issue, though. |
|
The updated test_ostruct.rb passed in CI, so only the spec failure remains. |
|
Thanks for the heads up, I hope to check it out tomorrow |
|
@marcandre Commenting out the additions from ruby/ostruct@683c3d6 appears to make the spec pass. The table instance variable appears to be leaking out as a struct element due to that patch. |
|
Oh sorry, I had it reversed... apparently the spec expects |
ostruct 0.3.0 no longer marshals the "table" key into YAML and instead just marshals the actual key/value attributes it contains. This addresses the remaining failure in jruby#6426.
|
@marcandre I have pushed a spec change that deals with the behavior change in 0.3.0. The version check isn't pretty... some alternatives to this:
When @brixen made the "rubysl" versions of the standard libraries, he moved the specs into those libraries... so that could be considered as a longer-term option, but we'd need a process for keeping the "complete" spec suite in sync. Or would we? I have always considered the library specs to be outside the domain of "Ruby specs" since the language, core, and C ext specs should be sufficient to support any library. If something in library doesn't pass then there's probably a missing or broken language, core, or C ext spec. In any case, I feel like this is more an ostruct behavior than a yaml behavior, so it probably should be moved to an ostruct spec or test. That would excuse or eliminate the extra version-checking and internal knowledge required. |
|
FWIW, my thinking behind moving the specs into the specific gems was that it seemed like the best trade off for modularity. I know it implies some extra complexity somewhere if you want to run the "whole" suite, but like you mention, what does that really mean? You can put a boundary around the core+language specs, but not really around all the possible libraries as the standard library becomes more fluid. Definitely not a simple problem or solution, but I opted for more modularity. |
|
I'm going to merge this. The spec change is not pretty but it seems appropriate since this is new behavior. I still think the spec should be moved into ostruct specs, wherever they live, and we should probably add specs for the "legacy" format being supported on 0.3.0. Looping in @eregon for spec discussion. |
| expected = "--- !ruby/object:OpenStruct\ntable:\n :age: 20\n :name: John\n" | ||
| end | ||
|
|
||
| yaml_dump.should match_yaml(expected) |
One concern is when this is done, the result is often that those specs/tests are not run by Ruby implementations anymore, because it's extra trouble to run them. So if we move stdlib specs to default gem repositories, we need a plan to still run the specs from Ruby implementations, and right now there is no plan and no tooling to do that easily. Feel free to open an issue on https://github.com/ruby/spec with some ideas how to do that. And those specs are still valuable, so I don't want to just remove then. |
Nobody said they should be removed, but their value as part of a conceptual "Ruby spec suite" is dubious. Anything a library spec can prove about a Ruby implementation would be better proven by having a language, core, or C API spec for that behavior. The only thing that library specs (should) prove is that the library behaves according to its own spec. It should not be used as a metric for Ruby compatibility... that's what language, core, and C API specs are for.
Do we? Isn't it sufficient to have those libraries run their CI against the implementations in question? This is how it is for every non-stdlib library out there, and whenever those libraries fail on a given implementation we (ideally) add a "core" spec for whatever behavior was broken. |
|
stdlib (and default gems, they are still part of stdlib just with an extra gemspec) are typically more used than random gems. So tracking compatibility with them more closely directly in language implementations makes sense to me. Also stdlibs are used by almost every Ruby program so IMHO they make sense in terms of Ruby compatibility. Also some of the stdlib/default gems have a different implementation in some Ruby implementations, e.g. tempfile and quite a few more. Ensuring these different implementations are compatible with ruby/spec (+ MRI tests) is what I think is most convenient. For pure-Ruby stdlibs like ostruct, I agree it's less needed. |
An updated release of ostruct is available in 0.3.0, so we can
start sourcing this from the gem.
See ruby/ostruct#11.
See #5576.
See #6161.