-
Notifications
You must be signed in to change notification settings - Fork 989
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
config of package_id default mode #4644
Merged
lasote
merged 9 commits into
conan-io:develop
from
memsharded:feature/new_package_id_modes
Mar 6, 2019
Merged
Changes from 4 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
70eaac8
config of package_id default mode
memsharded 9287bf8
Merge branch 'develop' into feature/new_package_id_modes
memsharded 598c642
Merge branch 'develop' into feature/new_package_id_modes
memsharded ae8e765
review
memsharded da04d59
Merge branch 'develop' into feature/new_package_id_modes
memsharded 87cf88f
Merge branch 'develop' into feature/new_package_id_modes
memsharded beb0d86
defaulting to semver_direct_mode
memsharded 073c022
fixing tests
memsharded ca707ab
more tests fixed
memsharded File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
import os | ||
import unittest | ||
|
||
from mock import Mock | ||
|
||
from conans.client.cache.cache import ClientCache | ||
from conans.client.graph.graph_manager import GraphManager | ||
from conans.client.graph.proxy import ConanProxy | ||
from conans.client.graph.python_requires import ConanPythonRequire | ||
from conans.client.graph.range_resolver import RangeResolver | ||
from conans.client.installer import BinaryInstaller | ||
from conans.client.loader import ConanFileLoader | ||
from conans.client.recorder.action_recorder import ActionRecorder | ||
from conans.model.graph_info import GraphInfo | ||
from conans.model.manifest import FileTreeManifest | ||
from conans.model.options import OptionsValues | ||
from conans.model.profile import Profile | ||
from conans.model.ref import ConanFileReference | ||
from conans.test.unittests.model.transitive_reqs_test import MockSearchRemote | ||
from conans.test.utils.conanfile import TestConanFile | ||
from conans.test.utils.test_files import temp_folder | ||
from conans.test.utils.tools import TestBufferConanOutput | ||
from conans.util.files import save | ||
|
||
|
||
class GraphManagerTest(unittest.TestCase): | ||
|
||
def setUp(self): | ||
self.output = TestBufferConanOutput() | ||
cache_folder = temp_folder() | ||
cache = ClientCache(cache_folder, os.path.join(cache_folder, ".conan"), self.output) | ||
self.cache = cache | ||
self.remote_search = MockSearchRemote() | ||
remote_manager = None | ||
self.resolver = RangeResolver(cache, self.remote_search) | ||
proxy = ConanProxy(cache, self.output, remote_manager) | ||
self.loader = ConanFileLoader(None, self.output, ConanPythonRequire(None, None)) | ||
self.manager = GraphManager(self.output, cache, remote_manager, self.loader, proxy, | ||
self.resolver) | ||
hook_manager = Mock() | ||
recorder = Mock() | ||
self.binary_installer = BinaryInstaller(cache, self.output, remote_manager, recorder, | ||
hook_manager) | ||
|
||
def _cache_recipe(self, reference, test_conanfile, revision=None): | ||
if isinstance(test_conanfile, TestConanFile): | ||
test_conanfile.info = True | ||
ref = ConanFileReference.loads(reference) | ||
save(self.cache.conanfile(ref), str(test_conanfile)) | ||
with self.cache.package_layout(ref).update_metadata() as metadata: | ||
metadata.recipe.revision = revision or "123" | ||
manifest = FileTreeManifest.create(self.cache.export(ref)) | ||
manifest.save(self.cache.export(ref)) | ||
|
||
def build_graph(self, content, profile_build_requires=None, ref=None): | ||
path = temp_folder() | ||
path = os.path.join(path, "conanfile.py") | ||
save(path, str(content)) | ||
self.loader.cached_conanfiles = {} | ||
|
||
profile = Profile() | ||
if profile_build_requires: | ||
profile.build_requires = profile_build_requires | ||
profile.process_settings(self.cache) | ||
update = check_updates = False | ||
recorder = ActionRecorder() | ||
remote_name = None | ||
build_mode = [] | ||
ref = ref or ConanFileReference(None, None, None, None, validate=False) | ||
options = OptionsValues() | ||
graph_info = GraphInfo(profile, options, root_ref=ref) | ||
deps_graph, _ = self.manager.load_graph(path, None, graph_info, | ||
build_mode, check_updates, update, | ||
remote_name, recorder) | ||
self.binary_installer.install(deps_graph, False, graph_info) | ||
return deps_graph | ||
|
||
def _check_node(self, node, ref, deps, build_deps, dependents, closure, public_deps): | ||
conanfile = node.conanfile | ||
ref = ConanFileReference.loads(str(ref)) | ||
self.assertEqual(node.ref.full_repr(), ref.full_repr()) | ||
self.assertEqual(conanfile.name, ref.name) | ||
self.assertEqual(len(node.dependencies), len(deps) + len(build_deps)) | ||
self.assertEqual(len(node.dependants), len(dependents)) | ||
|
||
public_deps = {n.name: n for n in public_deps} | ||
self.assertEqual(node.public_deps, public_deps) | ||
|
||
# The recipe requires is resolved to the reference WITH revision! | ||
self.assertEqual(len(deps), len(conanfile.requires)) | ||
for dep in deps: | ||
self.assertEqual(conanfile.requires[dep.name].ref, | ||
dep.ref) | ||
|
||
self.assertEqual(closure, node.public_closure) | ||
libs = [] | ||
envs = [] | ||
for n in closure: | ||
libs.append("mylib%s%slib" % (n.ref.name, n.ref.version)) | ||
envs.append("myenv%s%senv" % (n.ref.name, n.ref.version)) | ||
self.assertEqual(conanfile.deps_cpp_info.libs, libs) | ||
env = {"MYENV": envs} if envs else {} | ||
self.assertEqual(conanfile.deps_env_info.vars, env) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from conans.test.functional.graph.graph_manager_base import GraphManagerTest | ||
from conans.test.utils.conanfile import TestConanFile | ||
|
||
|
||
class PackageIDGraphTests(GraphManagerTest): | ||
|
||
def test_recipe_modes(self): | ||
configs = [] | ||
mode = "semver_mode" | ||
memsharded marked this conversation as resolved.
Show resolved
Hide resolved
|
||
configs.append((mode, "liba/1.1.1@user/testing", "8ecbf93ba63522ffb32573610c80ab4dcb399b52")) | ||
configs.append((mode, "liba/1.1.2@user/testing", "8ecbf93ba63522ffb32573610c80ab4dcb399b52")) | ||
configs.append((mode, "liba/1.2.1@other/stable", "8ecbf93ba63522ffb32573610c80ab4dcb399b52")) | ||
mode = "patch_mode" | ||
configs.append((mode, "liba/1.1.1@user/testing", "bd664570d5174c601d5d417bc19257c4dba48f2e")) | ||
configs.append((mode, "liba/1.1.2@user/testing", "fb1f766173191d44b67156c6b9ac667422e99286")) | ||
configs.append((mode, "liba/1.1.1@other/stable", "bd664570d5174c601d5d417bc19257c4dba48f2e")) | ||
mode = "full_recipe_mode" | ||
configs.append((mode, "liba/1.1.1@user/testing", "9cbe703e1dee73a2a6807f71d8551c5f1e1b08fd")) | ||
configs.append((mode, "liba/1.1.2@user/testing", "42a9ff9024adabbd54849331cf01be7d95139948")) | ||
configs.append((mode, "liba/1.1.1@user/stable", "b41d6c026473cffed4abded4b0eaa453497be1d2")) | ||
|
||
for package_id_mode, ref, package_id in configs: | ||
self.cache.config.set_item("general.default_package_id_mode", package_id_mode) | ||
libb_ref = "libb/0.1@user/testing" | ||
self._cache_recipe(ref, TestConanFile("liba", "0.1.1")) | ||
self._cache_recipe(libb_ref, TestConanFile("libb", "0.1", requires=[ref])) | ||
deps_graph = self.build_graph(TestConanFile("app", "0.1", requires=[libb_ref])) | ||
|
||
self.assertEqual(3, len(deps_graph.nodes)) | ||
app = deps_graph.root | ||
libb = app.dependencies[0].dst | ||
liba = libb.dependencies[0].dst | ||
|
||
self.assertEqual(liba.package_id, "5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9") | ||
self.assertEqual(libb.package_id, package_id) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the value be
None
orsemver
? Why not present in theconan.conf
? I would like to seedefault_package_id_mode=semver
explicit, always. In case someone doesn't have it, return "semver" instead of NoneThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The values shouldn't contain the "_mode" suffix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to see the possible values as comments in the conan.conf too. I even like the idea of having a link to the docs section if we feel this feature is important enough...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is different to not define a new default_package_id_mode, than defining it to semver. This is the logic:
So if defaults to
semver
it will never apply the currentunrelated_mode()
that is applying to indirect (transitive, but not declared) dependencies, changing the current behavior.Maybe we need to discuss this, but I thought that the new default mode would apply to all dependencies, transitive indirect dependencies too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really fail to see the whole picture now, so I will need a brief explanation