From ec7349ba7dacb294b50a8181508870461534befe Mon Sep 17 00:00:00 2001 From: Luis Martinez Date: Tue, 23 Aug 2022 23:52:58 +0200 Subject: [PATCH] When the layout, use different folder for the 'conan infos' files (#11820) * When the layout is declared, choose a different folder for the 'conaninfos' * WIP * Added test * fallback to install based on None * Try different approach * unnecessary changes * fix import * Fix condition --- conans/client/cmd/test.py | 38 +++++++++---------- conans/client/manager.py | 19 ++++++---- .../functional/command/test_command_test.py | 3 ++ .../gnu/test_v2_autotools_template.py | 2 +- 4 files changed, 35 insertions(+), 27 deletions(-) diff --git a/conans/client/cmd/test.py b/conans/client/cmd/test.py index e7f031bda1b..4c2f580dd60 100644 --- a/conans/client/cmd/test.py +++ b/conans/client/cmd/test.py @@ -32,28 +32,28 @@ def install_build_and_test(app, conanfile_abs_path, reference, graph_info, if build_modes is None: build_modes = ["never"] try: - deps_install(app=app, - create_reference=reference, - ref_or_path=conanfile_abs_path, - install_folder=test_build_folder, - base_folder=test_build_folder, - remotes=remotes, - graph_info=graph_info, - update=update, - build_modes=build_modes, - manifest_folder=manifest_folder, - manifest_verify=manifest_verify, - manifest_interactive=manifest_interactive, - keep_build=keep_build, - recorder=recorder, - require_overrides=require_overrides, - conanfile_path=os.path.dirname(conanfile_abs_path), - test=True # To keep legacy test_package_layout - ) + install_folder = deps_install(app=app, + create_reference=reference, + ref_or_path=conanfile_abs_path, + install_folder=test_build_folder, + base_folder=test_build_folder, + remotes=remotes, + graph_info=graph_info, + update=update, + build_modes=build_modes, + manifest_folder=manifest_folder, + manifest_verify=manifest_verify, + manifest_interactive=manifest_interactive, + keep_build=keep_build, + recorder=recorder, + require_overrides=require_overrides, + conanfile_path=os.path.dirname(conanfile_abs_path), + test=True # To keep legacy test_package_layout + ) cmd_build(app, conanfile_abs_path, test_build_folder, source_folder=base_folder, build_folder=test_build_folder, package_folder=os.path.join(test_build_folder, "package"), - install_folder=test_build_folder, test=reference) + install_folder=install_folder, test=reference) finally: if delete_after_build: # Required for windows where deleting the cwd is not possible. diff --git a/conans/client/manager.py b/conans/client/manager.py index 620d58a9261..f27fba83241 100644 --- a/conans/client/manager.py +++ b/conans/client/manager.py @@ -77,6 +77,16 @@ def deps_install(app, ref_or_path, install_folder, base_folder, graph_info, remo except ConanException: # Setting os doesn't exist pass + if hasattr(conanfile, "layout") and not test: + conanfile.folders.set_base_folders(conanfile_path, output_folder) + else: + conanfile.folders.set_base_install(install_folder) + conanfile.folders.set_base_imports(install_folder) + conanfile.folders.set_base_generators(base_folder) + + if hasattr(conanfile, "layout") and test: + install_folder = conanfile.generators_folder + installer = BinaryInstaller(app, recorder=recorder) # TODO: Extract this from the GraphManager, reuse same object, check args earlier build_modes = BuildMode(build_modes, out) @@ -95,13 +105,6 @@ def deps_install(app, ref_or_path, install_folder, base_folder, graph_info, remo interactive=manifest_interactive) manifest_manager.print_log() - if hasattr(conanfile, "layout") and not test: - conanfile.folders.set_base_folders(conanfile_path, output_folder) - else: - conanfile.folders.set_base_install(install_folder) - conanfile.folders.set_base_imports(install_folder) - conanfile.folders.set_base_generators(base_folder) - output = conanfile.output if root_node.recipe != RECIPE_VIRTUAL else out if conanfile.info.invalid: @@ -142,3 +145,5 @@ def deps_install(app, ref_or_path, install_folder, base_folder, graph_info, remo deploy_conanfile = neighbours[0].conanfile if hasattr(deploy_conanfile, "deploy") and callable(deploy_conanfile.deploy): run_deploy(deploy_conanfile, install_folder) + + return install_folder diff --git a/conans/test/functional/command/test_command_test.py b/conans/test/functional/command/test_command_test.py index ff97e0b37a1..970e50aaf72 100644 --- a/conans/test/functional/command/test_command_test.py +++ b/conans/test/functional/command/test_command_test.py @@ -1,3 +1,4 @@ +import os import time import unittest @@ -25,3 +26,5 @@ def test_conan_test(self): client.run("test test_package hello/0.1@lasote/stable -s hello:build_type=Debug " "--build missing") self.assertIn('hello/0.1: Hello World Debug!', client.out) + assert os.path.exists(os.path.join(client.current_folder, "test_package", + "build", "generators", "conaninfo.txt")) diff --git a/conans/test/functional/toolchains/gnu/test_v2_autotools_template.py b/conans/test/functional/toolchains/gnu/test_v2_autotools_template.py index 0e72f4d03ee..81685594aa9 100644 --- a/conans/test/functional/toolchains/gnu/test_v2_autotools_template.py +++ b/conans/test/functional/toolchains/gnu/test_v2_autotools_template.py @@ -93,7 +93,7 @@ def test_autotools_relocatable_libs_darwin(): shutil.move(os.path.join(package_folder, "lib"), os.path.join(client.current_folder, "tempfolder")) # will fail because rpath does not exist client.run_command("test_package/build-release/main", assert_error=True) - assert "Library not loaded: @rpath/libhello.0.dylib" in client.out + assert "Library not loaded: @rpath/libhello.0.dylib" in str(client.out).replace("'", "") # Use DYLD_LIBRARY_PATH and should run client.run_command("DYLD_LIBRARY_PATH={} test_package/build-release/main".format(os.path.join(client.current_folder, "tempfolder")))