Skip to content

Commit

Permalink
When the layout, use different folder for the 'conan infos' files (#1…
Browse files Browse the repository at this point in the history
…1820)

* 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
  • Loading branch information
lasote authored Aug 23, 2022
1 parent cd98a16 commit ec7349b
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 27 deletions.
38 changes: 19 additions & 19 deletions conans/client/cmd/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
19 changes: 12 additions & 7 deletions conans/client/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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:
Expand Down Expand Up @@ -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
3 changes: 3 additions & 0 deletions conans/test/functional/command/test_command_test.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import time
import unittest

Expand Down Expand Up @@ -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"))
Original file line number Diff line number Diff line change
Expand Up @@ -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")))
Expand Down

0 comments on commit ec7349b

Please sign in to comment.