Skip to content

Commit

Permalink
- BugFix: allow tested_reference_str to be None
Browse files Browse the repository at this point in the history
Signed-off-by: SSE4 <tomskside@gmail.com>
  • Loading branch information
SSE4 committed Mar 21, 2022
1 parent e98a759 commit dbb7fa8
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
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

0 comments on commit dbb7fa8

Please sign in to comment.