Repository: conan-io/conan
Pull request #17482 (2024-12-17 11:28:25)

Only warn on frozen conan v1 remote if enabled
Changelog: Feature: Only warn on frozen conan v1 remote if enabled.
Docs: Omit

cc/ @jcar87 





Patch:
diff --git a/conan/cli/cli.py b/conan/cli/cli.py
index 766b04f32..bd6c15a24 100644
--- a/conan/cli/cli.py
+++ b/conan/cli/cli.py
@@ -249,7 +249,7 @@ def _warn_python_version():
 def _warn_frozen_center(conan_api):
     remotes = conan_api.remotes.list()
     for r in remotes:
-        if r.url == "https://center.conan.io":
+        if r.url == "https://center.conan.io" and not r.disabled:
             ConanOutput().warning(
                 "The remote 'https://center.conan.io' is now frozen and has been replaced by 'https://center2.conan.io'. \n"
                 "Starting from Conan 2.9.2, the default remote is 'center2.conan.io'. \n"
diff --git a/conans/model/requires.py b/conans/model/requires.py
index b64e24bc8..5be2f3413 100644
--- a/conans/model/requires.py
+++ b/conans/model/requires.py
@@ -255,6 +255,7 @@ class Requirement:
         self.transitive_libs = self.transitive_libs or other.transitive_libs
         if not other.test:
             self.test = False  # it it was previously a test, but also required by non-test
+        # necessary even if no propagation, order of requires matter
         self.is_test = self.is_test or other.is_test
         # package_id_mode is not being propagated downstream. So it is enough to check if the
         # current require already defined it or not
@@ -347,7 +348,6 @@ class Requirement:
 
         if self.test:
             downstream_require.test = True
-        downstream_require.is_test = require.is_test
 
         # If the current one is resolving conflicts, the downstream one will be too
         downstream_require.force = require.force


Test patch:
diff --git a/test/integration/command/remote_test.py b/test/integration/command/remote_test.py
index 8a5b5b53e..4aab1d82d 100644
--- a/test/integration/command/remote_test.py
+++ b/test/integration/command/remote_test.py
@@ -366,6 +366,9 @@ def test_using_frozen_center():
     c.run("remote update conancenter --url=https://center.conan.io")
     assert "The remote 'https://center.conan.io' is now frozen and has been replaced by 'https://center2.conan.io'." in c.out
 
+    c.run("remote disable conancenter")
+    assert "The remote 'https://center.conan.io' is now frozen and has been replaced by 'https://center2.conan.io'." not in c.out
+
 
 def test_wrong_remotes_json_file():
     c = TestClient(light=True)
diff --git a/test/integration/graph/test_test_requires.py b/test/integration/graph/test_test_requires.py
index 5342bc3ad..d74bec93a 100644
--- a/test/integration/graph/test_test_requires.py
+++ b/test/integration/graph/test_test_requires.py
@@ -203,6 +203,8 @@ def test_requires_transitive_diamond_components_order():
     like the above, but in different order
      libc  --(test-requires)---> liba
        |-----> libb -----------/
+    libc->liba => test=False, direct=True, is_test=True
+    direct_dependencies (components check) => False
     https://github.com/conan-io/conan/issues/17164
     """
     c = TestClient(light=True)
@@ -230,6 +232,48 @@ def test_requires_transitive_diamond_components_order():
     assert "libc/0.1: Created package" in c.out
 
 
+def test_wrong_requirement_test_requires():
+    """ https://github.com/conan-io/conan/issues/17312
+
+    app --------> etas --------------> enum
+      \\-->hwinfo-/---(test_requires)---/
+       \\-----------------------------/
+
+    app->enum => test=False, direct=True, is_test=True
+    direct_dependencies (components check) => True
+    """
+    c = TestClient(light=True)
+    app = textwrap.dedent("""
+        from conan import ConanFile
+        class Pkg(ConanFile):
+            name = "app"
+            version = "0.1"
+            requires = "etas/0.1", "enum/0.1", "hwinfo/0.1"
+
+            def generate(self):
+                for r, d in self.dependencies.items():
+                    assert not (r.direct and r.is_test)
+
+            def package_info(self):
+                self.cpp_info.requires = ["etas::etas", "enum::enum", "hwinfo::hwinfo"]
+            """)
+    files = {
+        "enum/conanfile.py": GenConanfile("enum", "0.1"),
+        "etas/conanfile.py": GenConanfile("etas", "0.1").with_requirement("enum/0.1"),
+        "hwinfo/conanfile.py": GenConanfile("hwinfo", "0.1").with_requirement("etas/0.1")
+                                                            .with_test_requires("enum/0.1"),
+        "app/conanfile.py": app,
+    }
+    c.save(files)
+    c.run("create enum")
+    c.run("create etas")
+    c.run("create hwinfo")
+    # The assert in generate() doesnt fail
+    c.run("install app")
+    # the package_info() doesn't fail
+    c.run("create app")
+
+
 def test_test_requires_options():
     """ the default_options = {} values also propagate to ``test_requires()`` """
     c = TestClient(light=True)