Use version sort in pyenv versions#2405
Conversation
|
Oops I see that I'm relying on the existence of at least some |
|
|
apparently it's missing inside the CI environment, because it was breaking some bats tests |
|
BTW how do I run the test suite locally? Instead of pushing only to find I've broken more tests. |
|
|
Looks like it's good now! |
native-api
left a comment
There was a problem hiding this comment.
As new functionality, this probably warrants a test.
The problem is the CI environment doesn't have |
It does have |
The tests need to run in systems with both "modern" and "old" Since the new logic only fires with "modern" sort, it's sufficient to mock up a "modern" There is an existing function that mocks an executable, use it as an example. The logic for the mockup can be to just unconditionally output the correct result for the specific set of versions that you make in the test. |
|
Ok, the test passes, but I'm not sure if that's what you meant. If you drop the |
|
Also, I didn't add |
native-api
left a comment
There was a problem hiding this comment.
The test is fine.
Thinking about it though, other tests would fire the code branch that correspond to the system's sort. So we do also need a test for an old sort, likewise mocking it -- or in a modern system, this case would not be tested 😐
|
Well, the mktemp problem is fixed. Now, just to be sure: with the implementation we have right now, if the system doesn't have a modern As you also already said,
this old behavior is already checked in tests like "multiple versions", "indicates current version", "globally selected version", and others in the I understand that maybe explicitly testing the order with another test dedicated for this might be desired; I'd just like to make sure that's what you're asking for. |
The problem is, in those tests, we don't mock anything within the ordering logic. So with a new |
|
Oh ok, that makes sense |
|
Good job. Thank you! |
Considered; implementation is too simple for a plugin.
Is this recommendation still valid? Looks like rbenv's had version sort for months: rbenv/rbenv@28cd6f12
Description
Check if the system
sortcommand supports version sort and, if so, use it.I used
sort --version-sortas discussed in #2097.rbenv's solution does not depend on--version-sort, and would require a little bit more refactoring, but I'd be happy to port it to pyenv if you think it's worth the effort.Tests
Should I add any?