diff --git a/conan/cli/cli.py b/conan/cli/cli.py index 5848c39be07..4961c2e4a8e 100644 --- a/conan/cli/cli.py +++ b/conan/cli/cli.py @@ -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), \ @@ -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): diff --git a/conans/test/integration/package_id/test_default_package_id.py b/conans/test/integration/package_id/test_default_package_id.py index 323c8b48bf7..879befe242c 100644 --- a/conans/test/integration/package_id/test_default_package_id.py +++ b/conans/test/integration/package_id/test_default_package_id.py @@ -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")\ @@ -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) diff --git a/conans/test/utils/tools.py b/conans/test/utils/tools.py index 700224c16f4..c1fd1c01057 100644 --- a/conans/test/utils/tools.py +++ b/conans/test/utils/tools.py @@ -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} @@ -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):