Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
memsharded committed May 3, 2023
1 parent 08fd9e7 commit 293e7ed
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import textwrap
import unittest

import pytest

from conans.client.tools.env import environment_append
from conans.test.utils.tools import TestClient, GenConanfile

Expand Down Expand Up @@ -266,3 +268,22 @@ def test_test_package_build_require():

client.run("create pkg/conanfile.py pkg/1.0@ --build=missing --lockfile=conan.lock")
assert "pkg/1.0 (test package): Applying build-requirement: cmake/1.0" in client.out


@pytest.mark.parametrize("test_requires", [True, False])
def test_duplicated_build_host_require(test_requires):
c = TestClient()
if test_requires:
pkg = GenConanfile("pkg", "0.1").with_build_requirement("tool/[^4.0]",
force_host_context=True)
else:
pkg = GenConanfile("pkg", "0.1").with_requirement("tool/[^4.0]")
c.save({"tool/conanfile.py": GenConanfile("tool"),
"pkg/conanfile.py": pkg,
"profile": "[tool_requires]\ntool/[^3.0]"})
c.run("create tool 3.0@")
c.run("create tool 4.0@")
c.run("install pkg -pr:b=default -pr:h=profile --build")
assert "tool/4.0 from local cache - Cache" in c.out

This comment has been minimized.

Copy link
@SzBosch

SzBosch May 3, 2023

Contributor

Add a 2nd assert to check that also tool/3.0 is installed. Both tools (versions, contexts) need to be installed.

This comment has been minimized.

Copy link
@memsharded

memsharded May 3, 2023

Author Member

I only added the "offending" check, as I was assuming that the profile one will always be there (other tests will catch that if it wasn't this way). Certainly this could be added, but I already merged the PR, needs to go in a new PR.

Thanks for pointing this!

c.run("install pkg --lockfile=conan.lock")
assert "tool/4.0 from local cache - Cache" in c.out

This comment has been minimized.

Copy link
@SzBosch

SzBosch May 3, 2023

Contributor

Add a 2nd assert to check that also tool/3.0 is installed. Both tools (versions, contexts) need to be installed.

0 comments on commit 293e7ed

Please sign in to comment.