Skip to content
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

fix and remove more xfails #15251

Merged
merged 1 commit into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 1 addition & 77 deletions conans/test/integration/command/upload/upload_complete_test.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
import json
import os
import textwrap
import unittest

import pytest
from requests import ConnectionError

from conans.paths import CONAN_MANIFEST
from conans.test.utils.tools import (NO_SETTINGS_PACKAGE_ID, TestClient, TestRequester, TestServer,
from conans.test.utils.tools import (TestClient, TestRequester, TestServer,
GenConanfile)
from conans.util.env import environment_update
from conans.util.files import load


class BadConnectionUploader(TestRequester):
Expand Down Expand Up @@ -242,75 +238,3 @@ def test_upload_same_package_dont_compress(self):
client.run("upload foo/1.0 -r default")
self.assertNotIn("Compressing", client.out)
self.assertIn("already in server, skipping upload", client.out)

@pytest.mark.xfail(reason="No output json available yet for upload. Also old test, has to be "
"upgraded")
def test_upload_json(self):
conanfile = textwrap.dedent("""
from conan import ConanFile
from conan.tools.files import copy

class TestConan(ConanFile):
name = "test"
version = "0.1"

def package(self):
copy(self, "mylib.so", self.build_folder, os.path.join(self.package_folder, "lib"))
""")

client = self._get_client()
client.save({"conanfile.py": conanfile,
"mylib.so": ""})
client.run("create . danimtb/testing")

# Test conflict parameter error
client.run("upload test/0.1@danimtb/* -p ewvfw --json upload.json", assert_error=True)

json_path = os.path.join(client.current_folder, "upload.json")
self.assertTrue(os.path.exists(json_path))
json_content = load(json_path)
output = json.loads(json_content)
self.assertTrue(output["error"])
self.assertEqual(0, len(output["uploaded"]))

# Test invalid reference error
client.run("upload fake/0.1@danimtb/testing --json upload.json", assert_error=True)
json_path = os.path.join(client.current_folder, "upload.json")
self.assertTrue(os.path.exists(json_path))
json_content = load(json_path)
output = json.loads(json_content)
self.assertTrue(output["error"])
self.assertEqual(0, len(output["uploaded"]))

# Test normal upload
client.run("upload test/0.1@danimtb/testing --json upload.json")
self.assertTrue(os.path.exists(json_path))
json_content = load(json_path)
output = json.loads(json_content)
output_expected = {"error": False,
"uploaded": [
{
"recipe": {
"id": "test/0.1@danimtb/testing",
"remote_url": "unknown",
"remote_name": "default",
"time": "unknown"
},
"packages": [
{
"id": NO_SETTINGS_PACKAGE_ID,
"time": "unknown"
}
]
}
]}
self.assertEqual(output_expected["error"], output["error"])
self.assertEqual(len(output_expected["uploaded"]), len(output["uploaded"]))

for i, item in enumerate(output["uploaded"]):
self.assertEqual(output_expected["uploaded"][i]["recipe"]["id"], item["recipe"]["id"])
self.assertEqual(output_expected["uploaded"][i]["recipe"]["remote_name"],
item["recipe"]["remote_name"])
for j, subitem in enumerate(item["packages"]):
self.assertEqual(output_expected["uploaded"][i]["packages"][j]["id"],
subitem["id"])
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import unittest
import textwrap

import pytest

from conans.test.utils.tools import TestClient, GenConanfile


Expand Down Expand Up @@ -109,38 +107,30 @@ def build(self):
os = Windows
""")

@pytest.mark.xfail(reason="cache2.0 revisit test")
def test_br_from_profile_host_and_profile_build(self):
t = TestClient()
t.save({'profile_host': self.profile_host,
'profile_build': self.profile_build,
'library.py': self.library_conanfile,
'mytoolchain.py': self.toolchain,
"gtest.py": self.gtest})
t.run("create mytoolchain.py --profile=profile_build")
t.run("create mytoolchain.py --profile=profile_host")

# old way, the toolchain will have the same profile (profile_host=Linux) only
t.run("create gtest.py --profile:host=profile_host --profile:build=profile_host")
self.assertIn("mytoolchain/1.0: PackageInfo OS=Linux", t.out)
self.assertIn("gtest/1.0: Build OS=Linux", t.out)
t.run("create mytoolchain.py -pr:h=profile_host -pr:b=profile_build --build-require")

# new way, the toolchain can now run in Windows, but gtest in Linux
t.run("create gtest.py --profile=profile_host --profile:build=profile_build")
t.run("create gtest.py -pr=profile_host -pr:b=profile_build")
self.assertIn("mytoolchain/1.0: PackageInfo OS=Windows", t.out)
self.assertIn("gtest/1.0: PackageInfo OS=Linux", t.out)

t.run("create gtest.py --profile=profile_host --profile:build=profile_build --build")
t.run("create gtest.py -pr=profile_host -pr:b=profile_build --build=*")
self.assertIn("mytoolchain/1.0: PackageInfo OS=Windows", t.out)
self.assertIn("gtest/1.0: Build OS=Linux", t.out)
self.assertIn("gtest/1.0: PackageInfo OS=Linux", t.out)

t.run("create library.py --profile:host=profile_host --profile:build=profile_build")
t.run("create library.py -pr:h=profile_host -pr:b=profile_build")
self.assertIn("gtest/1.0: PackageInfo OS=Linux", t.out)
self.assertIn("library/version: Build OS=Linux", t.out)
self.assertIn("mytoolchain/1.0: PackageInfo OS=Windows", t.out)

t.run("create library.py --profile:host=profile_host --profile:build=profile_build --build")
t.run("create library.py -pr:h=profile_host -pr:b=profile_build --build=*")
self.assertIn("gtest/1.0: Build OS=Linux", t.out)
self.assertIn("gtest/1.0: PackageInfo OS=Linux", t.out)
self.assertIn("library/version: Build OS=Linux", t.out)
Expand Down Expand Up @@ -212,10 +202,9 @@ def build(self):
[settings]
os = Windows
[tool_requires]
creator/1.0
mytoolchain*:creator/1.0
""")

@pytest.mark.xfail(reason="cache2.0 revisit test")
def test_build_requires_both_contexts(self):
t = TestClient()
t.save({'profile_host': self.profile_host,
Expand All @@ -224,8 +213,8 @@ def test_build_requires_both_contexts(self):
'creator.py': self.toolchain_creator,
'mytoolchain.py': self.toolchain,
"gtest.py": self.gtest})
t.run("create creator.py --profile=profile_build -pr:b=profile_build")
t.run("create mytoolchain.py --profile:host=profile_build -pr:b=profile_build")
t.run("create creator.py -pr=profile_build")
t.run("create mytoolchain.py -pr:h=profile_host -pr:b=profile_build --build-require")
self.assertIn("creator/1.0: PackageInfo OS=Windows", t.out)
self.assertIn("mytoolchain/1.0: Build OS=Windows", t.out)

Expand All @@ -234,7 +223,7 @@ def test_build_requires_both_contexts(self):
self.assertNotIn("creator/1.0: PackageInfo", t.out) # Creator is skipped now, not needed
self.assertIn("gtest/1.0: PackageInfo OS=Linux", t.out)

t.run("create gtest.py --profile=profile_host --profile:build=profile_build --build")
t.run("create gtest.py --profile=profile_host --profile:build=profile_build --build=*")
self.assertIn("creator/1.0: PackageInfo OS=Windows", t.out)
self.assertIn("gtest/1.0: PackageInfo OS=Linux", t.out)

Expand All @@ -260,12 +249,12 @@ def package_info(self):
self.assertIn("creator/1.0: PackageInfo OS=Windows", t.out)
self.assertIn("mytoolchain/1.0: Build OS=Windows", t.out)

t.run("create gtest.py --profile=profile_host --profile:build=profile_build --build")
t.run("create gtest.py --profile=profile_host --profile:build=profile_build --build=*")
self.assertIn("creator/1.0: PackageInfo OS=Windows", t.out)
self.assertIn("mytoolchain/1.0: Build OS=Windows", t.out)
self.assertIn("gtest/1.0: Build OS=Linux", t.out)

t.run("create library.py --profile:host=profile_host --profile:build=profile_build --build")
t.run("create library.py -pr:h=profile_host --profile:build=profile_build --build=*")
self.assertIn("creator/1.0: PackageInfo OS=Windows", t.out)
self.assertIn("mytoolchain/1.0: Build OS=Windows", t.out)
self.assertIn("gtest/1.0: Build OS=Linux", t.out)
Expand Down
60 changes: 11 additions & 49 deletions conans/test/integration/graph/core/test_build_requires.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,66 +222,28 @@ def test_build_require_transitive_shared(self):
self._check_node(mingw, "mingw/0.1#123", deps=[zlib2], dependents=[lib])
self._check_node(zlib2, "zlib/0.2#123", deps=[], dependents=[mingw])

@pytest.mark.xfail(reason="Not updated yet")
def test_build_require_conflict(self):
# https://github.com/conan-io/conan/issues/4931
# cheetah -> gazelle -> grass/0.1
# \--(br)----------> grass/0.2
grass01_ref = RecipeReference.loads("grass/0.1@user/testing")
grass02_ref = RecipeReference.loads("grass/0.2@user/testing")
gazelle_ref = RecipeReference.loads("gazelle/0.1@user/testing")

self._cache_recipe(grass01_ref, GenConanfile().with_name("grass").with_version("0.1"))
self._cache_recipe(grass02_ref, GenConanfile().with_name("grass").with_version("0.2"))
self._cache_recipe(gazelle_ref, GenConanfile().with_name("gazelle").with_version("0.1")
.with_require(grass01_ref))
self._cache_recipe("grass/0.1", GenConanfile())
self._cache_recipe("grass/0.2", GenConanfile())
self._cache_recipe("gazelle/0.1", GenConanfile().with_require("grass/0.1"))

deps_graph = self.build_graph(GenConanfile().with_name("cheetah").with_version("0.1")
.with_require(gazelle_ref)
.with_tool_requires(grass02_ref))
deps_graph = self.build_graph(GenConanfile("cheetah", "0.1")
.with_require("gazelle/0.1")
.with_tool_requires("grass/0.2"))

self.assertEqual(4, len(deps_graph.nodes))
app = deps_graph.root
libb = app.dependencies[0].dst
libc = app.dependencies[1].dst
liba1 = libb.dependencies[0].dst
liba2 = libc.dependencies[0].dst
self._check_node(app, "app/0.1", deps=[libb, libc])
self._check_node(libb, "libb/0.1#123", deps=[liba1], dependents=[app])
self._check_node(libc, "libc/0.1#123", deps=[liba2], dependents=[app])

self._check_node(liba1, "liba/0.1#123", dependents=[libb])
# TODO: Conflicted without revision
self._check_node(liba2, "liba/0.2", dependents=[libc])

assert liba1.conflict == liba2
assert liba2.conflict == liba1

@pytest.mark.xfail(reason="Not updated yet")
def test_build_require_link_order(self):
# https://github.com/conan-io/conan/issues/4931
# cheetah -> gazelle -> grass
# \--(br)------------/
grass01_ref = RecipeReference.loads("grass/0.1@user/testing")
gazelle_ref = RecipeReference.loads("gazelle/0.1@user/testing")

self._cache_recipe(grass01_ref, GenConanfile().with_name("grass").with_version("0.1"))
self._cache_recipe(gazelle_ref, GenConanfile().with_name("gazelle").with_version("0.1")
.with_require(grass01_ref))

deps_graph = self.build_graph(GenConanfile().with_name("cheetah").with_version("0.1")
.with_require(gazelle_ref)
.with_tool_requires(grass01_ref))

self.assertEqual(3, len(deps_graph.nodes))
cheetah = deps_graph.root
gazelle = cheetah.dependencies[0].dst
grass = gazelle.dependencies[0].dst
grass2 = cheetah.dependencies[1].dst

self._check_node(cheetah, "cheetah/0.1@", deps=[gazelle], dependents=[])
self.assertListEqual(list(cheetah.conanfile.deps_cpp_info.libs),
['mylibgazelle0.1lib', 'mylibgrass0.1lib'])
grass1 = gazelle.dependencies[0].dst
self._check_node(cheetah, "cheetah/0.1", deps=[gazelle, grass2])
self._check_node(gazelle, "gazelle/0.1#123", deps=[grass1], dependents=[cheetah])
self._check_node(grass1, "grass/0.1#123", deps=[], dependents=[gazelle])
self._check_node(grass2, "grass/0.2#123", dependents=[cheetah])


class TestTestRequire(GraphManagerTest):
Expand Down
Loading