Skip to content
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

optimize test #15214

Merged
merged 6 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions conan/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class Cli:
parsing of parameters and delegates functionality to the conan python api. It can also show the
help of the tool.
"""
_builtin_commands = None # Caching the builtin commands, no need to load them over and over

def __init__(self, conan_api):
assert isinstance(conan_api, ConanAPI), \
Expand All @@ -35,10 +36,16 @@ def __init__(self, conan_api):
self._commands = {}

def _add_commands(self):
conan_commands_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "commands")
for module in pkgutil.iter_modules([conan_commands_path]):
module_name = module[1]
self._add_command("conan.cli.commands.{}".format(module_name), module_name)
if Cli._builtin_commands is None:
conan_cmd_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "commands")
for module in pkgutil.iter_modules([conan_cmd_path]):
module_name = module[1]
self._add_command("conan.cli.commands.{}".format(module_name), module_name)
Cli._builtin_commands = self._commands.copy()
else:
self._commands = Cli._builtin_commands.copy()
for k, v in self._commands.items(): # Fill groups data too
self._groups[v.group].append(k)

custom_commands_path = HomePaths(self._conan_api.cache_folder).custom_commands_path
if not os.path.isdir(custom_commands_path):
Expand Down
4 changes: 2 additions & 2 deletions conans/test/integration/package_id/test_default_package_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def test_default_package_id_options(typedep, typeconsumer, different_id):
""" test that some consumer package ids are changed when the dependency change one of its
options
"""
c = TestClient()
c = TestClient(light=True)
dep = GenConanfile("dep", "0.1").with_option("myopt", [True, False]) \
.with_package_type(typedep).with_class_attribute('implements = ["auto_shared_fpic", "auto_header_only"]')
consumer = GenConanfile("consumer", "0.1").with_requires("dep/0.1")\
Expand Down Expand Up @@ -62,7 +62,7 @@ def test_default_package_id_options(typedep, typeconsumer, different_id):
def test_default_package_id_versions(typedep, versiondep, typeconsumer, different_id):
""" test that some consumer package ids are changed when the dependency changes its version
"""
c = TestClient()
c = TestClient(light=True)
dep = GenConanfile("dep").with_package_type(typedep)
consumer = GenConanfile("consumer", "0.1").with_requires("dep/[>0.0]") \
.with_package_type(typeconsumer)
Expand Down
8 changes: 6 additions & 2 deletions conans/test/utils/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ class TestClient(object):

def __init__(self, cache_folder=None, current_folder=None, servers=None, inputs=None,
requester_class=None, path_with_spaces=True,
default_server_user=None):
default_server_user=None, light=False):
"""
current_folder: Current execution folder
servers: dict of {remote_name: TestServer}
Expand Down Expand Up @@ -423,7 +423,11 @@ def __init__(self, cache_folder=None, current_folder=None, servers=None, inputs=
self.inputs = inputs or []

# create default profile
text = default_profiles[platform.system()]
if light:
text = "[settings]\nos=Linux" # Needed at least build-os
save(self.cache.settings_path, "os: [Linux]")
else:
text = default_profiles[platform.system()]
save(self.cache.default_profile_path, text)

def load(self, filename):
Expand Down