Skip to content

Commit 99d11ad

Browse files
authored
test using workspace with replace-requires (#19339)
* using workspace.packages() for replace-requires logic * using replace_requires
1 parent 9d2fbfc commit 99d11ad

File tree

1 file changed

+25
-8
lines changed

1 file changed

+25
-8
lines changed

test/integration/workspace/test_workspace.py

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -238,13 +238,6 @@ def test_api_dynamic_any_version(self):
238238
# For workspace, the version of the conanfile can be ignored if the
239239
# workspace define a different version.
240240
c = TestClient(light=True)
241-
conanfile = textwrap.dedent("""
242-
from conan import ConanFile
243-
class Lib(ConanFile):
244-
name= "pkg"
245-
version = "0.1"
246-
""")
247-
248241
workspace = textwrap.dedent("""\
249242
import os
250243
from conan import Workspace
@@ -255,13 +248,37 @@ def packages(self):
255248
""")
256249

257250
c.save({"conanws.py": workspace,
258-
"dep1/conanfile.py": conanfile})
251+
"dep1/conanfile.py": GenConanfile("pkg", "0.1")})
259252
c.run("workspace info --format=json")
260253
info = json.loads(c.stdout)
261254
assert info["packages"] == [{"ref": "pkg/1.2.3", "path": "dep1"}]
262255
c.run("install --requires=pkg/1.2.3")
263256
# it will not fail
264257

258+
def test_replace_requires(self):
259+
c = TestClient(light=True)
260+
c.save({"conanws.yml": "",
261+
"pkga/conanfile.py": GenConanfile("pkga", "0.1"),
262+
"pkgb/conanfile.py": GenConanfile("pkgb", "0.1").with_requires("pkga/develop"),
263+
"pkgc/conanfile.py": GenConanfile("pkgc", "0.1").with_requires("pkgb/0.1",
264+
"pkga/0.1"),
265+
"myreplaces": "[replace_requires]\npkga/develop: pkga/0.1"})
266+
c.run("workspace add pkga")
267+
c.run("workspace add pkgb")
268+
c.run("workspace add pkgc")
269+
c.run("workspace info --format=json")
270+
271+
info = json.loads(c.stdout)
272+
assert info["packages"] == [{'path': 'pkga', 'ref': 'pkga/0.1'},
273+
{'path': 'pkgb', 'ref': 'pkgb/0.1'},
274+
{'path': 'pkgc', 'ref': 'pkgc/0.1'}]
275+
c.run("install --requires=pkgc/0.1", assert_error=True)
276+
assert "Version conflict: Conflict between pkga/develop and pkga/0.1 in the graph" in c.out
277+
# it will not fail
278+
c.run("install --requires=pkgc/0.1 -pr=default -pr=myreplaces")
279+
assert "pkga/0.1 - Editable" in c.out
280+
assert "pkga/develop: pkga/0.1" in c.out
281+
265282
def test_error_uppercase(self):
266283
c = TestClient(light=True)
267284
c.save({"conanws.yml": "",

0 commit comments

Comments
 (0)