Exemplo n.º 1
0
    def missing_dep_test(self):
        client = TestClient()

        # Create deps packages
        dep1_conanfile = GenConanfile("dep1")
        client.save({"conanfile.py": dep1_conanfile}, clean_first=True)
        client.run("create . dep1/1.0@lasote/testing")
        client.run("create . dep1/2.0@lasote/testing")

        dep2_conanfile = GenConanfile(
            "dep2", "1.0").with_require_plain("dep1/1.0@lasote/testing")
        client.save({"conanfile.py": dep2_conanfile}, clean_first=True)
        client.run("create . lasote/testing")

        # Create final package
        conanfile = GenConanfile("foo", "1.0").with_require_plain("dep1/1.0@lasote/testing")\
                                              .with_require_plain("dep2/1.0@lasote/testing")
        client.save({"conanfile.py": conanfile}, clean_first=True)
        client.run("create . lasote/testing")

        # Bump version of one dependency
        conanfile = GenConanfile("foo", "1.0").with_require_plain("dep1/2.0@lasote/testing") \
                                              .with_require_plain("dep2/1.0@lasote/testing")
        client.save({"conanfile.py": conanfile}, clean_first=True)
        client.run("create . lasote/testing", assert_error=True)

        self.assertIn("Can't find a 'dep2/1.0@lasote/testing' package",
                      client.out)
        self.assertIn("- Dependencies: dep1/2.0@lasote/testing", client.out)
Exemplo n.º 2
0
Arquivo: tools.py Projeto: stkw0/conan
    def massive_uploader(self, ref, revisions, num_prev, remote=None):
        """Uploads N revisions with M package revisions. The revisions can be specified like:
            revisions = [{"os": "Windows"}, {"os": "Linux"}], \
                        [{"os": "Macos"}], \
                        [{"os": "Solaris"}, {"os": "FreeBSD"}]

            IMPORTANT: Different settings keys will cause different recipe revisions
        """
        remote = remote or "default"
        ret = []
        for i, settings_groups in enumerate(revisions):
            tmp = []
            for settings in settings_groups:
                conanfile_gen = GenConanfile(). \
                    with_build_msg("REV{}".format(i)). \
                    with_package_file("file", env_var="MY_VAR")
                for s in settings.keys():
                    conanfile_gen = conanfile_gen.with_setting(s)
                for k in range(num_prev):
                    args = " ".join(["-s {}={}".format(key, value)
                                     for key, value in settings.items()])
                    with environment_append({"MY_VAR": str(k)}):
                        pref = self.create(ref, conanfile=conanfile_gen, args=args)
                        self.upload_all(ref, remote=remote)
                        tmp.append(pref)
                ret.append(tmp)
        return ret
Exemplo n.º 3
0
    def setUp(self):
        self.ref = ConanFileReference.loads('lib/version@user/name')
        self.ref_child = ConanFileReference.loads('child/version@user/name')

        self.t = TestClient(path_with_spaces=False)
        self.t.save({'conanfile.py': GenConanfile()})
        self.t.run('create . parent/version@user/name')

        lib_folder = os.path.join(self.t.current_folder, 'lib')
        conan_package_layout = textwrap.dedent("""\
            [includedirs]
            src/include
            """)
        self.t.save({
            'lib/conanfile.py':
            GenConanfile().with_requires("parent/version@user/name"),
            "lib/mylayout":
            conan_package_layout
        })
        self.t.run('editable add "{}" {}'.format(lib_folder, self.ref))
        self.assertTrue(self.t.cache.installed_as_editable(self.ref))

        # Create child
        self.t.save({'conanfile.py': GenConanfile().with_requires(self.ref)})
        self.t.run('export . {}'.format(self.ref_child))
Exemplo n.º 4
0
 def component_not_found_same_name_as_pkg_require_test(self):
     zlib = GenConanfile("zlib", "0.1").with_setting("build_type")\
         .with_generator("pkg_config")
     mypkg = GenConanfile("mypkg", "0.1").with_setting("build_type")\
         .with_generator("pkg_config")
     final = GenConanfile("final", "0.1").with_setting("build_type")\
         .with_generator("pkg_config")\
         .with_require(ConanFileReference("zlib", "0.1", None, None))\
         .with_require(ConanFileReference("mypkg", "0.1", None, None))\
         .with_package_info(cpp_info={"components": {"cmp": {"requires": ["mypkg::zlib",
                                                                          "zlib::zlib"]}}},
                            env_info={})
     consumer = GenConanfile("consumer", "0.1").with_setting("build_type")\
         .with_generator("pkg_config")\
         .with_requirement(ConanFileReference("final", "0.1", None, None))
     client = TestClient()
     client.save({
         "zlib.py": zlib,
         "mypkg.py": mypkg,
         "final.py": final,
         "consumer.py": consumer
     })
     client.run("create zlib.py")
     client.run("create mypkg.py")
     client.run("create final.py")
     client.run("install consumer.py", assert_error=True)
     self.assertIn(
         "Component 'mypkg::zlib' not found in 'mypkg' package requirement",
         client.out)
Exemplo n.º 5
0
    def test_cmake_find_dependency_redefinition(self):
        conanfile = textwrap.dedent("""
            from conans import ConanFile, CMake
            class Consumer(ConanFile):
                name = "App"
                version = "1.0"
                requires = "PkgC/1.0@user/testing"
                generators = "cmake_find_package"
                exports_sources = "CMakeLists.txt"
                settings = "os", "arch", "compiler"

                def build(self):
                    cmake = CMake(self)
                    cmake.configure()

        """)

        cmakelists = textwrap.dedent("""
            cmake_minimum_required(VERSION 3.0)
            project(app)
            find_package(PkgC)
        """)

        client = TestClient()
        client.save({"conanfile.py": GenConanfile()})
        client.run("create . PkgA/1.0@user/testing")
        client.save({"conanfile.py": GenConanfile().with_require("PkgA/1.0@user/testing")})
        client.run("create . PkgB/1.0@user/testing")
        client.save({"conanfile.py": GenConanfile().with_require("PkgB/1.0@user/testing")
                                                   .with_require("PkgA/1.0@user/testing")})
        client.run("create . PkgC/1.0@user/testing")
        client.save({"conanfile.py": conanfile,
                     "CMakeLists.txt": cmakelists})
        client.run("create . App/1.0@user/testing")
        self.assertIn("Dependency PkgA already found", client.out)
Exemplo n.º 6
0
    def missing_multiple_dep_test(self):
        client = TestClient()

        dep1_conanfile = GenConanfile()
        client.save({"conanfile.py": dep1_conanfile}, clean_first=True)
        client.run("export . dep1/1.0@")
        client.run("export . dep2/1.0@")

        conanfile = GenConanfile().with_require("dep1/1.0").with_require("dep2/1.0")
        client.save({"conanfile.py": conanfile}, clean_first=True)
        client.run("create . pkg/1.0@", assert_error=True)
        self.assertIn("ERROR: Missing prebuilt package for 'dep1/1.0', 'dep2/1.0'", client.out)
        self.assertIn('Try to build from sources with "--build=dep1 --build=dep2"', client.out)
Exemplo n.º 7
0
    def test_custom_settings(self):
        settings = textwrap.dedent("""\
            os:
                None:
                Windows:
                    subsystem: [None, cygwin]
                Linux:
            compiler: [gcc, visual]
            """)
        client = TestClient()
        save(client.cache.settings_path, settings)
        save(client.cache.default_profile_path, "")

        client.save({"conanfile.py": GenConanfile().with_settings("os", "compiler")})
        client.run("create . Pkg/0.1@lasote/testing -s compiler=gcc")
        self.assertIn("544c1d8c53e9d269737e68e00ec66716171d2704", client.out)
        client.run("search Pkg/0.1@lasote/testing")
        self.assertNotIn("os: None", client.out)
        pref = PackageReference.loads("Pkg/0.1@lasote/testing:"
                                      "544c1d8c53e9d269737e68e00ec66716171d2704")
        info_path = os.path.join(client.cache.package_layout(pref.ref).package(pref), CONANINFO)
        info = load(info_path)
        self.assertNotIn("os", info)
        # Explicitly specifying None, put it in the conaninfo.txt, but does not affect the hash
        client.run("create . Pkg/0.1@lasote/testing -s compiler=gcc -s os=None")
        self.assertIn("544c1d8c53e9d269737e68e00ec66716171d2704", client.out)
        client.run("search Pkg/0.1@lasote/testing")
        self.assertIn("os: None", client.out)
        info = load(info_path)
        self.assertIn("os", info)
Exemplo n.º 8
0
 def no_build_type_error_test(self):
     client = TestClient()
     client.save({"conanfile.py": GenConanfile()})
     client.run("create . mypkg/0.1@")
     client.run("install mypkg/0.1@ -g msbuild -s build_type=None", assert_error=True)
     self.assertIn("ERROR: The 'msbuild' generator requires a 'build_type' setting value",
                   client.out)
Exemplo n.º 9
0
    def install_reference_gcc_test(self):
        client = TestClient()
        client.save({"conanfile.py": GenConanfile()})
        client.run("create . pkg/1.0@")

        conanfile = textwrap.dedent("""
                    from conans import ConanFile
                    class Pkg(ConanFile):
                        settings = "os", "compiler", "arch", "build_type"
                        generators = "msbuild"
                        requires = "pkg/1.0"
                    """)
        client.save({"conanfile.py": conanfile})

        client.run('install . -s os=Windows -s compiler="Visual Studio" -s compiler.version=15'
                   ' -s compiler.runtime=MD')
        self.assertIn("conanfile.py: Generator msbuild created conan_deps.props", client.out)
        client.run("install . -s os=Linux -s compiler=gcc -s compiler.version=5.2 '"
                   "'-s compiler.libcxx=libstdc++")

        self.assertIn("conanfile.py: Generator msbuild created conan_deps.props", client.out)
        self.assertIn("conanfile.py: Generator msbuild created conan_pkg.props", client.out)
        self.assertIn("conanfile.py: Generator msbuild created conan_pkg_release_x64.props",
                      client.out)

        pkg_props = client.load("conan_pkg.props")
        self.assertIn('Project="conan_pkg_release_x64.props"', pkg_props)
Exemplo n.º 10
0
 def install_reference_test(self):
     client = TestClient()
     client.save({"conanfile.py": GenConanfile()})
     client.run("create . mypkg/0.1@")
     client.run("install mypkg/0.1@ -g msbuild")
     self.assertIn("Generator msbuild created conan_deps.props", client.out)
     self.assertIn("Generator msbuild created conan_mypkg.props", client.out)
Exemplo n.º 11
0
 def test_config_home_custom_install(self):
     cache_folder = os.path.join(temp_folder(), "custom")
     with environment_append({"CONAN_USER_HOME": cache_folder}):
         client = TestClient(cache_folder=cache_folder,
                             cache_autopopulate=False)
         client.save({"conanfile.py": GenConanfile()})
         client.run("install .")
         self.assertIn("conanfile.py: Installing package", client.out)
Exemplo n.º 12
0
Arquivo: tools.py Projeto: stkw0/conan
 def export(self, ref, conanfile=GenConanfile(), args=None):
     """ export a ConanFile with as "ref" and return the reference with recipe revision
     """
     if conanfile:
         self.save({"conanfile.py": conanfile})
     self.run("export . {} {}".format(ref.full_str(), args or ""))
     rrev = self.cache.package_layout(ref).recipe_revision()
     return ref.copy_with_rev(rrev)
Exemplo n.º 13
0
 def empty_include_test(self):
     client = TestClient()
     client.save({"conanfile.py": GenConanfile()})
     client.run("create . pkg/0.1@")
     client.run("install pkg/0.1@ -g=pkg_config")
     pc = client.load("pkg.pc")
     self.assertNotIn("libdir=${prefix}/lib", pc)
     self.assertNotIn("includedir=${prefix}/include", pc)
Exemplo n.º 14
0
 def test_invalid_settings(self):
     # Test wrong values and wrong constraints
     client = TestClient()
     # MISSING VALUE FOR A SETTING
     client.save({CONANFILE: GenConanfile().with_settings("os", "build_type"),
                  "profile": "[settings]\nbuild_type=Release"})
     client.run("install . -pr=profile --build missing", assert_error=True)
     self.assertIn(str(undefined_value("settings.os")), str(client.out))
Exemplo n.º 15
0
    def test_removed_references(self):
        self.client.save({"conanfile.py": GenConanfile()})
        self.client.run("create . lib/1.0@lasote/channel")
        self.client.run('upload "*" -c -r remote1')
        self.client.run('upload "*" -c -r remote2')

        self.client.run('remote list_ref')
        ref = "lib/1.0@lasote/channel"
        pref = "%s:%s" % (ref, NO_SETTINGS_PACKAGE_ID)
        self.assertIn("%s: remote1" % ref, self.client.out)

        # Remove from remote2, the reference should be kept there
        self.client.run('remove "lib/1.0@lasote/channel" -f -r remote2')
        self.client.run('remote list_ref')
        self.assertIn("%s: remote1" % ref, self.client.out)

        # Upload again to remote2 and remove from remote1, the ref shouldn't be removed
        self.client.run('upload "*" -c -r remote2')
        self.client.run('remove "lib/1.0@lasote/channel" -f -r remote1')
        self.client.run('remote list_ref')
        self.assertIn("%s: remote1" % ref, self.client.out)

        # Test the packages references now
        self.client.run('upload "*" -c -r remote1 --all')
        self.client.run('upload "*" -c -r remote2 --all')
        self.client.run('remote list_pref lib/1.0@lasote/channel')
        self.assertIn("%s: remote1" % pref, self.client.out)

        # Remove from remote2, the reference should be kept there
        self.client.run('remove "lib/1.0@lasote/channel" '
                        '-p %s -f -r remote2' % NO_SETTINGS_PACKAGE_ID)
        self.client.run('remote list_pref lib/1.0@lasote/channel')
        self.assertIn("%s: remote1" % pref, self.client.out)

        # Upload again to remote2 and remove from remote1, the ref shouldn't be removed
        self.client.run('upload "*" -c -r remote2 --all')
        self.client.run('remove "lib/1.0@lasote/channel" '
                        '-p %s -f -r remote1' % NO_SETTINGS_PACKAGE_ID)
        self.client.run('remote list_ref')
        self.assertIn("%s: remote1" % ref, self.client.out)
        self.client.run('remote list_pref lib/1.0@lasote/channel')
        self.assertIn("%s: remote1" % pref, self.client.out)

        # Remove package locally
        self.client.run('upload "*" -c -r remote1 --all')
        self.client.run('remote list_pref lib/1.0@lasote/channel')
        self.assertIn("%s: remote1" % pref, self.client.out)
        self.client.run('remove "lib/1.0@lasote/channel" '
                        '-p %s -f' % NO_SETTINGS_PACKAGE_ID)
        self.client.run('remote list_pref lib/1.0@lasote/channel')
        self.assertNotIn("%s: remote1" % pref, self.client.out)

        # If I remove all in local, I also remove packages
        self.client.run("create . lib/1.0@lasote/channel")
        self.client.run('upload "*" -c -r remote1')
        self.client.run('remove "lib/1.0@lasote/channel" -f')
        self.client.run('remote list_pref lib/1.0@lasote/channel')
        self.assertEqual("", self.client.out)
Exemplo n.º 16
0
 def install_reference_gcc_test(self):
     client = TestClient()
     client.save({"conanfile.py": GenConanfile()})
     client.run("create . mypkg/0.1@ -s compiler=gcc")
     client.run("install mypkg/0.1@ -s compiler=gcc -g msbuild",
                assert_error=True)
     self.assertIn(
         "The 'msbuild' generator only works with Visual Studio compiler",
         client.out)
Exemplo n.º 17
0
    def setUp(self):
        self.ref = ConanFileReference.loads('lib/version@user/name')

        self.t = TestClient()
        self.t.save({'conanfile.py': GenConanfile()})
        self.t.run('create . parent/version@user/name')
        conan_package_layout = textwrap.dedent("""\
            [includedirs]
            src/include
            """)
        self.t.save({
            'conanfile.py':
            GenConanfile().with_require("parent/version@user/name"),
            "mylayout":
            conan_package_layout
        })
        self.t.run('editable add . {}'.format(self.ref))
        self.assertTrue(self.t.cache.installed_as_editable(self.ref))
Exemplo n.º 18
0
    def test(self):
        client = TestClient()

        client.run("new dep/0.1 -b")
        client.run("create . user/testing")
        pkg = GenConanfile("pkg", "0.1").with_requires("dep/0.1@user/testing")
        client.save({"conanfile.py": pkg}, clean_first=True)
        client.run("create . user/testing")
        client.run("install pkg/0.1@user/testing -g=qbs")
        qbs = client.load("conanbuildinfo.qbs")
        self.assertIn('Depends { name: "dep" }', qbs)
Exemplo n.º 19
0
Arquivo: tools.py Projeto: stkw0/conan
 def export_pkg(self, ref, conanfile=GenConanfile(), args=None, assert_error=False):
     if conanfile:
         self.save({"conanfile.py": conanfile})
     self.run("export-pkg . {} {} --json {}".format(ref.full_str(),
                                                    args or "", self.tmp_json_name),
              assert_error=assert_error)
     rrev = self.cache.package_layout(ref).recipe_revision()
     data = json.loads(self.load(self.tmp_json_name))
     if assert_error:
         return None
     package_id = data["installed"][0]["packages"][0]["id"]
     package_ref = PackageReference(ref, package_id)
     prev = self.cache.package_layout(ref.copy_clear_rev()).package_revision(package_ref)
     return package_ref.copy_with_revs(rrev, prev)
Exemplo n.º 20
0
    def conan_test_test(self):
        # Checks --build in test command
        client = TestClient()
        self._create(client, "Hello0", "0.0")
        self._create(client, "Hello1", "1.1", ["Hello0/0.0@lasote/stable"])

        # Now test out Hello2
        self._create(client,
                     "Hello2",
                     "2.2", ["Hello1/1.1@lasote/stable"],
                     export=True)
        hello2conanfile = client.load(CONANFILE)
        client.save({CONANFILE: hello2conanfile})

        conanfile = GenConanfile().with_test("pass").with_require(
            "Hello2/2.2@lasote/stable")
        client.save({"test/conanfile.py": conanfile})

        # Should recognize the hello package
        # Will Fail because Hello0/0.0 and Hello1/1.1 has not built packages
        # and by default no packages are built
        client.run("create . lasote/stable", assert_error=True)
        self.assertIn(
            'Try to build from sources with "--build=Hello0 --build=Hello1"',
            client.out)

        # We generate the package for Hello0/0.0
        client.run("install Hello0/0.0@lasote/stable --build Hello0")

        # Still missing Hello1/1.1
        client.run("create . lasote/stable", assert_error=True)
        self.assertIn('Try to build from sources with "--build=Hello1"',
                      client.out)

        # We generate the package for Hello1/1.1
        client.run("install Hello1/1.1@lasote/stable --build Hello1")

        # Now Hello2 should be built and not fail
        client.run("create . lasote/stable")
        self.assertNotIn("Can't find a 'Hello2/2.2@lasote/stable' package",
                         client.out)
        self.assertIn('Hello2/2.2@lasote/stable: Forced build from source',
                      client.out)

        # Now package is generated but should be built again
        client.run("create . lasote/stable")
        self.assertIn('Hello2/2.2@lasote/stable: Forced build from source',
                      client.out)
Exemplo n.º 21
0
 def test_metadata_editable_packages(self):
     """
     Check that 'conan remote' commands work with editable packages
     """
     self.client.save({"conanfile.py": GenConanfile()})
     self.client.run("create . pkg/1.1@lasote/stable")
     self.client.run(
         "upload pkg/1.1@lasote/stable --all -c --remote remote1")
     self.client.run("remove -f pkg/1.1@lasote/stable")
     self.client.run("install pkg/1.1@lasote/stable")
     self.assertIn("pkg/1.1@lasote/stable: Package installed",
                   self.client.out)
     self.client.run("remote list_ref")
     self.assertIn("pkg/1.1@lasote/stable: remote1", self.client.out)
     self.client.run("editable add . pkg/1.1@lasote/stable")
     # Check add --force, update and rename
     self.client.run("remote add remote2 %s --force" %
                     self.servers["remote1"].fake_url)
     self.client.run("remote update remote2 %sfake" %
                     self.servers["remote1"].fake_url)
     self.client.run("remote rename remote2 remote-fake")
     self.client.run("editable remove pkg/1.1@lasote/stable")
     # Check associated remote has changed name
     self.client.run("remote list_ref")
     self.assertIn("pkg/1.1@lasote/stable: remote-fake", self.client.out)
     # Check remove
     self.client.run("editable add . pkg/1.1@lasote/stable")
     self.client.run("remote remove remote-fake")
     self.client.run("remote list")
     self.assertIn("remote0: %s" % self.servers["remote0"].fake_url,
                   self.client.out)
     self.assertNotIn("remote-fake", self.client.out)
     # Check clean
     self.client.run("editable remove pkg/1.1@lasote/stable")
     self.client.run("remove -f pkg/1.1@lasote/stable")
     self.client.run("remote add remote1 %s" %
                     self.servers["remote1"].fake_url)
     self.client.run("install pkg/1.1@lasote/stable")
     self.client.run("editable add . pkg/1.1@lasote/stable")
     self.client.run("remote clean")
     self.client.run("remote list")
     self.assertNotIn("remote1", self.client.out)
     self.assertNotIn("remote0", self.client.out)
Exemplo n.º 22
0
    def editable_test(self):
        client = TestClient()
        client.save({
            "pkg/conanfile.py":
            self.recipe_conanfile,
            "pkg/file.txt":
            "MYFILE!",
            "consumer/conanfile.py":
            GenConanfile().with_require("pkg/0.1@user/stable")
        })
        client.run("editable add pkg pkg/0.1@user/stable")

        client.run("install consumer")
        self.assertIn("pkg/0.1@user/stable: INIT: MYFILE!", client.out)
        self.assertIn("pkg/0.1@user/stable: CONFIGURE: MYFILE!", client.out)
        self.assertIn("pkg/0.1@user/stable: REQUIREMENTS: MYFILE!", client.out)
        self.assertIn("pkg/0.1@user/stable from user folder - Editable",
                      client.out)
        self.assertIn("pkg/0.1@user/stable: PACKAGE_INFO: MYFILE!", client.out)
Exemplo n.º 23
0
    def test(self):
        # https://github.com/conan-io/conan/issues/7598
        client = TestClient()

        client.save({"conanfile.py": GenConanfile()})
        client.run("create . dep/0.1@user/testing")

        conanfile = textwrap.dedent("""
            from conans import ConanFile
            class Pkg(ConanFile):
                requires = "dep/0.1@user/testing"
                def build(self):
                    self.output.info("DEPS_CPP_INFO_BIN: %s" % self.deps_cpp_info["dep"].bin_paths)
            """)
        client.save({"conanfile.py": conanfile})
        client.run("create . pkg/0.1@user/testing")
        self.assertIn("pkg/0.1@user/testing: DEPS_CPP_INFO_BIN: []",
                      client.out)
        client.run("install .")
        client.run("build .")
        self.assertIn("conanfile.py: DEPS_CPP_INFO_BIN: []", client.out)
Exemplo n.º 24
0
 def test_multiple_remotes_single_upload(self):
     servers = OrderedDict([("server1", TestServer()),
                            ("server2", TestServer())])
     client = TestClient(servers=servers,
                         users={
                             "server1": [("lasote", "mypass")],
                             "server2": [("lasote", "mypass")]
                         })
     conanfile = GenConanfile().with_setting("build_type")
     client.save({"conanfile.py": conanfile})
     client.run("create . Pkg/0.1@lasote/testing -s build_type=Release")
     client.run("create . Pkg2/0.1@lasote/testing -s build_type=Release")
     client.run("remote add_ref Pkg/0.1@lasote/testing server1")
     client.run("remote add_ref Pkg2/0.1@lasote/testing server2")
     client.run("upload Pkg* --all --confirm")
     self.assertIn(
         "Uploaded conan recipe 'Pkg/0.1@lasote/testing' to 'server1'",
         client.out)
     self.assertIn(
         "Uploaded conan recipe 'Pkg2/0.1@lasote/testing' to 'server2'",
         client.out)
Exemplo n.º 25
0
    def test_settings_constraint(self):
        conanfile = """from conans import ConanFile
class Test(ConanFile):
    name = "Hello"
    version = "0.1"
    settings = {"compiler": {"gcc": {"version": ["7.1"]}}}
    def build(self):
        self.output.info("Compiler version!: %s" % self.settings.compiler.version)
    """
        test = GenConanfile().with_requires("Hello/0.1@user/channel").with_test("pass")
        client = TestClient()
        client.save({"conanfile.py": conanfile,
                     "test_package/conanfile.py": test})
        default_profile = os.path.join(client.cache_folder, "profiles/default")
        save(default_profile, "[settings]\ncompiler=gcc\ncompiler.version=6.3")
        client.run("create . user/channel", assert_error=True)
        self.assertIn("Invalid setting '6.3' is not a valid 'settings.compiler.version'",
                      client.out)
        client.run("create . user/channel -s compiler=gcc -s compiler.version=7.1")
        self.assertIn("Hello/0.1@user/channel: Compiler version!: 7.1", client.out)
        self.assertIn("Hello/0.1@user/channel: Generating the package", client.out)
Exemplo n.º 26
0
    def setUp(self):
        self.client = TestClient()
        conanfile = """
from conans import ConanFile

class SayConan(ConanFile):
    name = "Say"
    version = "0.1"
    build_policy = "missing"

    def build(self):
        self.output.info("Building %s")
"""
        for channel in ("lasote/stable", "other/testing"):
            self.client.save({"conanfile.py": conanfile % channel})
            self.client.run("export . %s" % channel)

        self.conanfile = """
from conans import ConanFile

class HelloConan(ConanFile):
    name = "Hello"
    version = "0.1"
    build_policy = "missing"

    def requirements(self):
        self.requires("Say/0.1@%s/%s" % (self.user, self.channel))

    def build(self):
        self.output.info("Building %s/%s" % (self.user, self.channel) )
"""

        self.test_conanfile = str(GenConanfile().with_require(
            "Hello/0.1@lasote/stable").with_test("pass"))
        self.client.save({
            "conanfile.py": self.conanfile,
            "test/conanfile.py": self.test_conanfile
        })
Exemplo n.º 27
0
 def test_remove_package_empty(self):
     self.client.save({"conanfile.py": GenConanfile("name", "version")})
     self.client.run("export . name/version@lasote/stable")
     self.client.run("upload name/version@lasote/stable --remote remote1")
     self.client.run("remove -f -p -r remote1 name/version@lasote/stable")
Exemplo n.º 28
0
    def package_requires_in_components_requires_test(self):
        client = TestClient()
        client.save({
            "conanfile1.py": GenConanfile("dep1", "0.1"),
            "conanfile2.py": GenConanfile("dep2", "0.1")
        })
        client.run("create conanfile1.py")
        client.run("create conanfile2.py")

        conanfile = GenConanfile("consumer", "0.1") \
            .with_requirement_plain("dep1/0.1") \
            .with_requirement_plain("dep2/0.1") \
            .with_package_info(cpp_info={"components": {"kk": {"requires": []}}},
                               env_info={})
        client.save({"conanfile.py": conanfile})
        client.run("create conanfile.py", assert_error=True)
        self.assertIn(
            "consumer/0.1 package_info(): Package require 'dep1' not used in "
            "components requires", client.out)

        conanfile = GenConanfile("consumer", "0.1") \
            .with_requirement_plain("dep1/0.1") \
            .with_requirement_plain("dep2/0.1") \
            .with_package_info(cpp_info={"components": {"kk": {"requires": ["dep1::dep1"]}}},
                               env_info={})
        client.save({"conanfile.py": conanfile})
        client.run("create conanfile.py", assert_error=True)
        self.assertIn(
            "consumer/0.1 package_info(): Package require 'dep2' not used in components "
            "requires", client.out)

        conanfile = GenConanfile("consumer", "0.1") \
            .with_requirement_plain("dep1/0.1") \
            .with_requirement_plain("dep2/0.1") \
            .with_package_info(cpp_info={"components": {"kk": {"requires": ["dep1::dep1"]},
                                                        "kkk": {"requires": ["kk"]}}},
                               env_info={})
        client.save({"conanfile.py": conanfile})
        client.run("create conanfile.py", assert_error=True)
        self.assertIn(
            "consumer/0.1 package_info(): Package require 'dep2' not used in components "
            "requires", client.out)

        conanfile = GenConanfile("consumer", "0.1") \
            .with_requirement_plain("dep1/0.1") \
            .with_requirement_plain("dep2/0.1") \
            .with_package_info(cpp_info={"components": {"kk": {"requires": []},
                                                        "kkk": {"requires": ["kk"]}}},
                               env_info={})
        client.save({"conanfile.py": conanfile})
        client.run("create conanfile.py", assert_error=True)
        self.assertIn(
            "consumer/0.1 package_info(): Package require 'dep1' not used in components "
            "requires", client.out)

        conanfile = GenConanfile("consumer", "0.1") \
            .with_requirement_plain("dep1/0.1") \
            .with_requirement_plain("dep2/0.1") \
            .with_package_info(cpp_info={"components": {"kk": {"requires": ["dep2::comp"]},
                                                        "kkk": {"requires": ["dep3::dep3"]}}},
                               env_info={})
        client.save({"conanfile.py": conanfile})
        client.run("create conanfile.py", assert_error=True)
        self.assertIn(
            "consumer/0.1 package_info(): Package require 'dep1' not used in components "
            "requires", client.out)

        conanfile = GenConanfile("consumer", "0.1") \
            .with_requirement_plain("dep2/0.1") \
            .with_package_info(cpp_info={"components": {"kk": {"requires": ["dep2::comp"]},
                                                        "kkk": {"requires": ["dep3::dep3"]}}},
                               env_info={})
        client.save({"conanfile.py": conanfile})
        client.run("create conanfile.py", assert_error=True)
        self.assertIn(
            "consumer/0.1 package_info(): Package require 'dep3' declared in components "
            "requires but not defined as a recipe requirement", client.out)

        conanfile = GenConanfile("consumer", "0.1") \
            .with_package_info(cpp_info={"components": {"kk": {"requires": ["dep2::comp"]}}},
                               env_info={})
        client.save({"conanfile.py": conanfile})
        client.run("create conanfile.py", assert_error=True)
        self.assertIn(
            "consumer/0.1 package_info(): Package require 'dep2' declared in components "
            "requires but not defined as a recipe requirement", client.out)

        conanfile = GenConanfile("consumer", "0.1") \
            .with_requirement_plain("dep1/0.1") \
            .with_requirement_plain("dep2/0.1") \
            .with_package_info(cpp_info={"components": {"kk": {"requires": ["dep2::comp"]},
                                                        "kkk": {"requires": ["dep1::dep1"]}}},
                               env_info={})
        client.save({"conanfile.py": conanfile})
        client.run("create conanfile.py")  # Correct usage
Exemplo n.º 29
0
    def test_version_ranges(self):
        client = TestClient()
        client.run(
            "config set general.default_package_id_mode=full_package_mode")
        myprofile = textwrap.dedent("""
            [build_requires]
            br/[>=0.1]@user/channel
            """)
        files = {
            "myprofile":
            myprofile,
            "br/conanfile.py":
            GenConanfile(),
            "pkga/conanfile.py":
            conanfile.format(requires=""),
            "pkga/myfile.txt":
            "HelloA",
            "pkgb/conanfile.py":
            conanfile.format(requires='requires="PkgA/[*]@user/channel"'),
            "pkgb/myfile.txt":
            "HelloB",
            "pkgc/conanfile.py":
            conanfile.format(requires='requires="PkgB/[*]@user/channel"'),
            "pkgc/myfile.txt":
            "HelloC",
            "pkgd/conanfile.py":
            conanfile.format(requires='requires="PkgC/[*]@user/channel"'),
            "pkgd/myfile.txt":
            "HelloD",
        }
        client.save(files)
        client.run("create br br/0.1@user/channel")
        client.run("create pkga PkgA/0.1@user/channel -pr=myprofile")
        client.run("create pkgb PkgB/0.1@user/channel -pr=myprofile")
        client.run("create pkgc PkgC/0.1@user/channel -pr=myprofile")
        client.run("create pkgd PkgD/0.1@user/channel -pr=myprofile")

        self.assertIn("PkgD/0.1@user/channel: SELF FILE: HelloD", client.out)
        self.assertIn("PkgD/0.1@user/channel: DEP FILE PkgA: HelloA",
                      client.out)
        self.assertIn("PkgD/0.1@user/channel: DEP FILE PkgB: HelloB",
                      client.out)
        self.assertIn("PkgD/0.1@user/channel: DEP FILE PkgC: HelloC",
                      client.out)

        # Go back to main orchestrator
        client.run(
            "lock create --reference=PkgD/0.1@user/channel --build -pr=myprofile "
            " --lockfile-out=conan.lock")

        # Do a change in br
        client.run("create br br/0.2@user/channel")

        client.run("lock build-order conan.lock --json=build_order.json")
        self.assertIn("br/0.1", client.out)
        self.assertNotIn("br/0.2", client.out)
        master_lockfile = client.load("conan.lock")

        json_file = client.load("build_order.json")
        to_build = json.loads(json_file)
        if client.cache.config.revisions_enabled:
            build_order = [
                [[
                    'br/0.1@user/channel#f3367e0e7d170aa12abccb175fee5f97',
                    '5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9', 'host', '5'
                ]],
                [[
                    'PkgA/0.1@user/channel#189390ce059842ce984e0502c52cf736',
                    '5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9', 'host', '4'
                ]],
                [[
                    'PkgB/0.1@user/channel#fa97c46bf83849a5db4564327b3cfada',
                    '096f747d204735584fa0115bcbd7482d424094bc', 'host', '3'
                ]],
                [[
                    'PkgC/0.1@user/channel#c6f95948619d28d9d96b0ae86c46a482',
                    'f6d5dbb6f309dbf8519278bae8d07d3b739b3dec', 'host', '2'
                ]],
                [[
                    'PkgD/0.1@user/channel#fce78c934bc0de73eeb05eb4060fc2b7',
                    'de4467a3fa6ef01b09b7464e85553fb4be2d2096', 'host', '1'
                ]]
            ]
        else:
            build_order = [[[
                'br/0.1@user/channel',
                '5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9', 'host', '5'
            ]],
                           [[
                               'PkgA/0.1@user/channel',
                               '5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9',
                               'host', '4'
                           ]],
                           [[
                               'PkgB/0.1@user/channel',
                               '096f747d204735584fa0115bcbd7482d424094bc',
                               'host', '3'
                           ]],
                           [[
                               'PkgC/0.1@user/channel',
                               'f6d5dbb6f309dbf8519278bae8d07d3b739b3dec',
                               'host', '2'
                           ]],
                           [[
                               'PkgD/0.1@user/channel',
                               'de4467a3fa6ef01b09b7464e85553fb4be2d2096',
                               'host', '1'
                           ]]]

        self.assertEqual(to_build, build_order)
        lock_fileaux = master_lockfile
        while to_build:
            for ref, _, _, _ in to_build[0]:
                client_aux = TestClient(cache_folder=client.cache_folder)
                client_aux.save({LOCKFILE: lock_fileaux})
                client_aux.run("install %s --build=%s --lockfile=conan.lock "
                               "--lockfile-out=conan.lock" % (ref, ref))
                self.assertIn("br/0.1", client_aux.out)
                self.assertNotIn("br/0.2", client_aux.out)
                lock_fileaux = client_aux.load(LOCKFILE)
                client.save({"new_lock/%s" % LOCKFILE: lock_fileaux})
                client.run("lock update conan.lock new_lock/conan.lock")

            client.run("lock build-order conan.lock --json=build_order.json")
            lock_fileaux = client.load(LOCKFILE)
            to_build = json.loads(client.load("build_order.json"))

        client.run("install PkgD/0.1@user/channel --lockfile=conan.lock")
        # No build require at all
        self.assertNotIn("br/0.", client.out)

        client.run("install PkgD/0.1@user/channel --build -pr=myprofile")
        self.assertIn("br/0.2", client.out)
        self.assertNotIn("br/0.1", client.out)