Make the RubyGems test suite green under RUBY_BOX=1 - #9826
Open
hsbt wants to merge 7 commits into
Open
Conversation
Under RUBY_BOX=1 every spawned ruby prints an experimental warning to stderr, which breaks tests asserting on subprocess output. Prepend -W:no-experimental to RUBYOPT for child processes and add a ruby_box_enabled? helper for box-specific guards.
Ruby::Box leaves $? uninitialized, so exit status checks read exit 0 regardless of the real status. Under RUBY_BOX=1 this made Gem::Source::Git#rev_parse swallow git rev-parse failures, and made the cargo availability pend in the test suite misjudge a broken toolchain as usable. Process.last_status reports the real status in both modes.
Ruby::Box gives each box detached copies of the stdio globals, so reassigning or reopening $stdout/$stderr cannot capture output written by Kernel#warn, Kernel#puts or subprocesses, and $VERBOSE = nil cannot silence category warnings in assert_ractor children. Pend the affected tests until https://bugs.ruby-lang.org/issues/21867 is resolved.
Marshal in the main box cannot resolve Gem:: and other boxed constants, so loading dumps of Gem::Specification, Gem::Version or Date raises ArgumentError under RUBY_BOX=1. Pend the affected tests until https://bugs.ruby-lang.org/issues/22090 is resolved.
Requiring rdoc/rdoc makes rdoc's own box resolve its rbs dependency against the faked Gem.paths of the test, so the rbs already activated by the rake process is not reused and the require fails with LoadError.
rdoc 8 requires rbs at runtime, and the first require of rdoc/rdoc from inside a test cannot activate rbs against the faked Gem.paths. That broke TestGemRDoc on rdoc 8 environments with and without RUBY_BOX=1, so replace the Ruby::Box pends with an eager load while the real paths are active.
The suite is green under RUBY_BOX=1 now, so run it on ruby-head as a canary to catch regressions on either side early.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Running the test suite with
RUBY_BOX=1failed 38 tests and errored 18 on ruby master. This makes it green in both modes as the first step of Ruby::Box support in the test suite.The harness now prepends
-W:no-experimentaltoRUBYOPTfor spawned processes, since every child ruby prints the Ruby::Box experimental warning to stderr and breaks assertions on subprocess output. Checks reading$?move toProcess.last_statusbecause Ruby::Box leaves$?uninitialized, which also fixesGem::Source::Git#rev_parseswallowinggit rev-parsefailures at runtime. Tests that capture stdio or round-tripGem::constants throughMarshalare pended under Ruby::Box with references to https://bugs.ruby-lang.org/issues/21867 and https://bugs.ruby-lang.org/issues/22090, and are unaffected in normal runs.TestGemRDocnow preloadsrdoc/rdocbefore the tests fakeGem.paths, which was broken on rdoc 8 environments regardless of Ruby::Box.