-
-
Notifications
You must be signed in to change notification settings - Fork 397
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
Update to CodeObjects 'BUILTIN' constants #1005
Conversation
Tests don't seem to be passing on earlier Ruby versions (specs probably need updating), and I see some comment formatting errors. I think we should just start with the added constants to deal with #1003 directly and then open a refactoring PR afterwards if you want to change the coding style so as to not conflate these two changes. |
Sorry about that comment, my damn editor does that (add a 'spacer' line, and it indents the next). Missed it. Re the tests, it seems the only error is related to ClosedQueueError, which is new in 2.3 and not defined in 2.2 or earlier (I've got 2.0, 2.2, 2.3, and 2.4 doc'd). The two tests expect all BUILTIN members to be defined in the running version of Ruby. expect(eval(name)).to be_instance_of(Class)
expect(eval(name)).to be <= Exception
Sorry, I didn't look at the tests, I just saw they passed with Ruby 2.3.2. Also, I've wondered about having multiple versions of Ruby installed, but haven't yet done so. You use Windows? If so, reasonably easy to set up that way? |
We need to fix the tests to be lenient regarding missing constants on older versions or the tests will not pass. Use a string array for now, if you want to refactor, I can look at that separately. As for running tests, you should be able to see Travis output on your own fork if you set it up. If you want to run locally, I'd recommend installing Docker and just running: > docker run -v %CD%:/yard -w /yard ruby:2.2 /bin/sh -c "bundle && bundle exec rake" You can build a docker image with the installed gem dependencies if you test a lot (to avoid bundle installing). |
FYI, I checked for what's added from the previous code, re RSpec, and came up with the following (ClosedQueueError just happens to be on both lists and is the 1st addition alphabetically) -- new Exception Classes ClosedQueueError
EncodingError
FiberError
KeyError
StopIteration
UncaughtThrowError new Classes Complex
ConditionVariable
Encoding
Enumerator
Fiber
Queue
Random
RubyVM
SizedQueue
TracePoint |
@lsegal I'm having a bad git day (stack patch). IMHO, git docs (git-scm, etc) are very good when they address working with one's own repro and a remote origin, but they get sketchy when dealing with forks, etc, especially how to have multiple PR's open between a local fork, a remote origin, and the original repo. I should have never used the master branch for these commits/PR... Anyway,
I'm looking over some of the Ruby 2.4 docs, I suspect we need the tests to work both ways, as there may be Classes/Exceptions/Modules that might be deprecated or removed in future versions. Also, the tests currently fail on first failure, it would be nice if they loaded an array with all failures and then tested whether the array was empty, hence, showing all failures, not just the first. |
I strongly doubt any class in Ruby will ever go away, regardless of how "deprecated" it is (technically none of those are even deprecated yet). It's fairly safe to keep any existing constant in the tests. Given that it's only a testing functionality (YARD doesn't eval these during runtime), any failures would be caught as we move Travis to new Ruby versions. A RUBY_VERSION check for new constants can be used to exclude the new constants, and same for old ones: describe 'Ruby 2.4+ constants' do
it '...' { ... }
end if RUBY_VERSION >= '2.4'
I'd accept this change. Moving the class loop outside of the it() declaration (one it() block per class) would fix this. |
I'm currently working on this. So we'll list constants for 2.3, and test for earlier and later. Reason for later - |
Running tests on Travis against 2.0 and 2.1 is difficult now with dependency changes (like Rack, etc). Given the EOL for both versions, I'm okay with stopping at a "best effort" to ensure compatibility, and if regressions occur, we can accept patches to fix them. The burden on maintaining CI against those old versions is too high. |
@lsegal Eight days ago I was looking at this, but I moved to other issues. Can we revisit this? I've never closed a PR, if I do so, does that flush everything out? Again, apology for PR'ing on the main branch. I'd like to PR the stack |
YARD::CodeObjects::BUILTIN_EXCEPTIONS.each do |name| | ||
expect(eval(name)).to be <= Exception | ||
next if name == 'ClosedQueueError' && RUBY_VERSION < '2.3' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of manually mapping out constants (this will be a headache to maintain), why not just ignore any constant that does not exist? A NameError rescue should suffice.
@MSP-Greg I added some comments, but this also needs the commit history cleaned up. You can rebase and force push your branch after you clean it up so that you don't have to close the PR and open a new one. Ideally this should only require 1 single commit. |
* Tested and passed locally against 2.2.4 & 2.3.2. * Removed `Continuation` from `BUILTIN_CLASSES`, it's very similar to `ARGF` & `ENV`, no constructor, fails Module.constants.include?(:Continuation), and all doc examples show `require "continuation"` * Removed `MatchingData`, it's a left-over from before 2.0 * Added a bad class for testing, failed tests do show the full array...
Thank you for the Git tips. I generally don't forget once I've done something. |
Looks good, thanks! |
Description
Per #1003. Additionally, I decided to update all three,
BUILTIN_EXCEPTIONS
,BUILTIN_CLASSES
, andBUILTIN_MODULES
.MatchingData
inBUILTIN_CLASSES
BUILTIN_CLASSES
still doesn't containARGF
&ENV
, both fail RSpecCompleted Tasks