-
Notifications
You must be signed in to change notification settings - Fork 339
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
Fix get_plugins() bug #1723
Open
BryceGattis
wants to merge
5
commits into
AcademySoftwareFoundation:main
Choose a base branch
from
BryceGattis:hotfix/fix_get_plugins_empty_dir_error
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Fix get_plugins() bug #1723
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
8683320
Add suggested fix from @mmdanggg2 and add tests
BryceGattis bc9c451
Add type hints to func params
BryceGattis 2d37ebb
Fix wrong type on plugin_for in docs
BryceGattis 482e332
Fix example plugin_for
BryceGattis 7b5b913
Add new test for code coverage
BryceGattis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# Copyright Contributors to the Rez Project | ||
|
||
|
||
""" | ||
Test cases for package_search.py (package searching) | ||
""" | ||
import os | ||
|
||
from rez.package_maker import make_package | ||
from rez.package_search import get_plugins | ||
from rez.tests.util import TestBase, TempdirMixin | ||
|
||
|
||
class TestPackageSearch(TestBase, TempdirMixin): | ||
"""Class for a package searching test case""" | ||
@classmethod | ||
def setUpClass(cls): | ||
TempdirMixin.setUpClass() | ||
|
||
cls.settings = dict( | ||
packages_path=[ | ||
cls.root | ||
] | ||
) | ||
|
||
@classmethod | ||
def tearDownClass(cls): | ||
TempdirMixin.tearDownClass() | ||
|
||
def test_not_has_plugins(self): | ||
"""Ensure empty list is returned when has_plugins is False.""" | ||
|
||
with make_package('foo', self.root) as pkg: | ||
pkg.has_plugins = False | ||
|
||
plugins = get_plugins('foo') | ||
self.assertEqual(plugins, []) | ||
|
||
def test_get_plugins(self): | ||
"""Ensure package plugins are obtained as expected.""" | ||
|
||
with make_package('foo', self.root) as pkg: | ||
pkg.has_plugins = True | ||
|
||
with make_package('foo_plugin', self.root) as pkg: | ||
pkg.plugin_for = ["foo"] | ||
|
||
plugins = get_plugins('foo') | ||
self.assertEqual(plugins, ['foo_plugin']) | ||
|
||
def test_get_plugins_empty_folder(self): | ||
"""When an empty folder is present, plugins should still be valid.""" | ||
|
||
with make_package('foo', self.root) as pkg: | ||
pkg.has_plugins = True | ||
|
||
with make_package('foo_plugin', self.root) as pkg: | ||
pkg.plugin_for = ["foo"] | ||
|
||
os.mkdir(os.path.join(self.root, 'broken_pkg')) | ||
|
||
plugins = get_plugins('foo') | ||
self.assertEqual(plugins, ['foo_plugin']) |
Oops, something went wrong.
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.
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.
I'm wondering if we should instead make sure that
get_latest_package
returns valid packages. The docstring ofget_latest_package
says that it should either return aPackage
object or None is a package is not found. There is also this TODOrez/src/rez/packages.py
Lines 925 to 926 in 71d990b
It my books, that's what I call smell.
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.
In the case of #1618 I would say that get_latest_package is correctly returning None, as there is no valid package in an empty folder. Perhaps then iter_package_families should be more thorough and not return package names if there is no valid package in the folders?