From 7be60f277a2c3bd8e7a5e4088324285c172028f4 Mon Sep 17 00:00:00 2001 From: "Javier G. Sogo" Date: Thu, 30 Aug 2018 10:34:40 +0200 Subject: [PATCH 1/6] add dependencies to package output info when binary is not found --- conans/client/installer.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/conans/client/installer.py b/conans/client/installer.py index f56ff494b08..85ddce67f97 100644 --- a/conans/client/installer.py +++ b/conans/client/installer.py @@ -220,15 +220,17 @@ def call_system_requirements(conanfile, output): raise ConanException("Error in system requirements") -def raise_package_not_found_error(conan_file, conan_ref, package_id, out, recorder): +def raise_package_not_found_error(conan_file, conan_ref, package_id, dependencies, out, recorder): settings_text = ", ".join(conan_file.info.full_settings.dumps().splitlines()) options_text = ", ".join(conan_file.info.full_options.dumps().splitlines()) + dependencies_text = ', '.join(dependencies) - msg = '''Can't find a '%s' package for the specified options and settings: + msg = '''Can't find a '%s' package for the specified settings, options and dependencies: - Settings: %s - Options: %s +- Dependencies: %s - Package ID: %s -''' % (conan_ref, settings_text, options_text, package_id) +''' % (conan_ref, settings_text, options_text, dependencies_text, package_id) out.warn(msg) recorder.package_install_error(PackageReference(conan_ref, package_id), INSTALL_ERROR_MISSING, msg) @@ -268,7 +270,9 @@ def _build(self, nodes_by_level, deps_graph, keep_build, root_node): output = ScopedOutput(str(conan_ref), self._out) package_id = conan_file.info.package_id() if node.binary == BINARY_MISSING: - raise_package_not_found_error(conan_file, conan_ref, package_id, output, self._recorder) + dependencies = [str(dep.dst) for dep in node.dependencies] + raise_package_not_found_error(conan_file, conan_ref, package_id, dependencies, + out=output, recorder=self._recorder) self._propagate_info(node, inverse_levels, deps_graph, output) if node.binary == BINARY_SKIP: # Privates not necessary From 13f5ee018d527a4a31802c7d60c87d3c802dfb48 Mon Sep 17 00:00:00 2001 From: "Javier G. Sogo" Date: Thu, 30 Aug 2018 14:17:58 +0200 Subject: [PATCH 2/6] add test --- .../integration/install_missing_dep_test.py | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 conans/test/integration/install_missing_dep_test.py diff --git a/conans/test/integration/install_missing_dep_test.py b/conans/test/integration/install_missing_dep_test.py new file mode 100644 index 00000000000..a2f33413a95 --- /dev/null +++ b/conans/test/integration/install_missing_dep_test.py @@ -0,0 +1,56 @@ +import unittest +from conans.test.utils.tools import TestClient, TestServer +from conans.model.ref import ConanFileReference, PackageReference +import os +from conans.test.utils.cpp_test_files import cpp_hello_conan_files +from conans.util.files import load, save +from time import sleep +import time +from conans.paths import CONAN_MANIFEST + + +class InstallMissingDependencie(unittest.TestCase): + + def setUp(self): + test_server = TestServer() + self.servers = {"myremote": test_server} + self.client = TestClient(servers=self.servers, users={"myremote": [("lasote", "mypass")]}) + + # Create deps packages + dep1_conanfile = """from conans import ConanFile +class Dep1Pkg(ConanFile): + name = "dep1" + version = "{version}" + """ + + dep2_conanfile = """from conans import ConanFile +class Dep2Pkg(ConanFile): + name = "dep2" + version = "1.0" + requires = "dep1/1.0@lasote/testing" + """ + + self.client.save({"conanfile.py": dep1_conanfile.format(version="1.0")}, clean_first=True) + self.client.run("create . lasote/testing") + + self.client.save({"conanfile.py": dep1_conanfile.format(version="2.0")}, clean_first=True) + self.client.run("create . lasote/testing") + + self.client.save({"conanfile.py": dep2_conanfile}, clean_first=True) + self.client.run("create . lasote/testing") + + def missing_dep_test(self): + foo_conanfile = """from conans import ConanFile +class FooPkg(ConanFile): + name = "foo" + version = "1.0" + requires = "dep1/{dep1_version}@lasote/testing", "dep2/1.0@lasote/testing" + """ + self.client.save({"conanfile.py": foo_conanfile.format(dep1_version="1.0")}, + clean_first=True) + self.client.run("create . lasote/testing") + + self.client.save({"conanfile.py": foo_conanfile.format(dep1_version="2.0")}, + clean_first=True) + self.client.run("create . lasote/testing") + From 038fc763d29687fff57d7c4a423bac88186042fb Mon Sep 17 00:00:00 2001 From: "Javier G. Sogo" Date: Thu, 30 Aug 2018 14:30:24 +0200 Subject: [PATCH 3/6] check that message contains expected messsages --- conans/test/integration/install_missing_dep_test.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/conans/test/integration/install_missing_dep_test.py b/conans/test/integration/install_missing_dep_test.py index a2f33413a95..6325ce13580 100644 --- a/conans/test/integration/install_missing_dep_test.py +++ b/conans/test/integration/install_missing_dep_test.py @@ -48,9 +48,12 @@ class FooPkg(ConanFile): """ self.client.save({"conanfile.py": foo_conanfile.format(dep1_version="1.0")}, clean_first=True) - self.client.run("create . lasote/testing") + error = self.client.run("create . lasote/testing") + self.assertFalse(error) self.client.save({"conanfile.py": foo_conanfile.format(dep1_version="2.0")}, clean_first=True) - self.client.run("create . lasote/testing") + self.client.run("create . lasote/testing", ignore_error=True) + self.assertIn("Can't find a 'dep2/1.0@lasote/testing' package", self.client.user_io.out) + self.assertIn("- Dependencies: dep1/2.0@lasote/testing", self.client.user_io.out) From 5c091a92cf14a4c65cde17232ecd4268efeb9b1f Mon Sep 17 00:00:00 2001 From: "Javier G. Sogo" Date: Thu, 30 Aug 2018 17:53:39 +0200 Subject: [PATCH 4/6] fixes according to @memsharded review: code simplification --- .../integration/install_missing_dep_test.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/conans/test/integration/install_missing_dep_test.py b/conans/test/integration/install_missing_dep_test.py index 6325ce13580..9c2284f4bf0 100644 --- a/conans/test/integration/install_missing_dep_test.py +++ b/conans/test/integration/install_missing_dep_test.py @@ -9,9 +9,9 @@ from conans.paths import CONAN_MANIFEST -class InstallMissingDependencie(unittest.TestCase): +class InstallMissingDependency(unittest.TestCase): - def setUp(self): + def missing_dep_test(self): test_server = TestServer() self.servers = {"myremote": test_server} self.client = TestClient(servers=self.servers, users={"myremote": [("lasote", "mypass")]}) @@ -20,7 +20,6 @@ def setUp(self): dep1_conanfile = """from conans import ConanFile class Dep1Pkg(ConanFile): name = "dep1" - version = "{version}" """ dep2_conanfile = """from conans import ConanFile @@ -30,16 +29,13 @@ class Dep2Pkg(ConanFile): requires = "dep1/1.0@lasote/testing" """ - self.client.save({"conanfile.py": dep1_conanfile.format(version="1.0")}, clean_first=True) - self.client.run("create . lasote/testing") - - self.client.save({"conanfile.py": dep1_conanfile.format(version="2.0")}, clean_first=True) - self.client.run("create . lasote/testing") + self.client.save({"conanfile.py": dep1_conanfile}, clean_first=True) + self.client.run("create . dep1/1.0@lasote/testing") + self.client.run("create . dep1/2.0@lasote/testing") self.client.save({"conanfile.py": dep2_conanfile}, clean_first=True) self.client.run("create . lasote/testing") - def missing_dep_test(self): foo_conanfile = """from conans import ConanFile class FooPkg(ConanFile): name = "foo" @@ -53,7 +49,8 @@ class FooPkg(ConanFile): self.client.save({"conanfile.py": foo_conanfile.format(dep1_version="2.0")}, clean_first=True) - self.client.run("create . lasote/testing", ignore_error=True) + error = self.client.run("create . lasote/testing", ignore_error=True) + self.assertTrue(error) self.assertIn("Can't find a 'dep2/1.0@lasote/testing' package", self.client.user_io.out) self.assertIn("- Dependencies: dep1/2.0@lasote/testing", self.client.user_io.out) From 3623f1a74ce583ab1005e253981355a42749e45d Mon Sep 17 00:00:00 2001 From: "Javier G. Sogo" Date: Thu, 30 Aug 2018 18:53:19 +0200 Subject: [PATCH 5/6] remove server and 'self.' from places where it is not needed --- .../integration/install_missing_dep_test.py | 33 +++++++++---------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/conans/test/integration/install_missing_dep_test.py b/conans/test/integration/install_missing_dep_test.py index 9c2284f4bf0..8a10396f6c2 100644 --- a/conans/test/integration/install_missing_dep_test.py +++ b/conans/test/integration/install_missing_dep_test.py @@ -12,9 +12,7 @@ class InstallMissingDependency(unittest.TestCase): def missing_dep_test(self): - test_server = TestServer() - self.servers = {"myremote": test_server} - self.client = TestClient(servers=self.servers, users={"myremote": [("lasote", "mypass")]}) + client = TestClient(users={"myremote": [("lasote", "mypass")]}) # Create deps packages dep1_conanfile = """from conans import ConanFile @@ -29,28 +27,27 @@ class Dep2Pkg(ConanFile): requires = "dep1/1.0@lasote/testing" """ - self.client.save({"conanfile.py": dep1_conanfile}, clean_first=True) - self.client.run("create . dep1/1.0@lasote/testing") - self.client.run("create . dep1/2.0@lasote/testing") + client.save({"conanfile.py": dep1_conanfile}, clean_first=True) + client.run("create . dep1/1.0@lasote/testing") + client.run("create . dep1/2.0@lasote/testing") - self.client.save({"conanfile.py": dep2_conanfile}, clean_first=True) - self.client.run("create . lasote/testing") + client.save({"conanfile.py": dep2_conanfile}, clean_first=True) + client.run("create . lasote/testing") + # Create final package foo_conanfile = """from conans import ConanFile class FooPkg(ConanFile): name = "foo" version = "1.0" requires = "dep1/{dep1_version}@lasote/testing", "dep2/1.0@lasote/testing" """ - self.client.save({"conanfile.py": foo_conanfile.format(dep1_version="1.0")}, - clean_first=True) - error = self.client.run("create . lasote/testing") - self.assertFalse(error) - - self.client.save({"conanfile.py": foo_conanfile.format(dep1_version="2.0")}, - clean_first=True) - error = self.client.run("create . lasote/testing", ignore_error=True) + client.save({"conanfile.py": foo_conanfile.format(dep1_version="1.0")}, clean_first=True) + client.run("create . lasote/testing") + + # Bump version of one dependency + client.save({"conanfile.py": foo_conanfile.format(dep1_version="2.0")}, clean_first=True) + error = client.run("create . lasote/testing", ignore_error=True) self.assertTrue(error) - self.assertIn("Can't find a 'dep2/1.0@lasote/testing' package", self.client.user_io.out) - self.assertIn("- Dependencies: dep1/2.0@lasote/testing", self.client.user_io.out) + self.assertIn("Can't find a 'dep2/1.0@lasote/testing' package", client.user_io.out) + self.assertIn("- Dependencies: dep1/2.0@lasote/testing", client.user_io.out) From 2a3af44ad4dd9968181ad338a845c18670aa8b58 Mon Sep 17 00:00:00 2001 From: "Javier G. Sogo" Date: Fri, 31 Aug 2018 10:02:08 +0200 Subject: [PATCH 6/6] remove unused imports --- conans/test/integration/install_missing_dep_test.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/conans/test/integration/install_missing_dep_test.py b/conans/test/integration/install_missing_dep_test.py index 8a10396f6c2..4f8ee2ffe32 100644 --- a/conans/test/integration/install_missing_dep_test.py +++ b/conans/test/integration/install_missing_dep_test.py @@ -1,12 +1,5 @@ import unittest -from conans.test.utils.tools import TestClient, TestServer -from conans.model.ref import ConanFileReference, PackageReference -import os -from conans.test.utils.cpp_test_files import cpp_hello_conan_files -from conans.util.files import load, save -from time import sleep -import time -from conans.paths import CONAN_MANIFEST +from conans.test.utils.tools import TestClient class InstallMissingDependency(unittest.TestCase):