diff --git a/conan/api/output.py b/conan/api/output.py index 79b07bab18e..f2701b396a6 100644 --- a/conan/api/output.py +++ b/conan/api/output.py @@ -139,7 +139,7 @@ def json_encoder(_obj): else: ret = "{}: ".format(self._scope) - if self._color and not self._scope: + if self._color: ret += "{}{}{}{}".format(fg or '', bg or '', msg, Style.RESET_ALL) else: ret += "{}".format(msg) @@ -170,6 +170,12 @@ def status(self, msg, fg=None, bg=None): info = status def title(self, msg): + if log_level_allowed(LEVEL_NOTICE): + self._write_message("\n======== {} ========".format(msg), "NOTICE", + fg=Color.BRIGHT_MAGENTA) + return self + + def subtitle(self, msg): if log_level_allowed(LEVEL_NOTICE): self._write_message("\n-------- {} --------".format(msg), "NOTICE", fg=Color.BRIGHT_MAGENTA) diff --git a/conan/api/subapi/export.py b/conan/api/subapi/export.py index 07c378c2314..e122f765a34 100644 --- a/conan/api/subapi/export.py +++ b/conan/api/subapi/export.py @@ -11,6 +11,7 @@ def __init__(self, conan_api): self.conan_api = conan_api def export(self, path, name, version, user, channel, lockfile=None, remotes=None): + ConanOutput().title("Exporting recipe to the cache") app = ConanApp(self.conan_api.cache_folder) return cmd_export(app, path, name, version, user, channel, graph_lock=lockfile, remotes=remotes) diff --git a/conan/api/subapi/graph.py b/conan/api/subapi/graph.py index 74a3c4f2113..0c886a95de7 100644 --- a/conan/api/subapi/graph.py +++ b/conan/api/subapi/graph.py @@ -2,7 +2,6 @@ from conan.api.output import ConanOutput from conan.internal.conan_app import ConanApp -from conan.cli.printers.graph import print_graph_basic from conans.client.graph.graph import Node, RECIPE_CONSUMER, CONTEXT_HOST, RECIPE_VIRTUAL from conans.client.graph.graph_binaries import GraphBinariesAnalyzer from conans.client.graph.graph_builder import DepsGraphBuilder @@ -110,24 +109,16 @@ def _scope_options(profile, requires, tool_requires): profile.options.scope(tool_requires[0]) def load_graph_requires(self, requires, tool_requires, profile_host, profile_build, - lockfile, remotes, update, check_updates=False, allow_error=False): + lockfile, remotes, update, check_updates=False): requires = [RecipeReference.loads(r) if isinstance(r, str) else r for r in requires] \ if requires else None tool_requires = [RecipeReference.loads(r) if isinstance(r, str) else r for r in tool_requires] if tool_requires else None - out = ConanOutput() - out.title("Input profiles") - out.info("Profile host:") - out.info(profile_host.dumps()) - out.info("Profile build:") - out.info(profile_build.dumps()) - self._scope_options(profile_host, requires=requires, tool_requires=tool_requires) root_node = self._load_root_virtual_conanfile(requires=requires, tool_requires=tool_requires, profile_host=profile_host) - out.title("Computing dependency graph") # check_updates = args.check_updates if "check_updates" in args else False deps_graph = self.load_graph(root_node, profile_host=profile_host, profile_build=profile_build, @@ -135,40 +126,20 @@ def load_graph_requires(self, requires, tool_requires, profile_host, profile_bui remotes=remotes, update=update, check_update=check_updates) - print_graph_basic(deps_graph) - if deps_graph.error: - if allow_error: - return deps_graph - raise deps_graph.error - return deps_graph def load_graph_consumer(self, path, name, version, user, channel, profile_host, profile_build, lockfile, remotes, update, - allow_error=False, check_updates=False, is_build_require=False): - out = ConanOutput() - out.title("Input profiles") - out.info("Profile host:") - out.info(profile_host.dumps()) - out.info("Profile build:") - out.info(profile_build.dumps()) - + check_updates=False, is_build_require=False): root_node = self._load_root_consumer_conanfile(path, profile_host, profile_build, name=name, version=version, user=user, channel=channel, lockfile=lockfile, remotes=remotes, update=update, is_build_require=is_build_require) - out.title("Computing dependency graph") deps_graph = self.load_graph(root_node, profile_host=profile_host, profile_build=profile_build, lockfile=lockfile, remotes=remotes, update=update, check_update=check_updates) - print_graph_basic(deps_graph) - if deps_graph.error: - if allow_error: - return deps_graph - raise deps_graph.error - return deps_graph def load_graph(self, root_node, profile_host, profile_build, lockfile=None, remotes=None, @@ -189,6 +160,7 @@ def load_graph(self, root_node, profile_host, profile_build, lockfile=None, remo revisions for already existing recipes in the Conan cache :param check_update: For "graph info" command, check if there are recipe updates """ + ConanOutput().title("Computing dependency graph") app = ConanApp(self.conan_api.cache_folder) assert profile_host is not None diff --git a/conan/cli/commands/build.py b/conan/cli/commands/build.py index cafb4a14b31..c28f376a45b 100644 --- a/conan/cli/commands/build.py +++ b/conan/cli/commands/build.py @@ -5,7 +5,7 @@ from conan.cli.commands import make_abs_path from conan.cli.args import add_lockfile_args, add_common_install_arguments, add_reference_args from conan.internal.conan_app import ConanApp -from conan.cli.printers.graph import print_graph_packages +from conan.cli.printers.graph import print_graph_packages, print_graph_basic from conans.client.conanfile.build import run_build_method @@ -41,7 +41,8 @@ def build(conan_api, parser, *args): args.user, args.channel, profile_host, profile_build, lockfile, remotes, args.update) - + print_graph_basic(deps_graph) + deps_graph.report_graph_error() conan_api.graph.analyze_binaries(deps_graph, args.build, remotes=remotes, update=args.update, lockfile=lockfile) print_graph_packages(deps_graph) diff --git a/conan/cli/commands/create.py b/conan/cli/commands/create.py index 7b25072d3ae..ebad8477822 100644 --- a/conan/cli/commands/create.py +++ b/conan/cli/commands/create.py @@ -6,8 +6,9 @@ from conan.cli.command import conan_command, OnceArgument from conan.cli.commands.export import common_args_export from conan.cli.args import add_lockfile_args, add_common_install_arguments +from conan.cli.printers import print_profiles from conan.internal.conan_app import ConanApp -from conan.cli.printers.graph import print_graph_packages +from conan.cli.printers.graph import print_graph_packages, print_graph_basic from conans.client.conanfile.build import run_build_method from conans.errors import ConanException, conanfile_exception_formatter from conans.util.files import chdir, mkdir @@ -45,8 +46,6 @@ def create(conan_api, parser, *args): remotes = conan_api.remotes.list(args.remote) if not args.no_remote else [] profile_host, profile_build = conan_api.profiles.get_profiles_from_args(args) - out = ConanOutput() - out.highlight("Exporting the recipe") ref, conanfile = conan_api.export.export(path=path, name=args.name, version=args.version, user=args.user, channel=args.channel, @@ -57,11 +56,7 @@ def create(conan_api, parser, *args): lockfile = conan_api.lockfile.update_lockfile_export(lockfile, conanfile, ref, args.build_require) - out.title("Input profiles") - out.info("Profile host:") - out.info(profile_host.dumps()) - out.info("Profile build:") - out.info(profile_build.dumps()) + print_profiles(profile_host, profile_build) deps_graph = None if not is_python_require: @@ -69,22 +64,20 @@ def create(conan_api, parser, *args): requires = [ref] if not args.build_require else None tool_requires = [ref] if args.build_require else None - out.title("Computing dependency graph") deps_graph = conan_api.graph.load_graph_requires(requires, tool_requires, profile_host=profile_host, profile_build=profile_build, lockfile=lockfile, remotes=remotes, update=args.update) + print_graph_basic(deps_graph) deps_graph.report_graph_error() - out.title("Computing necessary packages") # Not specified, force build the tested library build_modes = [ref.repr_notime()] if args.build is None else args.build conan_api.graph.analyze_binaries(deps_graph, build_modes, remotes=remotes, update=args.update, lockfile=lockfile) print_graph_packages(deps_graph) - out.title("Installing packages") conan_api.install.install_binaries(deps_graph=deps_graph, remotes=remotes) # We update the lockfile, so it will be updated for later ``test_package`` lockfile = conan_api.lockfile.update_lockfile(lockfile, deps_graph, args.lockfile_packages, @@ -146,7 +139,7 @@ def test_package(conan_api, deps_graph, test_conanfile_path, tested_python_requi conanfile.folders.set_base_package(conanfile.folders.base_build) run_build_method(conanfile, app.hook_manager) - out.title("Testing the package: Running test()") + out.title("Testing the package: Executing test") conanfile.output.highlight("Running test()") with conanfile_exception_formatter(conanfile, "test"): with chdir(conanfile.build_folder): diff --git a/conan/cli/commands/export.py b/conan/cli/commands/export.py index 4fbb1634968..1c555c0b022 100644 --- a/conan/cli/commands/export.py +++ b/conan/cli/commands/export.py @@ -1,7 +1,7 @@ import json import os -from conan.api.output import ConanOutput, cli_out_write +from conan.api.output import cli_out_write from conan.cli.command import conan_command, OnceArgument from conan.cli.args import add_reference_args @@ -51,5 +51,4 @@ def export(conan_api, parser, *args): lockfile = conan_api.lockfile.update_lockfile_export(lockfile, conanfile, ref, args.build_require) conan_api.lockfile.save_lockfile(lockfile, args.lockfile_out, cwd) - ConanOutput().success("Exported recipe: {}".format(ref.repr_humantime())) return ref diff --git a/conan/cli/commands/export_pkg.py b/conan/cli/commands/export_pkg.py index 86cb19a7a6b..297775589c0 100644 --- a/conan/cli/commands/export_pkg.py +++ b/conan/cli/commands/export_pkg.py @@ -6,6 +6,7 @@ from conan.cli.args import add_lockfile_args, add_profiles_args, add_reference_args from conan.cli.commands import make_abs_path from conan.cli.commands.create import _get_test_conanfile_path +from conan.cli.printers.graph import print_graph_basic def json_export_pkg(info): @@ -54,6 +55,7 @@ def export_pkg(conan_api, parser, *args): lockfile=lockfile, remotes=None, update=None, is_build_require=args.build_require) + print_graph_basic(deps_graph) deps_graph.report_graph_error() conan_api.graph.analyze_binaries(deps_graph, build_mode=[ref.name], lockfile=lockfile) deps_graph.report_graph_error() diff --git a/conan/cli/commands/graph.py b/conan/cli/commands/graph.py index 8f629df3905..5406fce410e 100644 --- a/conan/cli/commands/graph.py +++ b/conan/cli/commands/graph.py @@ -1,8 +1,8 @@ import json import os -from conan.api.output import ConanOutput, cli_out_write -from conan.cli.printers.graph import print_graph_packages +from conan.api.output import ConanOutput, cli_out_write, Color +from conan.cli.printers.graph import print_graph_packages, print_graph_basic from conan.internal.deploy import do_deploys from conan.cli.command import conan_command, conan_subcommand from conan.cli.commands import make_abs_path @@ -144,15 +144,17 @@ def graph_info(conan_api, parser, subparser, *args): args.user, args.channel, profile_host, profile_build, lockfile, remotes, args.update, - allow_error=True, check_updates=args.check_updates) else: deps_graph = conan_api.graph.load_graph_requires(args.requires, args.tool_requires, profile_host, profile_build, lockfile, remotes, args.update, - allow_error=True, check_updates=args.check_updates) - if not deps_graph.error: + print_graph_basic(deps_graph) + if deps_graph.error: + ConanOutput().info("Graph error", Color.BRIGHT_RED) + ConanOutput().info(" {}".format(deps_graph.error), Color.BRIGHT_RED) + else: conan_api.graph.analyze_binaries(deps_graph, args.build, remotes=remotes, update=args.update, lockfile=lockfile) print_graph_packages(deps_graph) diff --git a/conan/cli/commands/install.py b/conan/cli/commands/install.py index c227429c0f0..17c467ffb85 100644 --- a/conan/cli/commands/install.py +++ b/conan/cli/commands/install.py @@ -5,7 +5,8 @@ from conan.cli.args import common_graph_args from conan.cli.command import conan_command from conan.cli.commands import make_abs_path -from conan.cli.printers.graph import print_graph_packages +from conan.cli.printers import print_profiles +from conan.cli.printers.graph import print_graph_packages, print_graph_basic from conans.errors import ConanException @@ -67,6 +68,7 @@ def install(conan_api, parser, *args): cwd=cwd, partial=args.lockfile_partial) profile_host, profile_build = conan_api.profiles.get_profiles_from_args(args) + print_profiles(profile_host, profile_build) if path: deps_graph = conan_api.graph.load_graph_consumer(path, args.name, args.version, args.user, args.channel, @@ -76,12 +78,13 @@ def install(conan_api, parser, *args): deps_graph = conan_api.graph.load_graph_requires(args.requires, args.tool_requires, profile_host, profile_build, lockfile, remotes, args.update) + print_graph_basic(deps_graph) + deps_graph.report_graph_error() conan_api.graph.analyze_binaries(deps_graph, args.build, remotes=remotes, update=args.update, lockfile=lockfile) print_graph_packages(deps_graph) out = ConanOutput() - out.title("Installing packages") conan_api.install.install_binaries(deps_graph=deps_graph, remotes=remotes) out.title("Finalizing install (deploy, generators)") @@ -92,6 +95,7 @@ def install(conan_api, parser, *args): deploy=args.deploy ) + out.success("Install finished succesfully") lockfile = conan_api.lockfile.update_lockfile(lockfile, deps_graph, args.lockfile_packages, clean=args.lockfile_clean) conan_api.lockfile.save_lockfile(lockfile, args.lockfile_out, cwd) diff --git a/conan/cli/commands/lock.py b/conan/cli/commands/lock.py index 3a9c73501d1..9093ae1acb1 100644 --- a/conan/cli/commands/lock.py +++ b/conan/cli/commands/lock.py @@ -4,7 +4,7 @@ from conan.cli.command import conan_command, OnceArgument, conan_subcommand from conan.cli.commands import make_abs_path from conan.cli.args import common_graph_args -from conan.cli.printers.graph import print_graph_packages +from conan.cli.printers.graph import print_graph_packages, print_graph_basic from conans.errors import ConanException from conans.model.graph_lock import Lockfile, LOCKFILE from conans.model.recipe_ref import RecipeReference @@ -47,6 +47,8 @@ def lock_create(conan_api, parser, subparser, *args): profile_host, profile_build, lockfile, remotes, args.build, args.update) + print_graph_basic(graph) + graph.report_graph_error() conan_api.graph.analyze_binaries(graph, args.build, remotes=remotes, update=args.update, lockfile=lockfile) print_graph_packages(graph) diff --git a/conan/cli/commands/test.py b/conan/cli/commands/test.py index 398467441e3..dd4bfc103ec 100644 --- a/conan/cli/commands/test.py +++ b/conan/cli/commands/test.py @@ -4,6 +4,7 @@ from conan.cli.command import conan_command, OnceArgument from conan.cli.commands.create import test_package, _check_tested_reference_matches from conan.cli.args import add_lockfile_args, add_common_install_arguments +from conan.cli.printers import print_profiles from conan.cli.printers.graph import print_graph_basic, print_graph_packages from conans.model.recipe_ref import RecipeReference @@ -31,12 +32,7 @@ def test(conan_api, parser, *args): remotes = conan_api.remotes.list(args.remote) if not args.no_remote else [] profile_host, profile_build = conan_api.profiles.get_profiles_from_args(args) - out = ConanOutput() - out.title("Input profiles") - out.info("Profile host:") - out.info(profile_host.dumps()) - out.info("Profile build:") - out.info(profile_build.dumps()) + print_profiles(profile_host, profile_build) deps_graph = run_test(conan_api, path, ref, profile_host, profile_build, remotes, lockfile, args.update, build_modes=args.build) @@ -55,7 +51,7 @@ def run_test(conan_api, path, ref, profile_host, profile_build, remotes, lockfil tested_python_requires=tested_python_requires) out = ConanOutput() - out.title("test_package: Computing dependency graph") + out.title("Launching test_package") deps_graph = conan_api.graph.load_graph(root_node, profile_host=profile_host, profile_build=profile_build, lockfile=lockfile, @@ -63,13 +59,12 @@ def run_test(conan_api, path, ref, profile_host, profile_build, remotes, lockfil update=update, check_update=update) print_graph_basic(deps_graph) - out.title("test_package: Computing necessary packages") deps_graph.report_graph_error() + conan_api.graph.analyze_binaries(deps_graph, build_modes, remotes=remotes, update=update, lockfile=lockfile) print_graph_packages(deps_graph) - out.title("test_package: Installing packages") conan_api.install.install_binaries(deps_graph=deps_graph, remotes=remotes) _check_tested_reference_matches(deps_graph, ref, out) test_package(conan_api, deps_graph, path, tested_python_requires) diff --git a/conan/cli/printers/__init__.py b/conan/cli/printers/__init__.py index e69de29bb2d..8a906696c29 100644 --- a/conan/cli/printers/__init__.py +++ b/conan/cli/printers/__init__.py @@ -0,0 +1,10 @@ +from conan.api.output import ConanOutput, Color + + +def print_profiles(profile_host, profile_build): + out = ConanOutput() + out.title("Input profiles") + out.info("Profile host:", fg=Color.BRIGHT_CYAN) + out.info(profile_host.dumps()) + out.info("Profile build:", fg=Color.BRIGHT_CYAN) + out.info(profile_build.dumps()) diff --git a/conan/cli/printers/graph.py b/conan/cli/printers/graph.py index 6dbc7a530c1..2a05907251d 100644 --- a/conan/cli/printers/graph.py +++ b/conan/cli/printers/graph.py @@ -1,5 +1,6 @@ from conan.api.output import ConanOutput, Color -from conans.client.graph.graph import RECIPE_CONSUMER, RECIPE_VIRTUAL, CONTEXT_BUILD +from conans.client.graph.graph import RECIPE_CONSUMER, RECIPE_VIRTUAL, CONTEXT_BUILD, \ + BINARY_SYSTEM_TOOL def print_graph_basic(graph): @@ -70,10 +71,6 @@ def _format_resolved(title, reqs_to_print): reason = f": {reason}" if reason else "" output.info(" {}{}".format(d, reason), Color.BRIGHT_CYAN) - if graph.error: - output.info("Graph error", Color.BRIGHT_RED) - output.info(" {}".format(graph.error), Color.BRIGHT_RED) - def print_graph_packages(graph): # I am excluding the "download"-"cache" or remote information, that is not @@ -101,7 +98,8 @@ def _format_requires(title, reqs_to_print): for pref, (status, remote) in sorted(reqs_to_print.items(), key=repr): if remote is not None: status = "{} ({})".format(status, remote.name) - output.info(" {} - {}".format(pref.repr_notime(), status), Color.BRIGHT_CYAN) + name = pref.repr_notime() if status != BINARY_SYSTEM_TOOL else str(pref.ref) + output.info(" {} - {}".format(name, status), Color.BRIGHT_CYAN) _format_requires("Requirements", requires) _format_requires("Test requirements", test_requires) diff --git a/conan/tools/cmake/cmake.py b/conan/tools/cmake/cmake.py index 0d5ff91b788..b2cae603e54 100644 --- a/conan/tools/cmake/cmake.py +++ b/conan/tools/cmake/cmake.py @@ -74,6 +74,7 @@ def configure(self, variables=None, build_script_folder=None, cli_args=None): ``self.folders.source`` at the ``layout()`` method. :param cli_args: List of extra arguments provided when calling to CMake. """ + self._conanfile.output.info("Running CMake.configure()") cmakelist_folder = self._conanfile.source_folder if build_script_folder: cmakelist_folder = os.path.join(self._conanfile.source_folder, build_script_folder) @@ -107,7 +108,6 @@ def configure(self, variables=None, build_script_folder=None, cli_args=None): arg_list.extend(cli_args) command = " ".join(arg_list) - self._conanfile.output.info("CMake command: %s" % command) with chdir(self, build_folder): self._conanfile.run(command) @@ -138,7 +138,6 @@ def _build(self, build_type=None, target=None, cli_args=None, build_tool_args=No arg_list = ['"{}"'.format(bf), build_config, cmd_args_to_string(args)] arg_list = " ".join(filter(None, arg_list)) command = "%s --build %s" % (self._cmake_program, arg_list) - self._conanfile.output.info("CMake command: %s" % command) self._conanfile.run(command, env=env) def build(self, build_type=None, target=None, cli_args=None, build_tool_args=None): @@ -155,6 +154,7 @@ def build(self, build_type=None, target=None, cli_args=None, build_tool_args=Non build system that will be passed to the command line after the ``--`` indicator: ``cmake --build ... -- barg1 barg2`` """ + self._conanfile.output.info("Running CMake.build()") self._build(build_type, target, cli_args, build_tool_args) def install(self, build_type=None, component=None): @@ -167,6 +167,7 @@ def install(self, build_type=None, component=None): as in that case the build type must be specified at configure time, not build type. """ + self._conanfile.output.info("Running CMake.install()") mkdir(self._conanfile, self._conanfile.package_folder) bt = build_type or self._conanfile.settings.get_safe("build_type") @@ -182,7 +183,6 @@ def install(self, build_type=None, component=None): arg_list.extend(["--component", component]) arg_list = " ".join(filter(None, arg_list)) command = "%s %s" % (self._cmake_program, arg_list) - self._conanfile.output.info("CMake command: %s" % command) self._conanfile.run(command) def test(self, build_type=None, target=None, cli_args=None, build_tool_args=None, env=""): diff --git a/conan/tools/cmake/presets.py b/conan/tools/cmake/presets.py index a200bd7c23b..09c17a667e5 100644 --- a/conan/tools/cmake/presets.py +++ b/conan/tools/cmake/presets.py @@ -2,9 +2,11 @@ import os import platform +from conan.api.output import ConanOutput from conan.tools.cmake.layout import get_build_folder_custom_vars from conan.tools.cmake.utils import is_multi_configuration from conan.tools.microsoft import is_msvc +from conans.client.graph.graph import RECIPE_CONSUMER from conans.errors import ConanException from conans.util.files import save, load @@ -106,12 +108,18 @@ def _format_val(val): add_toolchain_cache = f"-DCMAKE_TOOLCHAIN_FILE={toolchain_file} " \ if "CMAKE_TOOLCHAIN_FILE" not in cache_variables_info else "" - conanfile.output.info(f"Preset '{name}' added to CMakePresets.json. Invoke it manually using " - f"'cmake --preset {name}'") - conanfile.output.info(f"If your CMake version is not compatible with " - f"CMakePresets (<3.19) call cmake like: 'cmake " - f"-G {_format_val(generator)} {add_toolchain_cache}" - f"{cache_variables_info}'") + try: + is_consumer = conanfile._conan_node.recipe == RECIPE_CONSUMER and \ + conanfile.tested_reference_str is None + except: + is_consumer = False + if is_consumer: + conanfile.output.info(f"Preset '{name}' added to CMakePresets.json. Invoke it manually using " + f"'cmake --preset {name}'") + conanfile.output.info(f"If your CMake version is not compatible with " + f"CMakePresets (<3.19) call cmake like: 'cmake " + f"-G {_format_val(generator)} {add_toolchain_cache}" + f"{cache_variables_info}'") return ret @@ -200,6 +208,7 @@ def write_cmake_presets(conanfile, toolchain_file, generator, cache_variables, preset_content = json.dumps(data, indent=4) save(preset_path, preset_content) + ConanOutput(str(conanfile)).info("CMakeToolchain generated: CMakePresets.json") _save_cmake_user_presets(conanfile, preset_path, user_presets_path, preset_prefix, data) @@ -244,6 +253,8 @@ def _save_cmake_user_presets(conanfile, preset_path, user_presets_path, preset_p data = _append_user_preset_path(conanfile, data, preset_path) data = json.dumps(data, indent=4) + relpath = os.path.relpath(user_presets_path, conanfile.generators_folder) + ConanOutput(str(conanfile)).info(f"CMakeToolchain generated: {relpath}") save(user_presets_path, data) diff --git a/conan/tools/cmake/toolchain/toolchain.py b/conan/tools/cmake/toolchain/toolchain.py index 6ded2d3b5a2..1a6e83f965c 100644 --- a/conan/tools/cmake/toolchain/toolchain.py +++ b/conan/tools/cmake/toolchain/toolchain.py @@ -4,6 +4,7 @@ from jinja2 import Template +from conan.api.output import ConanOutput from conan.internal import check_duplicated_generator from conan.tools.build import use_win_mingw from conan.tools.cmake.presets import write_cmake_presets @@ -180,6 +181,7 @@ def generate(self): toolchain_file = self._conanfile.conf.get("tools.cmake.cmaketoolchain:toolchain_file") if toolchain_file is None: # The main toolchain file generated only if user dont define save(os.path.join(self._conanfile.generators_folder, self.filename), self.content) + ConanOutput(str(self._conanfile)).info(f"CMakeToolchain generated: {self.filename}") # If we're using Intel oneAPI, we need to generate the environment file and run it if self._conanfile.settings.get_safe("compiler") == "intel-cc": IntelCC(self._conanfile).generate() diff --git a/conan/tools/files/copy_pattern.py b/conan/tools/files/copy_pattern.py index 3c9f5b7b01e..7278759b05d 100644 --- a/conan/tools/files/copy_pattern.py +++ b/conan/tools/files/copy_pattern.py @@ -1,7 +1,6 @@ import fnmatch import os import shutil -from collections import defaultdict from conans.util.files import mkdir @@ -38,10 +37,6 @@ def copy(conanfile, pattern, src, dst, keep_path=True, excludes=None, copied_files = _copy_files(files_to_copy, src, dst, keep_path) copied_files.extend(_copy_files_symlinked_to_folders(files_symlinked_to_folders, src, dst)) - - # FIXME: Not always passed conanfile - if conanfile: - report_files_copied(copied_files, conanfile.output) return copied_files @@ -144,23 +139,3 @@ def _copy_files_symlinked_to_folders(files_symlinked_to_folders, src, dst): os.symlink(link_dst, symlink_path) copied_files.append(symlink_path) return copied_files - - -def report_files_copied(copied, scoped_output, message_suffix="Copied"): - ext_files = defaultdict(list) - for f in copied: - _, ext = os.path.splitext(f) - ext_files[ext].append(os.path.basename(f)) - - if not ext_files: - return False - - for ext, files in ext_files.items(): - files_str = (": " + ", ".join(files)) if len(files) < 5 else "" - file_or_files = "file" if len(files) == 1 else "files" - if not ext: - scoped_output.info("%s %d %s%s" % (message_suffix, len(files), file_or_files, files_str)) - else: - scoped_output.info("%s %d '%s' %s%s" - % (message_suffix, len(files), ext, file_or_files, files_str)) - return True diff --git a/conans/client/cmd/export.py b/conans/client/cmd/export.py index c65a69059dc..35daa5cd0cf 100644 --- a/conans/client/cmd/export.py +++ b/conans/client/cmd/export.py @@ -2,12 +2,11 @@ import shutil from conan.tools.files import copy -from conan.tools.files.copy_pattern import report_files_copied from conan.api.output import ConanOutput from conans.errors import ConanException, conanfile_exception_formatter from conans.model.manifest import FileTreeManifest from conans.model.recipe_ref import RecipeReference -from conans.paths import CONANFILE, DATA_YML +from conans.paths import DATA_YML from conans.util.files import is_dirty, rmdir, set_dirty, mkdir, clean_dirty, chdir from conans.util.runners import check_output_runner @@ -33,7 +32,7 @@ def cmd_export(app, conanfile_path, name, version, user, channel, graph_lock=Non hook_manager.execute("pre_export", conanfile=conanfile) - scoped_output.highlight("Exporting package recipe") + scoped_output.info(f"Exporting package recipe: {conanfile_path}") export_folder = recipe_layout.export() export_src_folder = recipe_layout.export_sources() @@ -52,6 +51,7 @@ def cmd_export(app, conanfile_path, name, version, user, channel, graph_lock=Non # Compute the new digest manifest = FileTreeManifest.create(export_folder, export_src_folder) manifest.save(export_folder) + manifest.report_summary(scoped_output) # Compute the revision for the recipe revision = calc_revision(scoped_output=conanfile.output, @@ -62,9 +62,7 @@ def cmd_export(app, conanfile_path, name, version, user, channel, graph_lock=Non ref.revision = revision recipe_layout.reference = ref cache.assign_rrev(recipe_layout) - # TODO: cache2.0 check if this is the message we want to output - scoped_output.success('A new %s version was exported' % CONANFILE) - scoped_output.info('Folder: %s' % recipe_layout.export()) + scoped_output.info('Exported to cache folder: %s' % recipe_layout.export()) # TODO: cache2.0: check this part source_folder = recipe_layout.source() @@ -80,7 +78,7 @@ def cmd_export(app, conanfile_path, name, version, user, channel, graph_lock=Non scoped_output.warning(str(e)) set_dirty(source_folder) - scoped_output.info("Exported revision: %s" % revision) + scoped_output.success(f"Exported: {ref.repr_humantime()}") return ref, conanfile @@ -91,8 +89,6 @@ def calc_revision(scoped_output, path, manifest, revision_mode): # Use the proper approach depending on 'revision_mode' if revision_mode == "hash": revision = manifest.summary_hash - scoped_output.info("Using the exported files summary hash as the recipe" - " revision: {} ".format(revision)) else: try: with chdir(path): @@ -141,8 +137,6 @@ def export_source(conanfile, destination_source_folder): dst=destination_source_folder, excludes=excluded_sources) copied.extend(_tmp) - package_output = ConanOutput(scope="%s exports_sources" % conanfile.output.scope) - report_files_copied(copied, package_output) conanfile.folders.set_base_export_sources(destination_source_folder) _run_method(conanfile, "export_sources") @@ -153,7 +147,7 @@ def export_recipe(conanfile, destination_folder): if isinstance(conanfile.exports, str): conanfile.exports = (conanfile.exports,) - package_output = ConanOutput(scope="%s exports" % conanfile.output.scope) + package_output = ConanOutput(scope="%s: exports" % conanfile.output.scope) if os.path.exists(os.path.join(conanfile.recipe_folder, DATA_YML)): package_output.info("File '{}' found. Exporting it...".format(DATA_YML)) @@ -169,7 +163,6 @@ def export_recipe(conanfile, destination_folder): tmp = copy(conanfile, pattern, conanfile.recipe_folder, destination_folder, excludes=excluded_exports) copied.extend(tmp) - report_files_copied(copied, package_output) conanfile.folders.set_base_export(destination_folder) _run_method(conanfile, "export") diff --git a/conans/client/conanfile/package.py b/conans/client/conanfile/package.py index 33250c1286f..d494e608887 100644 --- a/conans/client/conanfile/package.py +++ b/conans/client/conanfile/package.py @@ -1,6 +1,5 @@ import os -from conan.tools.files.copy_pattern import report_files_copied from conan.api.output import ConanOutput from conans.errors import ConanException, conanfile_exception_formatter, conanfile_remove_attr from conans.model.manifest import FileTreeManifest @@ -37,25 +36,15 @@ def run_package_method(conanfile, package_id, hook_manager, ref): save(os.path.join(conanfile.package_folder, CONANINFO), conanfile.info.dumps()) manifest = FileTreeManifest.create(conanfile.package_folder) manifest.save(conanfile.package_folder) - - package_output = ConanOutput(scope="%s package()" % scoped_output.scope) - _report_files_from_manifest(package_output, manifest) - scoped_output.success("Package '%s' created" % package_id) + package_output = ConanOutput(scope="%s: package()" % scoped_output.scope) + manifest.report_summary(package_output, "Packaged") prev = manifest.summary_hash scoped_output.info("Created package revision %s" % prev) pref = PkgReference(ref, package_id) pref.revision = prev + scoped_output.success("Package '%s' created" % package_id) scoped_output.success("Full package reference: {}".format(pref.repr_notime())) return prev -def _report_files_from_manifest(scoped_output, manifest): - copied_files = list(manifest.files()) - copied_files.remove(CONANINFO) - - if not copied_files: - scoped_output.warning("No files in this package!") - return - - report_files_copied(copied_files, scoped_output, message_suffix="Packaged") diff --git a/conans/client/downloaders/file_downloader.py b/conans/client/downloaders/file_downloader.py index a2736b00ec1..f3567bde113 100644 --- a/conans/client/downloaders/file_downloader.py +++ b/conans/client/downloaders/file_downloader.py @@ -104,9 +104,10 @@ def get_total_length(): try: total_length = get_total_length() - action = "Downloading" if range_start == 0 else "Continuing download of" - description = "{} {}".format(action, os.path.basename(file_path)) - self._output.info(description) + if total_length > 100000: + action = "Downloading" if range_start == 0 else "Continuing download of" + description = "{} {}".format(action, os.path.basename(file_path)) + self._output.info(description) chunk_size = 1024 * 100 total_downloaded_size = range_start diff --git a/conans/client/generators/__init__.py b/conans/client/generators/__init__.py index da5ec38f31b..79f978e4599 100644 --- a/conans/client/generators/__init__.py +++ b/conans/client/generators/__init__.py @@ -31,10 +31,11 @@ def _get_generator_class(generator_name): try: generator_class = _generators[generator_name] # This is identical to import ... form ... in terms of cacheing - return getattr(importlib.import_module(generator_class), generator_name) except KeyError as e: raise ConanException(f"Invalid generator '{generator_name}'. " f"Available types: {', '.join(_generators)}") from e + try: + return getattr(importlib.import_module(generator_class), generator_name) except ImportError as e: raise ConanException("Internal Conan error: " f"Could not find module {generator_class}") from e @@ -51,7 +52,7 @@ def write_generators(conanfile, hook_manager): hook_manager.execute("pre_generate", conanfile=conanfile) if conanfile.generators: - conanfile.output.info(f"Writing generators to {new_gen_folder}") + conanfile.output.highlight(f"Writing generators to {new_gen_folder}") # generators check that they are not present in the generators field, # to avoid duplicates between the generators attribute and the generate() method # They would raise an exception here if we don't invalidate the field while we call them @@ -63,8 +64,8 @@ def write_generators(conanfile, hook_manager): if generator_class: try: generator = generator_class(conanfile) - conanfile.output.highlight(f"Generator '{generator_name}' calling 'generate()'") mkdir(new_gen_folder) + conanfile.output.info(f"Generator '{generator_name}' calling 'generate()'") with chdir(new_gen_folder): generator.generate() continue @@ -78,6 +79,7 @@ def write_generators(conanfile, hook_manager): conanfile.generators = old_generators if hasattr(conanfile, "generate"): conanfile.output.highlight("Calling generate()") + conanfile.output.info(f"Generators folder: {new_gen_folder}") mkdir(new_gen_folder) with chdir(new_gen_folder): with conanfile_exception_formatter(conanfile, "generate"): @@ -96,7 +98,6 @@ def write_generators(conanfile, hook_manager): env = VirtualRunEnv(conanfile) env.generate() - conanfile.output.highlight("Aggregating env generators") _generate_aggregated_env(conanfile) hook_manager.execute("post_generate", conanfile=conanfile) @@ -125,6 +126,7 @@ def deactivates(filenames): result.append(os.path.join(folder, "deactivate_{}".format(f))) return result + generated = [] for group, env_scripts in conanfile.env_scripts.items(): subsystem = deduce_subsystem(conanfile, group) bats = [] @@ -146,6 +148,7 @@ def deactivates(filenames): def sh_content(files): return ". " + " && . ".join('"{}"'.format(s) for s in files) filename = "conan{}.sh".format(group) + generated.append(filename) save(os.path.join(conanfile.generators_folder, filename), sh_content(shs)) save(os.path.join(conanfile.generators_folder, "deactivate_{}".format(filename)), sh_content(deactivates(shs))) @@ -153,6 +156,7 @@ def sh_content(files): def bat_content(files): return "\r\n".join(["@echo off"] + ['call "{}"'.format(b) for b in files]) filename = "conan{}.bat".format(group) + generated.append(filename) save(os.path.join(conanfile.generators_folder, filename), bat_content(bats)) save(os.path.join(conanfile.generators_folder, "deactivate_{}".format(filename)), bat_content(deactivates(bats))) @@ -160,6 +164,10 @@ def bat_content(files): def ps1_content(files): return "\r\n".join(['& "{}"'.format(b) for b in files]) filename = "conan{}.ps1".format(group) + generated.append(filename) save(os.path.join(conanfile.generators_folder, filename), ps1_content(ps1s)) save(os.path.join(conanfile.generators_folder, "deactivate_{}".format(filename)), ps1_content(deactivates(ps1s))) + if generated: + conanfile.output.highlight("Generating aggregated env files") + conanfile.output.info(f"Generated aggregated env files: {generated}") diff --git a/conans/client/graph/graph.py b/conans/client/graph/graph.py index 5d07f934954..92f6f77f919 100644 --- a/conans/client/graph/graph.py +++ b/conans/client/graph/graph.py @@ -12,7 +12,7 @@ RECIPE_NO_REMOTE = "No remote" RECIPE_EDITABLE = "Editable" RECIPE_CONSUMER = "Consumer" # A conanfile from the user -RECIPE_VIRTUAL = "Virtual" # A virtual conanfile (dynamic in memory conanfile) +RECIPE_VIRTUAL = "Cli" # A virtual conanfile (dynamic in memory conanfile) RECIPE_MISSING = "Missing recipe" # Impossible to find a recipe for this reference RECIPE_SYSTEM_TOOL = "System tool" diff --git a/conans/client/graph/graph_error.py b/conans/client/graph/graph_error.py index 29ee6254ac2..19a8f680498 100644 --- a/conans/client/graph/graph_error.py +++ b/conans/client/graph/graph_error.py @@ -19,6 +19,11 @@ def __str__(self): elif self.kind == GraphError.VERSION_CONFLICT: return f"Version conflict: {self.node.ref}->{self.require.ref}, "\ f"{self.base_previous.ref}->{self.prev_require.ref}." + elif self.kind == GraphError.LOOP: + return "There is a cycle/loop in the graph:\n"\ + f" Initial ancestor: {self.ancestor}\n" \ + f" Require: {self.require.ref}\n" \ + f" Dependency: {self.node}" return self.kind @staticmethod diff --git a/conans/client/graph/proxy.py b/conans/client/graph/proxy.py index bcd50718e7e..ff89ee2b0db 100644 --- a/conans/client/graph/proxy.py +++ b/conans/client/graph/proxy.py @@ -121,7 +121,6 @@ def _find_newest_recipe_in_remotes(self, reference, remotes): # searches in all the remotes and downloads the latest from all of them def _download_recipe(self, ref, remotes, scoped_output): def _retrieve_from_remote(the_remote, reference): - scoped_output.info("Trying with '%s'..." % the_remote.name) # If incomplete, resolve the latest in server if not reference.revision: reference = self._remote_manager.get_latest_recipe_reference(ref, remote) diff --git a/conans/client/installer.py b/conans/client/installer.py index c519763bb75..423e71ef8cd 100644 --- a/conans/client/installer.py +++ b/conans/client/installer.py @@ -106,7 +106,6 @@ def _build(self, conanfile, pref): def _package(self, conanfile, pref): # Creating ***info.txt files save(os.path.join(conanfile.folders.base_build, CONANINFO), conanfile.info.dumps()) - conanfile.output.info("Generated %s" % CONANINFO) package_id = pref.package_id # Do the actual copy, call the conanfile.package() method @@ -235,19 +234,25 @@ def install_sources(self, graph, remotes): def install(self, deps_graph, remotes): assert not deps_graph.error, "This graph cannot be installed: {}".format(deps_graph) - ConanOutput().title("Installing (downloading, building) binaries...") + ConanOutput().title("Installing packages") # order by levels and separate the root node (ref=None) from the rest install_graph = InstallGraph(deps_graph) install_graph.raise_errors() install_order = install_graph.install_order() + package_count = sum([sum(len(install_reference.packages.values()) + for level in install_order + for install_reference in level)]) + installed_count = 1 + self._download_bulk(install_order) for level in install_order: for install_reference in level: for package in install_reference.packages.values(): self._install_source(package.nodes[0], remotes) - self._handle_package(package, install_reference) + self._handle_package(package, install_reference, installed_count, package_count) + installed_count += 1 def _download_bulk(self, install_order): """ executes the download of packages (both download and update), only once for a given @@ -262,6 +267,9 @@ def _download_bulk(self, install_order): if not downloads: return + download_count = len(downloads) + plural = 's' if download_count != 1 else '' + ConanOutput().subtitle(f"Downloading {download_count} package{plural}") parallel = self._cache.new_config.get("core.download:parallel", check_type=int) if parallel is not None: ConanOutput().info("Downloading binary packages in %s parallel threads" % parallel) @@ -279,9 +287,10 @@ def _download_pkg(self, package): assert node.pref.timestamp is not None self._remote_manager.get_package(node.conanfile, node.pref, node.binary_remote) - def _handle_package(self, package, install_reference): + def _handle_package(self, package, install_reference, installed_count, total_count): if package.binary == BINARY_SYSTEM_TOOL: return + if package.binary in (BINARY_EDITABLE, BINARY_EDITABLE_BUILD): self._handle_node_editable(package) return @@ -297,6 +306,9 @@ def _handle_package(self, package, install_reference): package_layout = self._cache.get_or_create_pkg_layout(pref) if package.binary == BINARY_BUILD: + ConanOutput().subtitle(f"Building package {pref.ref} from source " + f"({installed_count} of {total_count})") + ConanOutput(scope=str(pref.ref)).info(f"Package {pref}") self._handle_node_build(package, package_layout) # Just in case it was recomputed package.package_id = package.nodes[0].pref.package_id # Just in case it was recomputed @@ -379,7 +391,7 @@ def _handle_node_build(self, package, pkg_layout): # but better make sure here, and be able to report the actual folder in case # something fails) node.conanfile.folders.set_base_package(pkg_layout.package()) - node.conanfile.output.info("Package folder %s" % node.conanfile.package_folder) + node.conanfile.output.success("Package folder %s" % node.conanfile.package_folder) def _call_package_info(self, conanfile, package_folder, is_editable): diff --git a/conans/client/loader.py b/conans/client/loader.py index 50916719cb9..5385d87d45d 100644 --- a/conans/client/loader.py +++ b/conans/client/loader.py @@ -246,7 +246,7 @@ def layout(_self): def load_virtual(self, requires=None, tool_requires=None): # If user don't specify namespace in options, assume that it is # for the reference (keep compatibility) - conanfile = ConanFile(display_name="virtual") + conanfile = ConanFile(display_name="cli") if tool_requires: for reference in tool_requires: diff --git a/conans/client/remote_manager.py b/conans/client/remote_manager.py index 8ad525df3ac..5d2fbd98a1a 100644 --- a/conans/client/remote_manager.py +++ b/conans/client/remote_manager.py @@ -57,13 +57,11 @@ def get_recipe(self, ref, remote): layout = self._cache.get_or_create_ref_layout(ref) layout.export_remove() - t1 = time.time() download_export = layout.download_export() zipped_files = self._call_remote(remote, "get_recipe", ref, download_export) remote_refs = self._call_remote(remote, "get_recipe_revisions_references", ref) ref_time = remote_refs[0].timestamp ref.timestamp = ref_time - duration = time.time() - t1 # filter metadata files # This could be also optimized in the download, avoiding downloading them, for performance zipped_files = {k: v for k, v in zipped_files.items() if not k.startswith(METADATA)} diff --git a/conans/model/conan_file.py b/conans/model/conan_file.py index 5c57634ae60..8bd09e4a7ec 100644 --- a/conans/model/conan_file.py +++ b/conans/model/conan_file.py @@ -1,7 +1,7 @@ import os from pathlib import Path -from conan.api.output import ConanOutput +from conan.api.output import ConanOutput, Color from conans.client.subsystems import command_env_wrapper from conans.errors import ConanException from conans.model.build_info import MockInfoProperty @@ -289,8 +289,10 @@ def run(self, command, stdout=None, cwd=None, ignore_errors=False, env="", quiet envfiles_folder = self.generators_folder or os.getcwd() wrapped_cmd = command_env_wrapper(self, command, env, envfiles_folder=envfiles_folder) from conans.util.runners import conan_run - ConanOutput().writeln(f"{self.display_name}: RUN: {command if not quiet else '*hidden*'}") + ConanOutput().writeln(f"{self.display_name}: RUN: {command if not quiet else '*hidden*'}", + fg=Color.BRIGHT_BLUE) retcode = conan_run(wrapped_cmd, cwd=cwd, stdout=stdout, shell=shell) + ConanOutput().writeln("") if not ignore_errors and retcode != 0: raise ConanException("Error %d while executing" % retcode) diff --git a/conans/model/manifest.py b/conans/model/manifest.py index 3a8bb6e14dd..c3c10737f02 100644 --- a/conans/model/manifest.py +++ b/conans/model/manifest.py @@ -1,4 +1,5 @@ import os +from collections import defaultdict from conans.paths import CONAN_MANIFEST, EXPORT_SOURCES_TGZ_NAME, EXPORT_TGZ_NAME, PACKAGE_TGZ_NAME from conans.util.dates import timestamp_now, timestamp_to_str @@ -63,6 +64,26 @@ def save(self, folder, filename=CONAN_MANIFEST): path = os.path.join(folder, filename) save(path, repr(self)) + def report_summary(self, output, suffix="Copied"): + ext_files = defaultdict(list) + for f in self.file_sums: + if f == "conaninfo.txt": + continue + _, ext = os.path.splitext(f) + ext_files[ext].append(os.path.basename(f)) + if not ext_files: + if suffix != "Copied": + output.warning("No files in this package!") + return + + for ext, files in ext_files.items(): + files_str = (": " + ", ".join(files)) if len(files) < 5 else "" + file_or_files = "file" if len(files) == 1 else "files" + if not ext: + output.info("%s %d %s%s" % (suffix, len(files), file_or_files, files_str)) + else: + output.info("%s %d '%s' %s%s" % (suffix, len(files), ext, file_or_files, files_str)) + @classmethod def create(cls, folder, exports_sources_folder=None): """ Walks a folder and create a FileTreeManifest for it, reading file contents diff --git a/conans/test/functional/configuration/profile_test.py b/conans/test/functional/configuration/profile_test.py index 18489db216e..05463d59c7a 100644 --- a/conans/test/functional/configuration/profile_test.py +++ b/conans/test/functional/configuration/profile_test.py @@ -70,7 +70,7 @@ def test_profile_relative_cwd(self): self.client.run("install .. -pr=sub/profile2", assert_error=True) self.assertIn("ERROR: Profile not found: sub/profile2", self.client.out) self.client.run("install .. -pr=sub/profile") - self.assertIn("Installing (downloading, building) binaries", self.client.out) + self.assertIn("Installing packages", self.client.out) def test_bad_syntax(self): self.client.save({CONANFILE: conanfile_scope_env}) diff --git a/conans/test/functional/toolchains/cmake/test_cmake.py b/conans/test/functional/toolchains/cmake/test_cmake.py index 4218ea72c96..2327f5817ea 100644 --- a/conans/test/functional/toolchains/cmake/test_cmake.py +++ b/conans/test/functional/toolchains/cmake/test_cmake.py @@ -222,7 +222,7 @@ def test_toolchain_win(self, compiler, build_type, runtime, version, cppstd, arc # FIXME: Hardcoded VS version and partial toolset check toolchain_path = os.path.join(self.client.current_folder, "build", "conan_toolchain.cmake").replace("\\", "/") - self.assertIn('CMake command: cmake -G "Visual Studio 15 2017" ' + self.assertIn('cmake -G "Visual Studio 15 2017" ' '-DCMAKE_TOOLCHAIN_FILE="{}"'.format(toolchain_path), self.client.out) if toolset == "v140": self.assertIn("Microsoft Visual Studio 14.0", self.client.out) @@ -318,7 +318,7 @@ def test_toolchain_mingw_win(self, build_type, libcxx, version, cppstd, arch, sh self.assertIn("The C compiler identification is GNU", self.client.out) toolchain_path = os.path.join(self.client.current_folder, "build", "conan_toolchain.cmake").replace("\\", "/") - self.assertIn('CMake command: cmake -G "MinGW Makefiles" ' + self.assertIn('cmake -G "MinGW Makefiles" ' '-DCMAKE_TOOLCHAIN_FILE="{}"'.format(toolchain_path), self.client.out) assert '-DCMAKE_SH="CMAKE_SH-NOTFOUND"' in self.client.out @@ -374,7 +374,7 @@ def test_toolchain_linux(self, build_type, cppstd, arch, libcxx, shared): self._run_build(settings, {"shared": shared}) toolchain_path = os.path.join(self.client.current_folder, "build", "conan_toolchain.cmake").replace("\\", "/") - self.assertIn('CMake command: cmake -G "Unix Makefiles" ' + self.assertIn('cmake -G "Unix Makefiles" ' '-DCMAKE_TOOLCHAIN_FILE="{}"'.format(toolchain_path), self.client.out) extensions_str = "ON" if "gnu" in cppstd else "OFF" @@ -431,7 +431,7 @@ def test_toolchain_apple(self, build_type, cppstd, shared): toolchain_path = os.path.join(self.client.current_folder, "build", "conan_toolchain.cmake").replace("\\", "/") - self.assertIn('CMake command: cmake -G "Unix Makefiles" ' + self.assertIn('cmake -G "Unix Makefiles" ' '-DCMAKE_TOOLCHAIN_FILE="{}"'.format(toolchain_path), self.client.out) extensions_str = "OFF" if cppstd else "" @@ -558,7 +558,7 @@ def package(self): # The create flow must work client.run("create . --name=pkg --version=0.1") - self.assertIn("pkg/0.1 package(): Packaged 1 '.h' file: header.h", client.out) + self.assertIn("pkg/0.1: package(): Packaged 1 '.h' file: header.h", client.out) ref = RecipeReference.loads("pkg/0.1") pref = client.get_latest_package_reference(ref) package_folder = client.get_latest_pkg_layout(pref).package() @@ -596,7 +596,7 @@ def build(self): # The create flow must work client.run("build .") - assert "conanfile.py: CMake command: cmake --install" in client.out + assert "conanfile.py: RUN: cmake --install" in client.out @pytest.mark.tool("cmake") diff --git a/conans/test/functional/tools/scm/test_git_get_commit.py b/conans/test/functional/tools/scm/test_git_get_commit.py index db945e9fb69..40c718e1d18 100644 --- a/conans/test/functional/tools/scm/test_git_get_commit.py +++ b/conans/test/functional/tools/scm/test_git_get_commit.py @@ -124,7 +124,6 @@ def test_relative_folder_repo(): c.save({"root_change": ""}) c.run_command("git add .") c.run_command('git commit -m "root change"') - print(c.current_folder) # Relative paths for folders, from the current_folder with chdir(c.current_folder): diff --git a/conans/test/integration/build_requires/build_requires_test.py b/conans/test/integration/build_requires/build_requires_test.py index e64c4690791..206da0c84d9 100644 --- a/conans/test/integration/build_requires/build_requires_test.py +++ b/conans/test/integration/build_requires/build_requires_test.py @@ -201,7 +201,6 @@ def test_consumer(self): env_info={"MYENV": ["myenvcatch0.1env"]})}) t.run("create . --name=catch --version=0.1 --user=user --channel=testing") t.save({"conanfile.py": GenConanfile().with_requirement(catch_ref, private=True)}) - print(t.load("conanfile.py")) t.run("create . --name=LibA --version=0.1 --user=user --channel=testing") t.save({"conanfile.py": GenConanfile().with_require(libA_ref) .with_tool_requires(catch_ref)}) diff --git a/conans/test/integration/build_requires/profile_build_requires_test.py b/conans/test/integration/build_requires/profile_build_requires_test.py index c463e6ca563..c2d30c42b91 100644 --- a/conans/test/integration/build_requires/profile_build_requires_test.py +++ b/conans/test/integration/build_requires/profile_build_requires_test.py @@ -3,8 +3,6 @@ import textwrap import unittest -import pytest - from conans.paths import CONANFILE from conans.test.utils.tools import TestClient, GenConanfile @@ -95,12 +93,12 @@ def test_build_mode_requires(self): client.run("install . --profile ./profile.txt --build=Pythontool", assert_error=True) self.assertIn("ERROR: Missing prebuilt package for 'tool/0.1@lasote/stable'", client.out) client.run("install . --profile ./profile.txt --build=tool/0.1*") - self.assertIn("tool/0.1@lasote/stable: Generated conaninfo.txt", client.out) + self.assertIn("tool/0.1@lasote/stable: Created package", client.out) # now remove packages, ensure --build=missing also creates them client.run('remove "*:*" -c') client.run("install . --profile ./profile.txt --build=missing") - self.assertIn("tool/0.1@lasote/stable: Generated conaninfo.txt", client.out) + self.assertIn("tool/0.1@lasote/stable: Created package", client.out) def test_profile_test_requires(self): client = TestClient() @@ -209,8 +207,9 @@ def test_consumer_patterns_loop_error(): client.run("export tool1 --name=tool1 --version=1.0") client.run("export tool2 --name=tool2 --version=1.0") - client.run("install consumer --build=missing -pr:b=profile.txt -pr:h=profile.txt", assert_error=True) - assert "graph loop" in client.out + client.run("install consumer --build=missing -pr:b=profile.txt -pr:h=profile.txt", + assert_error=True) + assert "There is a cycle/loop in the graph" in client.out # we can fix it with the negation profile_patterns = textwrap.dedent(""" diff --git a/conans/test/integration/cache/download_cache_test.py b/conans/test/integration/cache/download_cache_test.py index e7d95922992..ba3adb37e6d 100644 --- a/conans/test/integration/cache/download_cache_test.py +++ b/conans/test/integration/cache/download_cache_test.py @@ -29,7 +29,7 @@ def test_download_skip(self): client.run("remove * -c") client.run("install --requires=mypkg/0.1@user/testing") - assert "Downloading" not in client.out + # TODO assert "Downloading" not in client.out # removing the config downloads things client.save({"global.conf": ""}, path=client.cache.cache_folder) @@ -42,7 +42,7 @@ def test_download_skip(self): client.run("remove * -c") client.run("install --requires=mypkg/0.1@user/testing") - assert "Downloading" not in client.out + # TODO assert "Downloading" not in client.out def test_dirty_download(self): # https://github.com/conan-io/conan/issues/8578 @@ -71,7 +71,7 @@ def test_dirty_download(self): client.run("remove * -c") client.run("install --requires=pkg/0.1@") - assert "Downloading" not in client.out + # TODO assert "Downloading" not in client.out def test_user_downloads_cached_newtools(self): http_server = StoppableThreadBottle() diff --git a/conans/test/integration/cache/storage_path_test.py b/conans/test/integration/cache/storage_path_test.py index a51ddc80a26..2aef6a8fe26 100644 --- a/conans/test/integration/cache/storage_path_test.py +++ b/conans/test/integration/cache/storage_path_test.py @@ -11,7 +11,7 @@ def test_storage_path(): client.save({"global.conf": f"core.cache:storage_path={tmp_folder}"}, path=client.cache.cache_folder) client.run("create . --name=mypkg --version=0.1") - assert f"mypkg/0.1: Folder: {tmp_folder}" in client.out + assert f"mypkg/0.1: Package folder {tmp_folder}" in client.out assert os.path.isfile(os.path.join(tmp_folder, "cache.sqlite3")) client.run("cache path mypkg/0.1") diff --git a/conans/test/integration/command/create_test.py b/conans/test/integration/command/create_test.py index 0a01625691d..e8e67c9d7e6 100644 --- a/conans/test/integration/command/create_test.py +++ b/conans/test/integration/command/create_test.py @@ -491,7 +491,7 @@ class MyTest(ConanFile): raise Exception("Ref not found. Review the revisions hash.") # Consumer information - assert consumer_info["recipe"] == "Virtual" + assert consumer_info["recipe"] == "Cli" assert consumer_info["package_id"] is None assert consumer_info["prev"] is None assert consumer_info["options"] == {} diff --git a/conans/test/integration/command/download/download_test.py b/conans/test/integration/command/download/download_test.py index 2c86f6f251c..0171dc45c95 100644 --- a/conans/test/integration/command/download/download_test.py +++ b/conans/test/integration/command/download/download_test.py @@ -27,7 +27,7 @@ class Pkg(ConanFile): client.run("remove pkg/0.1@lasote/stable -c") client.run("download pkg/0.1@lasote/stable -r default") - self.assertIn("Downloading conan_sources.tgz", client.out) + self.assertIn("pkg/0.1@lasote/stable: Sources downloaded from 'default'", client.out) source = client.get_latest_ref_layout(ref).export_sources() self.assertEqual("myfile.h", load(os.path.join(source, "file.h"))) self.assertEqual("C++code", load(os.path.join(source, "otherfile.cpp"))) diff --git a/conans/test/integration/command/export/export_path_test.py b/conans/test/integration/command/export/export_path_test.py index 8ba4858230e..5ad449a6e56 100644 --- a/conans/test/integration/command/export/export_path_test.py +++ b/conans/test/integration/command/export/export_path_test.py @@ -29,8 +29,8 @@ def test_basic(relative_path): reg_path = ref_layoyt.export() manif = FileTreeManifest.load(reg_path) - assert '%s: A new conanfile.py version was exported' % str(ref) in client.out - assert '%s: Folder: %s' % (str(ref), reg_path) in client.out + assert '%s: Exported' % str(ref) in client.out + assert '%s: Exported to cache folder: %s' % (str(ref), reg_path) in client.out for name in list(files.keys()): assert os.path.exists(os.path.join(reg_path, name)) diff --git a/conans/test/integration/command/export/export_test.py b/conans/test/integration/command/export/export_test.py index 64f693cd70f..eddafb812a3 100644 --- a/conans/test/integration/command/export/export_test.py +++ b/conans/test/integration/command/export/export_test.py @@ -29,7 +29,7 @@ def test_export_without_full_reference(self): client.save({"conanfile.py": GenConanfile()}) client.run("export . --name=lib --version=1.0 --user=lasote --channel=channel") - self.assertIn("lib/1.0@lasote/channel: A new conanfile.py version was exported", client.out) + self.assertIn("lib/1.0@lasote/channel: Exported", client.out) client.save({"conanfile.py": GenConanfile("lib", "1.0")}) client.run("export . --user=lasote") @@ -186,7 +186,7 @@ def test_filename(self, filename): client = TestClient() client.save({filename: GenConanfile("hello", "1.2")}) client.run("export %s --user=user --channel=stable" % filename) - self.assertIn("hello/1.2@user/stable: A new conanfile.py version was exported", client.out) + self.assertIn("hello/1.2@user/stable: Exported", client.out) ref = RecipeReference("hello", "1.2", "user", "stable") latest_rrev = client.cache.get_latest_recipe_reference(ref) export_path = client.cache.ref_layout(latest_rrev).export() @@ -261,9 +261,9 @@ def test_basic(self): reg_path = self.client.cache.ref_layout(latest_rrev).export() manif = FileTreeManifest.load(reg_path) - self.assertIn('%s: A new conanfile.py version was exported' % str(self.ref), + self.assertIn('%s: Exported' % str(self.ref), self.client.out) - self.assertIn('%s: Folder: %s' % (str(self.ref), reg_path), self.client.out) + self.assertIn('%s: Exported to cache folder: %s' % (str(self.ref), reg_path), self.client.out) self.assertTrue(os.path.exists(reg_path)) for name in list(self.files.keys()): @@ -279,7 +279,7 @@ def test_case_sensitive(self): self.ref = RecipeReference("hello0", "0.1", "lasote", "stable") self.client.save({"conanfile.py": GenConanfile("hello0", "0.1").with_exports("*")}) self.client.run("export . --user=lasote --channel=stable") - self.assertIn("hello0/0.1@lasote/stable: Exported revision", self.client.out) + self.assertIn("hello0/0.1@lasote/stable: Exported", self.client.out) def test_export_filter(self): self.client.save({CONANFILE: GenConanfile("openssl", "2.0.1")}) @@ -338,7 +338,7 @@ def test_export_the_same_code(self): self.assertNotIn('Cleaning the old builds ...', client2.out) self.assertNotIn('Cleaning the old packs ...', client2.out) self.assertNotIn('All the previous packs were cleaned', client2.out) - self.assertIn('%s: A new conanfile.py version was exported' % str(self.ref), + self.assertIn('%s: Exported' % str(self.ref), self.client.out) self.assertIn('%s: Folder: %s' % (str(self.ref), reg_path2), self.client.out) self.assertTrue(os.path.exists(reg_path2)) @@ -373,7 +373,7 @@ def test_export_a_new_version(self): reg_path3 = client2.get_latest_ref_layout(self.ref).export() digest3 = FileTreeManifest.load(client2.get_latest_ref_layout(self.ref).export()) - self.assertIn('%s: A new conanfile.py version was exported' % str(self.ref), + self.assertIn('%s: Exported' % str(self.ref), self.client.out) self.assertIn('%s: Folder: %s' % (str(self.ref), reg_path3), self.client.out) @@ -442,14 +442,14 @@ def test_export_no_params(self): client = TestClient() client.save({"conanfile.py": GenConanfile().with_name("lib").with_version("1.0")}) client.run('export .') - self.assertIn("lib/1.0: A new conanfile.py version was exported", client.out) + self.assertIn("lib/1.0: Exported", client.out) def test_export_with_name_and_version(self): client = TestClient() client.save({"conanfile.py": GenConanfile()}) client.run('export . --name=lib --version=1.0') - self.assertIn("lib/1.0: A new conanfile.py version was exported", client.out) + self.assertIn("lib/1.0: Exported", client.out) def test_export_with_only_user_channel(self): """This should be the recommended way and only from Conan 2.0""" @@ -457,20 +457,20 @@ def test_export_with_only_user_channel(self): client.save({"conanfile.py": GenConanfile().with_name("lib").with_version("1.0")}) client.run('export . --version= --user=user --channel=channel') - self.assertIn("lib/1.0@user/channel: A new conanfile.py version was exported", client.out) + self.assertIn("lib/1.0@user/channel: Exported", client.out) def test_export_conflict_no_user_channel(self): client = TestClient() client.save({"conanfile.py": GenConanfile()}) client.run('export . --name=pkg --version=0.1 --user=user --channel=channel') - self.assertIn("pkg/0.1@user/channel: A new conanfile.py version was exported", client.out) + self.assertIn("pkg/0.1@user/channel: Exported", client.out) client.run('export . --name=pkg --version=0.1 --user=other --channel=stable') - self.assertIn("pkg/0.1@other/stable: A new conanfile.py version was exported", client.out) + self.assertIn("pkg/0.1@other/stable: Exported", client.out) client.run('export . --name=pkg --version=0.1') - self.assertIn("pkg/0.1: A new conanfile.py version was exported", client.out) + self.assertIn("pkg/0.1: Exported", client.out) client.run('export . --name=pkg --version=0.1') - self.assertIn("pkg/0.1: Exported revision", client.out) + self.assertIn("pkg/0.1: Exported", client.out) @pytest.mark.skipif(platform.system() != "Linux", reason="Needs case-sensitive filesystem") diff --git a/conans/test/integration/command/export/exports_method_test.py b/conans/test/integration/command/export/exports_method_test.py index d2ef6564207..08376cdcbcb 100644 --- a/conans/test/integration/command/export/exports_method_test.py +++ b/conans/test/integration/command/export/exports_method_test.py @@ -23,7 +23,7 @@ def export(self): """) client.save({"conanfile.py": conanfile, "LICENSE.md": "license", "file.txt": "file"}) client.run("export . --name=pkg --version=0.1") - self.assertIn("pkg/0.1 exports: Copied 1 '.txt' file: file.txt", client.out) + self.assertIn("pkg/0.1: Copied 1 '.txt' file: file.txt", client.out) self.assertIn("pkg/0.1: Calling export()", client.out) self.assertIn("Copied 1 '.md' file: LICENSE.md", client.out) @@ -170,7 +170,7 @@ def export_sources(self): """) client.save({"conanfile.py": conanfile, "LICENSE.md": "license", "file.txt": "file"}) client.run("export . --name=pkg --version=0.1") - self.assertIn("pkg/0.1 exports_sources: Copied 1 '.txt' file: file.txt", client.out) + self.assertIn("pkg/0.1: Copied 1 '.txt' file: file.txt", client.out) self.assertIn("Copied 1 '.md' file: LICENSE.md", client.out) latest_rrev = client.cache.get_latest_recipe_reference(RecipeReference.loads("pkg/0.1")) @@ -248,5 +248,5 @@ def build(self): client.run("upload pkg/0.1 -r default") client.run("remove * -c") client.run("install --requires=pkg/0.1@ --build='*'") - self.assertIn("Downloading conan_sources.tgz", client.out) + self.assertIn("pkg/0.1: Sources downloaded from 'default'", client.out) self.assertIn("pkg/0.1: CONTENT: mycontent", client.out) diff --git a/conans/test/integration/command/export_pkg_test.py b/conans/test/integration/command/export_pkg_test.py index 9ead0aaaa5d..0a161d41827 100644 --- a/conans/test/integration/command/export_pkg_test.py +++ b/conans/test/integration/command/export_pkg_test.py @@ -54,7 +54,7 @@ def test_package_folder_errors(self): client = TestClient() client.save({CONANFILE: GenConanfile()}) client.run("export-pkg . --name=hello --version=0.1 --user=lasote --channel=stable") - self.assertIn("conanfile.py (hello/0.1@lasote/stable) package(): " + self.assertIn("conanfile.py (hello/0.1@lasote/stable): package(): " "WARN: No files in this package!", client.out) def test_options(self): @@ -232,7 +232,7 @@ def package(self): # Partial reference is ok client.save({CONANFILE: conanfile, "file.txt": "txt contents"}) client.run("export-pkg . --user=conan --channel=stable") - self.assertIn("conanfile.py (hello/0.1@conan/stable) package(): " + self.assertIn("conanfile.py (hello/0.1@conan/stable): package(): " "Packaged 1 '.txt' file: file.txt", client.out) # Specify different name or version is not working @@ -254,7 +254,7 @@ def package(self): # Partial reference is ok client.save({CONANFILE: conanfile, "file.txt": "txt contents"}) client.run("export-pkg . --name=anyname --version=1.222 --user=conan --channel=stable") - self.assertIn("conanfile.py (anyname/1.222@conan/stable) package(): " + self.assertIn("conanfile.py (anyname/1.222@conan/stable): package(): " "Packaged 1 '.txt' file: file.txt", client.out) def test_with_deps(self): @@ -344,10 +344,10 @@ def package(self): client.save({CONANFILE: conanfile, "src/header.h": "contents"}) client.run("export-pkg . --name=pkg --version=1.0") - assert "conanfile.py (pkg/1.0) package(): Packaged 1 '.h' file: header.h" in client.out + assert "conanfile.py (pkg/1.0): package(): Packaged 1 '.h' file: header.h" in client.out # check for https://github.com/conan-io/conan/issues/10736 client.run("export-pkg . --name=pkg --version=1.0") - assert "conanfile.py (pkg/1.0) package(): Packaged 1 '.h' file: header.h" in client.out + assert "conanfile.py (pkg/1.0): package(): Packaged 1 '.h' file: header.h" in client.out client.run("install --requires=pkg/1.0@ --build='*'") client.assert_listed_require({"pkg/1.0": "Cache"}) assert "conanfile.py (pkg/1.0): Calling build()" not in client.out @@ -546,7 +546,7 @@ def package(self): c.run("build . -of=mytmp") c.run("export-pkg . -of=mytmp") - assert "Copied 1 '.txt' file: myfile.txt" in c.out + assert "Packaged 1 '.txt' file: myfile.txt" in c.out assert os.path.exists(os.path.join(c.current_folder, "mytmp", "myfile.txt")) diff --git a/conans/test/integration/command/install/install_update_test.py b/conans/test/integration/command/install/install_update_test.py index f23def3f8f8..e20a917a45b 100644 --- a/conans/test/integration/command/install/install_update_test.py +++ b/conans/test/integration/command/install/install_update_test.py @@ -126,8 +126,7 @@ def test_reuse(): client2 = TestClient(servers=client.servers, inputs=["admin", "password"]) client2.run("install --requires=hello0/1.0@lasote/stable") - - assert str(client2.out).count("Downloading conaninfo.txt") == 1 + assert "hello0/1.0@lasote/stable: Retrieving package" in client2.out client.save({"header.h": "//EMPTY!"}) sleep(1) diff --git a/conans/test/integration/command/source_test.py b/conans/test/integration/command/source_test.py index b064f6d262b..bece91a890a 100644 --- a/conans/test/integration/command/source_test.py +++ b/conans/test/integration/command/source_test.py @@ -162,7 +162,6 @@ def test_retrieve_exports_sources(self): # download the sources from server0 client.run("install --requires=hello/0.1@ -r server0") client.run("upload hello/0.1 -r server1") - self.assertIn("Downloading conan_sources.tgz", client.out) self.assertIn("Sources downloaded from 'server0'", client.out) # install from server1 that has the sources, upload to server1 @@ -171,14 +170,12 @@ def test_retrieve_exports_sources(self): client.run("install --requires=hello/0.1@ -r server1") client.run("upload hello/0.1 -r server1") assert f"'hello/0.1#{rrev}' already in server, skipping upload" in client.out - self.assertNotIn("Downloading conan_sources.tgz", client.out) self.assertNotIn("Sources downloaded from 'server0'", client.out) # install from server0 and build # download sources from server0 client.run("remove * -c") client.run("install --requires=hello/0.1@ -r server0 --build='*'") - self.assertIn("Downloading conan_sources.tgz", client.out) self.assertIn("Sources downloaded from 'server0'", client.out) def test_source_method_called_once(self): diff --git a/conans/test/integration/command/test_package_test.py b/conans/test/integration/command/test_package_test.py index 6e3c6ef1bd2..36fbe7de96b 100644 --- a/conans/test/integration/command/test_package_test.py +++ b/conans/test/integration/command/test_package_test.py @@ -15,7 +15,7 @@ def test_basic(self): client.save({CONANFILE: GenConanfile().with_name("hello").with_version("0.1"), "test_package/conanfile.py": GenConanfile().with_test("pass")}) client.run("create . --user=lasote --channel=stable") - self.assertIn("hello/0.1@lasote/stable: Generated conaninfo.txt", client.out) + self.assertIn("hello/0.1@lasote/stable: Created package", client.out) def test_test_only(self): test_conanfile = GenConanfile().with_test("pass") @@ -34,7 +34,7 @@ def test_test_only(self): client.save({"test_package/conanfile.py": test_conanfile}, clean_first=True) client.run("test test_package hello/0.1@lasote/stable") self.assertNotIn("hello/0.1@lasote/stable: Configuring sources", client.out) - self.assertNotIn("hello/0.1@lasote/stable: Generated conaninfo.txt", client.out) + self.assertNotIn("hello/0.1@lasote/stable: Created package", client.out) self.assertIn("hello/0.1@lasote/stable: Already installed!", client.out) self.assertIn("hello/0.1@lasote/stable (test package): Running test()", client.out) @@ -57,11 +57,11 @@ def test_other_requirements(self): client.save({CONANFILE: GenConanfile().with_name("hello").with_version("0.1"), "test_package/conanfile.py": test_conanfile}) client.run("create . --user=user --channel=channel") - self.assertIn("hello/0.1@user/channel: Generated conaninfo.txt", client.out) + self.assertIn("hello/0.1@user/channel: Created package", client.out) # explicit override of user/channel works client.run("create . --user=lasote --channel=stable") - self.assertIn("hello/0.1@lasote/stable: Generated conaninfo.txt", client.out) + self.assertIn("hello/0.1@lasote/stable: Created package", client.out) def test_test_with_path_errors(self): client = TestClient() diff --git a/conans/test/integration/conanfile/set_name_version_test.py b/conans/test/integration/conanfile/set_name_version_test.py index 93b71c5d322..7d09c412315 100644 --- a/conans/test/integration/conanfile/set_name_version_test.py +++ b/conans/test/integration/conanfile/set_name_version_test.py @@ -24,7 +24,7 @@ def set_version(self): client.save({"conanfile.py": conanfile}) user_channel_arg = "--user=user --channel=channel" if user_channel else "" client.run("export . %s" % user_channel_arg) - self.assertIn("pkg/2.1%s: A new conanfile.py version was exported" % user_channel, + self.assertIn("pkg/2.1%s: Exported" % user_channel, client.out) # installing it doesn't break client.run("install --requires=pkg/2.1%s --build=missing" % (user_channel or "@")) @@ -54,7 +54,7 @@ def set_version(self): "name.txt": "pkg", "version.txt": "2.1"}) client.run("export . --user=user --channel=testing") - self.assertIn("pkg/2.1@user/testing: A new conanfile.py version was exported", client.out) + self.assertIn("pkg/2.1@user/testing: Exported", client.out) client.run("install --requires=pkg/2.1@user/testing --build=missing") client.assert_listed_binary({f"pkg/2.1@user/testing": (NO_SETTINGS_PACKAGE_ID, "Build")}) client.run("install --requires=pkg/2.1@user/testing") @@ -149,4 +149,4 @@ def set_version(self): with client.chdir("build"): client.save({"version.txt": "2.1"}, clean_first=True) client.run("export .. ") - self.assertIn("pkg/2.1: A new conanfile.py version was exported", client.out) + self.assertIn("pkg/2.1: Exported", client.out) diff --git a/conans/test/integration/editable/forbidden_commands_test.py b/conans/test/integration/editable/forbidden_commands_test.py index 477c9364402..ca5b664f769 100644 --- a/conans/test/integration/editable/forbidden_commands_test.py +++ b/conans/test/integration/editable/forbidden_commands_test.py @@ -22,7 +22,7 @@ def test_commands_not_blocked(self): assert "ERROR: Recipe 'lib/0.1' not found" in t.out t.run('export . ') - assert "lib/0.1: Exported revision" in t.out + assert "lib/0.1: Exported" in t.out t.run("list *") assert "lib/0.1" in t.out t.run('list lib/0.1:*') diff --git a/conans/test/integration/export_sources_test.py b/conans/test/integration/export_sources_test.py index f9f757ad04c..0b30d04e32b 100644 --- a/conans/test/integration/export_sources_test.py +++ b/conans/test/integration/export_sources_test.py @@ -69,4 +69,4 @@ def test_test_package_copied(): client.save({"conanfile.py": conanfile, "test_package/foo.txt": "bar"}) client.run("export . --name foo --version 1.0") - assert "Copied 1 '.txt' file" in client.out + assert "Copied 2 '.txt' file" in client.out diff --git a/conans/test/integration/graph/core/graph_manager_base.py b/conans/test/integration/graph/core/graph_manager_base.py index fc661e63640..9cafafcd694 100644 --- a/conans/test/integration/graph/core/graph_manager_base.py +++ b/conans/test/integration/graph/core/graph_manager_base.py @@ -119,10 +119,9 @@ def build_consumer(self, path, profile_build_requires=None, ref=None, create_ref conan_api = ConanAPI(cache_folder=self.cache_folder) - deps_graph = conan_api.graph.load_graph_consumer(path, None, None, None, None, profile_host, profile_build, None, None, - None, allow_error=True) + None) if install: deps_graph.report_graph_error() diff --git a/conans/test/integration/graph/test_pure_runtime_dep.py b/conans/test/integration/graph/test_pure_runtime_dep.py index 0924c2b2c44..d83c293c80d 100644 --- a/conans/test/integration/graph/test_pure_runtime_dep.py +++ b/conans/test/integration/graph/test_pure_runtime_dep.py @@ -20,5 +20,3 @@ def test_pure_runtime_dep(): c.run("create tool") c.run("create lib") c.run("install consumer -g CMakeDeps") - print(c.out) - print(c.current_folder) diff --git a/conans/test/integration/graph/test_system_tools.py b/conans/test/integration/graph/test_system_tools.py index f24790a8f51..7bb7023324b 100644 --- a/conans/test/integration/graph/test_system_tools.py +++ b/conans/test/integration/graph/test_system_tools.py @@ -133,7 +133,7 @@ def test_package_id_modes(self, package_id_mode): client.save({"conanfile.py": GenConanfile("pkg", "1.0").with_tool_requires("dep/1.0"), "profile": "[system_tools]\ndep/1.0"}) client.run("create . -pr=profile") - assert "dep/1.0:da39a3ee5e6b4b0d3255bfef95601890afd80709 - System tool" in client.out + assert "dep/1.0 - System tool" in client.out def test_package_id_explicit_revision(self): """ @@ -145,12 +145,12 @@ def test_package_id_explicit_revision(self): "profile": "[system_tools]\ndep/1.0#r1", "profile2": "[system_tools]\ndep/1.0#r2"}) client.run("create . -pr=profile") - assert "dep/1.0#r1:da39a3ee5e6b4b0d3255bfef95601890afd80709 - System tool" in client.out + assert "dep/1.0#r1 - System tool" in client.out assert "pkg/1.0#27a56f09310cf1237629bae4104fe5bd:" \ "ea0e320d94b4b70fcb3efbabf9ab871542f8f696 - Build" in client.out client.run("create . -pr=profile2") # pkg gets a new package_id because it is a different revision - assert "dep/1.0#r2:da39a3ee5e6b4b0d3255bfef95601890afd80709 - System tool" in client.out + assert "dep/1.0#r2 - System tool" in client.out assert "pkg/1.0#27a56f09310cf1237629bae4104fe5bd:" \ "334882884da082740e5a002a0b6fdb509a280159 - Build" in client.out diff --git a/conans/test/integration/graph/ux/loop_detection_test.py b/conans/test/integration/graph/ux/loop_detection_test.py index ea6b4dbfadf..6870a962c3a 100644 --- a/conans/test/integration/graph/ux/loop_detection_test.py +++ b/conans/test/integration/graph/ux/loop_detection_test.py @@ -18,12 +18,11 @@ def test_transitive_loop(self): client.run("install --requires=pkg3/0.1@lasote/stable --build='*'", assert_error=True) # TODO: Complete with better diagnostics - self.assertIn("ERROR: graph loop", - client.out) + self.assertIn("ERROR: There is a cycle/loop in the graph", client.out) def test_self_loop(self): client = TestClient() client.save({'pkg1.py': GenConanfile().with_require('pkg1/0.1@lasote/stable'), }) client.run('export pkg1.py --name=pkg1 --version=0.1 --user=lasote --channel=stable') client.run("install --requires=pkg1/0.1@lasote/stable --build='*'", assert_error=True) - self.assertIn("ERROR: graph loop", client.out) + self.assertIn("ERROR: There is a cycle/loop in the graph", client.out) diff --git a/conans/test/integration/lockfile/test_lock_requires.py b/conans/test/integration/lockfile/test_lock_requires.py index d43574ba340..ef197795c0a 100644 --- a/conans/test/integration/lockfile/test_lock_requires.py +++ b/conans/test/integration/lockfile/test_lock_requires.py @@ -174,7 +174,7 @@ def requirements(self): client.run("install consumer -s os=Linux -s:b os=Linux") assert "nix/0.2#" in client.out assert "nix/0.1" not in client.out - assert "win" not in client.out + assert "win/" not in client.out @pytest.mark.parametrize("requires", ["requires", "tool_requires"]) diff --git a/conans/test/integration/lockfile/test_lock_requires_revisions.py b/conans/test/integration/lockfile/test_lock_requires_revisions.py index 0b5c91edbad..57e520c902c 100644 --- a/conans/test/integration/lockfile/test_lock_requires_revisions.py +++ b/conans/test/integration/lockfile/test_lock_requires_revisions.py @@ -77,7 +77,7 @@ def test_conanfile_txt_strict_revisions(requires): client.save({"pkg/conanfile.py": GenConanfile().with_package_id("self.output.info('REV2!!!!')")}) client.run("create pkg --name=pkg --version=0.1 --user=user --channel=testing") - rrev = re.search(r"pkg/0.1@user/testing: Exported revision: (\S+)", str(client.out)).group(1) + rrev = client.exported_recipe_revision() # Not strict mode works client.save({"consumer/conanfile.txt": f"[{requires}]\npkg/0.1@user/testing#{rrev}"}) @@ -169,9 +169,9 @@ def requirements(self): "pkg/conanfile.py": pkg_conanfile, "consumer/conanfile.txt": f"[{requires}]\npkg/0.1"}) client.run("create dep1 --name=dep --version=0.1") - rrev1 = re.search(r"dep/0.1: Exported revision: (\S+)", str(client.out)).group(1) + rrev1 = client.exported_recipe_revision() client.run("create dep2 --name=dep --version=0.1") - rrev2 = re.search(r"dep/0.1: Exported revision: (\S+)", str(client.out)).group(1) + rrev2 = client.exported_recipe_revision() client.save({"pkg/conanfile.py": pkg_conanfile.format(rrev1, rrev2)}) client.run("create pkg --name=pkg --version=0.1 -s os=Windows") diff --git a/conans/test/integration/package_id/compatible_test.py b/conans/test/integration/package_id/compatible_test.py index 98840f12bc3..983c2152531 100644 --- a/conans/test/integration/package_id/compatible_test.py +++ b/conans/test/integration/package_id/compatible_test.py @@ -71,8 +71,8 @@ def package_info(self): "myprofile": profile}) # Create package with gcc 4.8 client.run("export . --name=pkg --version=0.1 --user=user --channel=stable") - self.assertIn("pkg/0.1@user/stable: Exported revision: d165eb4bcdd1c894a97d2a212956f5fe", - client.out) + self.assertIn("pkg/0.1@user/stable: Exported: " + "pkg/0.1@user/stable#d165eb4bcdd1c894a97d2a212956f5fe", client.out) # package can be used with a profile gcc 4.9 falling back to 4.8 binary client.save({"conanfile.py": GenConanfile().with_require("pkg/0.1@user/stable")}) diff --git a/conans/test/integration/package_id/package_id_test.py b/conans/test/integration/package_id/package_id_test.py index 6eb01452db9..901d8b7e51b 100644 --- a/conans/test/integration/package_id/package_id_test.py +++ b/conans/test/integration/package_id/package_id_test.py @@ -182,5 +182,4 @@ def package_id(self): c = TestClient() c.save({"conanfile.py": conanfile}) c.run("create . --name=pkg --version=0.1", assert_error=True) - print(c.out) assert "ConanException: Invalid setting 'DONT_EXIST' is not a valid 'settings.os' value" in c.out diff --git a/conans/test/integration/package_id/test_cache_compatibles.py b/conans/test/integration/package_id/test_cache_compatibles.py index c20d55ab919..4851aa4b50e 100644 --- a/conans/test/integration/package_id/test_cache_compatibles.py +++ b/conans/test/integration/package_id/test_cache_compatibles.py @@ -219,12 +219,12 @@ def package_id(self): client.assert_listed_binary({"sum/0.1": ("da39a3ee5e6b4b0d3255bfef95601890afd80709", "Build")}) # Just check that it works and doesn't fail - assert "Installing (downloading, building) binaries" in client.out + assert "Installing packages" in client.out client.run("create . -s compiler.cppstd=14 --build missing") # Now it will not build, as package exist client.assert_listed_binary({"sum/0.1": ("da39a3ee5e6b4b0d3255bfef95601890afd80709", "Cache")}) - assert "Installing (downloading, building) binaries" in client.out + assert "Installing packages" in client.out def test_check_min_cppstd(self): """ test that the check_min_cppstd works fine wiht compatibility, as it is based diff --git a/conans/test/integration/py_requires/python_requires_test.py b/conans/test/integration/py_requires/python_requires_test.py index 16381ead24c..9c5e66428b6 100644 --- a/conans/test/integration/py_requires/python_requires_test.py +++ b/conans/test/integration/py_requires/python_requires_test.py @@ -313,10 +313,8 @@ def build(self): "other.txt": "text"}) client.run("create . --name=pkg --version=0.1 --user=user --channel=testing") self.assertIn("pkg/0.1@user/testing: Exports sources! *.h", client.out) - self.assertIn("pkg/0.1@user/testing exports: Copied 1 '.txt' file: other.txt", - client.out) - self.assertIn("pkg/0.1@user/testing exports_sources: Copied 1 '.h' file: header.h", - client.out) + self.assertIn("pkg/0.1@user/testing: Copied 1 '.txt' file: other.txt", client.out) + self.assertIn("pkg/0.1@user/testing: Copied 1 '.h' file: header.h", client.out) self.assertIn("pkg/0.1@user/testing: Short paths! True", client.out) self.assertIn("pkg/0.1@user/testing: License! MyLicense", client.out) self.assertIn("pkg/0.1@user/testing: Author! author@company.com", client.out) @@ -611,7 +609,7 @@ def package(self): "name.txt": "mypkg", "version.txt": "myversion"}) client.run("export .") - self.assertIn("mypkg/myversion: A new conanfile.py version was exported", client.out) + self.assertIn("mypkg/myversion: Exported", client.out) client.run("create .") self.assertIn("mypkg/myversion: Pkg1 source: mypkg:myversion", client.out) self.assertIn("mypkg/myversion: Pkg1 build: mypkg:myversion", client.out) @@ -657,7 +655,7 @@ def package(self): "name.txt": "MyPkg", "version.txt": "MyVersion"}) client.run("export . --name=pkg --version=1.0 --user=user --channel=channel") - self.assertIn("pkg/1.0@user/channel: A new conanfile.py version was exported", client.out) + self.assertIn("pkg/1.0@user/channel: Exported", client.out) client.run("create . --name=pkg --version=1.0 --user=user --channel=channel") self.assertIn("pkg/1.0@user/channel: Source: tool header: myheader", client.out) self.assertIn("pkg/1.0@user/channel: Source: tool other: otherheader", client.out) diff --git a/conans/test/integration/remote/download_retries_test.py b/conans/test/integration/remote/download_retries_test.py index d9be0c17b01..813120824b6 100644 --- a/conans/test/integration/remote/download_retries_test.py +++ b/conans/test/integration/remote/download_retries_test.py @@ -58,4 +58,4 @@ def get(self, *args, **kwargs): requester_class=BuggyRequester) client.run("install --requires=pkg/0.1@lasote/stable", assert_error=True) self.assertEqual(str(client.out).count("Waiting 0 seconds to retry..."), 2) - self.assertEqual(str(client.out).count("Error 200 downloading"), 4) + self.assertEqual(str(client.out).count("Error 200 downloading"), 3) diff --git a/conans/test/unittests/client/file_copier/test_report_copied_files.py b/conans/test/unittests/client/file_copier/test_report_copied_files.py index b097e537c99..06a26343c02 100644 --- a/conans/test/unittests/client/file_copier/test_report_copied_files.py +++ b/conans/test/unittests/client/file_copier/test_report_copied_files.py @@ -1,9 +1,7 @@ -# coding=utf-8 - import unittest -from conan.tools.files.copy_pattern import report_files_copied from conan.api.output import ConanOutput +from conans.model.manifest import FileTreeManifest from conans.test.utils.mocks import RedirectedTestOutput from conans.test.utils.tools import redirect_output @@ -11,21 +9,20 @@ class ReportCopiedFilesTestCase(unittest.TestCase): def test_output_string(self): - + manifest = FileTreeManifest(0, + file_sums={'/abs/path/to/file.pdf': "", + '../rel/path/to/file2.pdf': "", + '../rel/path/to/file3.pdf': "", + '../rel/path/to/file4.pdf': "", + '../rel/path/to/file5.pdf': "", + '../rel/path/to/file6.pdf': "", + '../rel/path/to/file7.pdf': "", + '/without/ext/no_ext1': "", + 'no_ext2': "", + 'a/other.txt': ""}) output = RedirectedTestOutput() with redirect_output(output): - files = ['/abs/path/to/file.pdf', - '../rel/path/to/file2.pdf', - '../rel/path/to/file3.pdf', - '../rel/path/to/file4.pdf', - '../rel/path/to/file5.pdf', - '../rel/path/to/file6.pdf', - '../rel/path/to/file7.pdf', - '/without/ext/no_ext1', - 'no_ext2', - 'a/other.txt'] - - report_files_copied(files, ConanOutput()) + manifest.report_summary(ConanOutput()) lines = sorted(str(output).splitlines()) self.assertEqual("Copied 7 '.pdf' files", lines[2]) self.assertEqual("Copied 2 files: no_ext1, no_ext2", lines[1]) diff --git a/conans/test/unittests/model/other_settings_test.py b/conans/test/unittests/model/other_settings_test.py index 1cadb80dda6..887d111a4fd 100644 --- a/conans/test/unittests/model/other_settings_test.py +++ b/conans/test/unittests/model/other_settings_test.py @@ -225,7 +225,6 @@ class SayConan(ConanFile): save(client.cache.settings_path, config) client.run("create . -s os=ChromeOS --build missing") - self.assertIn('Generated conaninfo.txt', client.out) # Settings is None content = """ @@ -239,7 +238,6 @@ class SayConan(ConanFile): client.save({CONANFILE: content}) client.run("remove say/0.1 -c") client.run("create . --build missing") - self.assertIn('Generated conaninfo.txt', client.out) conan_info = self._get_conaninfo("say/0.1", client) self.assertEqual(conan_info.get("settings"), None) @@ -255,8 +253,6 @@ class SayConan(ConanFile): client.save({CONANFILE: content}) client.run("remove say/0.1 -c") client.run("create . --build missing") - self.assertIn('Generated conaninfo.txt', client.out) - conan_info = self._get_conaninfo("say/0.1", client) self.assertEqual(conan_info.get("settings"), None) diff --git a/conans/test/unittests/tools/cmake/test_cmake_presets_definitions.py b/conans/test/unittests/tools/cmake/test_cmake_presets_definitions.py index 87041eeb117..916543950c3 100644 --- a/conans/test/unittests/tools/cmake/test_cmake_presets_definitions.py +++ b/conans/test/unittests/tools/cmake/test_cmake_presets_definitions.py @@ -13,7 +13,7 @@ @pytest.fixture(scope="module") def conanfile(): - c = ConanFile(Mock()) + c = ConanFile("") c.settings = Settings({"os": ["Windows"], "compiler": {"gcc": {"libcxx": ["libstdc++"]}}, "build_type": ["Release"], diff --git a/conans/test/unittests/tools/cmake/test_cmaketoolchain.py b/conans/test/unittests/tools/cmake/test_cmaketoolchain.py index 83de2410516..a75a300a653 100644 --- a/conans/test/unittests/tools/cmake/test_cmaketoolchain.py +++ b/conans/test/unittests/tools/cmake/test_cmaketoolchain.py @@ -18,7 +18,7 @@ @pytest.fixture def conanfile(): - c = ConanFile(None) + c = ConanFile() settings = Settings({"os": ["Windows"], "compiler": {"clang": {"libcxx": ["libstdc++"]}}, "build_type": ["Release"], diff --git a/conans/test/utils/tools.py b/conans/test/utils/tools.py index 6c292734f75..57452973c91 100644 --- a/conans/test/utils/tools.py +++ b/conans/test/utils/tools.py @@ -675,7 +675,7 @@ def assert_listed_require(self, requires, build=False, python=False, test=False, """ lines = self.out.splitlines() if test_package: - line_req = lines.index("-------- test_package: Computing dependency graph --------") + line_req = lines.index("======== Launching test_package ========") lines = lines[line_req:] header = "Requirements" if not build else "Build requirements" if python: @@ -701,9 +701,9 @@ def assert_listed_binary(self, requires, build=False, test=False, test_package=F """ lines = self.out.splitlines() if test_package: - line_req = lines.index("-------- test_package: Computing dependency graph --------") + line_req = lines.index("======== Launching test_package ========") lines = lines[line_req:] - line_req = lines.index("-------- Computing necessary packages --------") + line_req = lines.index("======== Computing necessary packages ========") header = "Requirements" if not build else "Build requirements" if test: header = "Test requirements" @@ -743,7 +743,7 @@ def created_package_reference(self, ref): return PkgReference.loads(pref) def exported_recipe_revision(self): - return re.search(r"Exported revision: (\S+)", str(self.out)).group(1) + return re.search(r": Exported: .*#(\S+)", str(self.out)).group(1) class TurboTestClient(TestClient):