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

- BugFix: allow tested_reference_str to be None #10834

Merged
merged 1 commit into from
Mar 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions conans/client/graph/graph_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ def __init__(self, conanfile, default_context):
self.add(build_require, context=self._default_context)

def add(self, build_require, context, force_host_context=False):
if build_require is None:
return
if not isinstance(build_require, ConanFileReference):
build_require = ConanFileReference.loads(build_require)
build_require.force_host_context = force_host_context # Dirty, but will be removed in 2.0
Expand Down
1 change: 1 addition & 0 deletions conans/model/conan_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ class ConanFile(object):

# Run in windows bash
win_bash = None
tested_reference_str = None

def __init__(self, output, runner, display_name="", user=None, channel=None):
# an output stream (writeln, info, warn error)
Expand Down
2 changes: 2 additions & 0 deletions conans/model/requires.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ def iteritems(self): # FIXME: Just a trick to not change default testing conanf
def add(self, reference, private=False, override=False):
""" to define requirements by the user in text, prior to any propagation
"""
if reference is None:
return
assert isinstance(reference, six.string_types)
ref = ConanFileReference.loads(reference)
self.add_ref(ref, private, override)
Expand Down
27 changes: 27 additions & 0 deletions conans/test/integration/command/info/info_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -720,3 +720,30 @@ class Pkg(ConanFile):
client.run("info . --json=file.json")
info = json.loads(client.load("file.json"))
assert info[0]["python_requires"] == ['tool/0.1#f3367e0e7d170aa12abccb175fee5f97']

class TestInfoTestPackage:
# https://github.com/conan-io/conan/issues/10714

def test_tested_reference_str(self):
client = TestClient()
client.save({"conanfile.py": GenConanfile()})
client.run("export . tool/0.1@")

conanfile = textwrap.dedent("""
from conans import ConanFile
class HelloConan(ConanFile):

def requirements(self):
self.requires(self.tested_reference_str)

def build_requirements(self):
self.build_requires(self.tested_reference_str)

test_type = 'explicit'
""")
client.save({"conanfile.py": conanfile})

for args in ["", " --build-order tool/0.1@", " --build"]:
client.run("info . " + args)
assert "AttributeError: 'HelloConan' object has no attribute 'tested_reference_str'"\
not in client.out