Skip to content

Commit

Permalink
Feature/fix 621 (conan-io#622)
Browse files Browse the repository at this point in the history
* invoke requirements method

* With little test
  • Loading branch information
lasote authored and memsharded committed Nov 3, 2016
1 parent 0272d36 commit 9b50da2
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
1 change: 1 addition & 0 deletions conans/client/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ def test_package(self, *args):
conanfile = loader.load_conan(test_conanfile, self._user_io.out, consumer=True)
try:
# convert to list from ItemViews required for python3
conanfile.requirements()
reqs = list(conanfile.requires.items())
first_dep = reqs[0][1].conan_reference
except Exception:
Expand Down
34 changes: 31 additions & 3 deletions conans/test/integration/conan_test_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ def _create(self, client, number, version, deps=None, export=True):
client.run("export lasote/stable")

def conan_test_test(self):
client = TestClient()
files = cpp_hello_conan_files("Hello0", "0.1")
test_conanfile = '''

# With classic requires
conanfile = '''
from conans import ConanFile, CMake
import os
Expand All @@ -34,6 +34,34 @@ def test(self):
# equal to ./bin/greet, but portable win: .\bin\greet
self.run(os.sep.join([".","bin", "greet"]))
'''
self._test_with_conanfile(conanfile)

# With requirements
conanfile = '''
from conans import ConanFile, CMake
import os
class HelloReuseConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake"
def requirements(self):
self.requires("Hello0/0.1@ lasote/stable")
def build(self):
cmake = CMake(self.settings)
self.run('cmake "%s" %s' % (self.conanfile_directory, cmake.command_line))
self.run("cmake --build . %s" % cmake.build_config)
def test(self):
# equal to ./bin/greet, but portable win: .\bin\greet
self.run(os.sep.join([".","bin", "greet"]))
'''
self._test_with_conanfile(conanfile)

def _test_with_conanfile(self, test_conanfile):
client = TestClient()
files = cpp_hello_conan_files("Hello0", "0.1")

cmakelist = """PROJECT(MyHello)
cmake_minimum_required(VERSION 2.8)
Expand Down

0 comments on commit 9b50da2

Please sign in to comment.