Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solving conf_info from BR inherited by consumers' test_package #12095

Merged
merged 9 commits into from
Sep 21, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion conans/client/cmd/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
def cmd_build(app, conanfile_path, base_path, source_folder, build_folder, package_folder,
install_folder, test=False, should_configure=True, should_build=True,
should_install=True, should_test=True, layout_source_folder=None,
layout_build_folder=None):
layout_build_folder=None, conf=None):
""" Call to build() method saved on the conanfile.py
param conanfile_path: path to a conanfile.py
"""
Expand All @@ -29,6 +29,7 @@ def cmd_build(app, conanfile_path, base_path, source_folder, build_folder, packa
"requirements and generators from '%s' file"
% (CONANFILE, CONANFILE, CONANFILE_TXT))

conan_file.conf = conf
if test:
try:
conan_file.requires.add_ref(test)
Expand Down
4 changes: 2 additions & 2 deletions conans/client/cmd/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def install_build_and_test(app, conanfile_abs_path, reference, graph_info,
if build_modes is None:
build_modes = ["never"]
try:
install_folder = deps_install(app=app,
install_folder, conanfile = deps_install(app=app,
create_reference=reference,
ref_or_path=conanfile_abs_path,
install_folder=test_build_folder,
Expand All @@ -53,7 +53,7 @@ def install_build_and_test(app, conanfile_abs_path, reference, graph_info,
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=install_folder, test=reference)
install_folder=install_folder, test=reference, conf=conanfile.conf)
finally:
if delete_after_build:
# Required for windows where deleting the cwd is not possible.
Expand Down
2 changes: 1 addition & 1 deletion conans/client/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,4 @@ def deps_install(app, ref_or_path, install_folder, base_folder, graph_info, remo
if hasattr(deploy_conanfile, "deploy") and callable(deploy_conanfile.deploy):
run_deploy(deploy_conanfile, install_folder)

return install_folder
return install_folder, conanfile
50 changes: 50 additions & 0 deletions conans/test/integration/toolchains/env/test_virtualenv_winbash.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import platform
import textwrap

import pytest

Expand Down Expand Up @@ -166,3 +167,52 @@ def test_nowinbash_virtual_cygwin(client):
assert not os.path.exists(os.path.join(client.current_folder, "conanrunenv.bat"))
run_contents = client.load("conanrunenv.sh")
assert 'export RUNTIME_VAR="/cygdrive/c/path/to/exe"' in run_contents


@pytest.mark.skipif(platform.system() != "Windows", reason="Requires Windows")
def test_conf_inherited_in_test_package():
client = TestClient()
conanfile = textwrap.dedent("""
from conan import ConanFile

class Recipe(ConanFile):
name="msys2"
version="1.0"

def package_info(self):
self.conf_info["tools.microsoft.bash:subsystem"] = "msys2"
lasote marked this conversation as resolved.
Show resolved Hide resolved
self.conf_info["tools.microsoft.bash:path"] = "C:/msys64/usr/bin/bash.exe"
""")
client.save({"conanfile.py": conanfile})
client.run("create .")

conanfile = textwrap.dedent("""
from conan import ConanFile

class Recipe(ConanFile):
name="consumer"
version="1.0"
""")
test_package = textwrap.dedent("""
from conan import ConanFile

class Recipe(ConanFile):
name="test"
version="1.0"
win_bash = True

def build_requirements(self):
self.tool_requires(self.tested_reference_str)
self.tool_requires("msys2/1.0")

def build(self):
self.output.warn(self.conf["tools.microsoft.bash:subsystem"])
lasote marked this conversation as resolved.
Show resolved Hide resolved
self.run("pwd")

def test(self):
pass
""")
client.save({"conanfile.py": conanfile, "test_package/conanfile.py": test_package})
client.run("create .")
assert "are needed to run commands in a Windows subsystem" not in client.out
assert "/c/test_conan/" in client.out