Ejemplo n.º 1
0
    def test_upload(self):
        ref = ConanFileReference.loads("Hello0/0.1@lasote/stable")
        files = cpp_hello_conan_files("Hello0", "0.1", build=False)
        self.client.save(files)
        self.client.run("export . lasote/stable")
        self.client.run("upload %s" % str(ref))

        self.client.run("info %s" % str(ref))
        self.assertIn("remote0=http://", self.client.out)

        # The remote, once fixed does not change
        self.client.run("upload %s -r=remote1" % str(ref))
        self.client.run("info %s" % str(ref))
        self.assertIn("remote0=http://", self.client.out)

        # Now install it in other machine from remote 0
        client2 = TestClient(servers=self.servers, users=self.users)
        client2.run("install %s --build=missing" % str(ref))
        client2.run("info %s" % str(ref))
        self.assertIn("remote0=http://", client2.out)

        # Now install it in other machine from remote 1
        servers = self.servers.copy()
        servers.pop("remote0")
        client3 = TestClient(servers=servers, users=self.users)
        client3.run("install %s --build=missing" % str(ref))
        client3.run("info %s" % str(ref))
        self.assertIn("remote1=http://", client3.out)
Ejemplo n.º 2
0
    def test_skip_upload(self):
        """ Check that the option --dry does not upload anything
        """
        client = TestClient(default_server_user=True)

        files = cpp_hello_conan_files("Hello0", "1.2.1", build=False)
        client.save(files)
        client.run("create . frodo/stable")
        client.run("upload Hello0/1.2.1@frodo/stable -r default --all --skip-upload")

        # dry run should not upload
        self.assertNotIn("Uploading conan_package.tgz", client.out)

        # but dry run should compress
        self.assertIn("Compressing recipe...", client.out)
        self.assertIn("Compressing package...", client.out)

        client.run("search -r default")
        # after dry run nothing should be on the server ...
        self.assertNotIn("Hello0/1.2.1@frodo/stable", client.out)

        # now upload, the stuff should NOT be recompressed
        client.run("upload Hello0/1.2.1@frodo/stable -r default --all")

        # check for upload message
        self.assertIn("Uploading conan_package.tgz", client.out)

        # check if compressed files are re-used
        self.assertNotIn("Compressing recipe...", client.out)
        self.assertNotIn("Compressing package...", client.out)

        # now it should be on the server
        client.run("search -r default")
        self.assertIn("Hello0/1.2.1@frodo/stable", client.out)
Ejemplo n.º 3
0
    def test_export_a_new_version(self):
        self._create_packages_and_builds()
        # Export an update of the same conans

        # Do not adjust cpu_count, it is reusing a cache
        client2 = TestClient(self.client.cache_folder, cpu_count=False)
        files2 = cpp_hello_conan_files("Hello0", "0.1")
        files2[CONANFILE] = "# insert comment\n %s" % files2[CONANFILE]
        client2.save(files2)
        client2.run("export . lasote/stable")

        reg_path3 = client2.cache.package_layout(self.ref).export()
        digest3 = FileTreeManifest.load(
            client2.cache.package_layout(self.ref).export())

        self.assertIn(
            '%s: A new conanfile.py version was exported' % str(self.ref),
            self.client.out)
        self.assertIn('%s: Folder: %s' % (str(self.ref), reg_path3),
                      self.client.out)

        self.assertTrue(os.path.exists(reg_path3))

        for name in list(files2.keys()):
            self.assertTrue(os.path.exists(os.path.join(reg_path3, name)))

        expected_sums = {
            'hello.cpp': '4f005274b2fdb25e6113b69774dac184',
            'main.cpp': '0479f3c223c9a656a718f3148e044124',
            'CMakeLists.txt': '10d907c160c360b28f6991397a5aa9b4',
            'conanfile.py': 'e309305959502e16f8a57439bb6a4107',
            'executable': '68b329da9893e34099c7d8ad5cb9c940',
            'helloHello0.h': 'd0a6868b5df17a6ae6e61ebddb0c9eb3'
        }
        self.assertEqual(expected_sums, digest3.file_sums)
Ejemplo n.º 4
0
    def test_uploaded_chain(self):
        self._export_upload("Hello0", "0.1")
        self._export_upload("Hello1", "0.1", ["Hello0/0.1@lasote/stable"])

        client = TestClient(servers=self.servers,
                            users={"default": [("lasote", "mypass")]})
        files = cpp_hello_conan_files("Hello2",
                                      "0.1", ["Hello1/0.1@lasote/stable"],
                                      static=True)
        c = files["conanfile.py"]
        c = c.replace(
            "def imports(self):", "def imports(self):\n"
            '        self.copy(pattern="*.so", dst=".", src="lib")')
        files["conanfile.py"] = c
        client.save(files)

        client.run("install .")
        client.run("build .")
        ld_path = ("LD_LIBRARY_PATH='{}' ".format(client.current_folder)
                   if platform.system() != "Windows" else "")
        cmd_path = os.sep.join([".", "bin", "say_hello"])
        command = ld_path + cmd_path

        client.run_command(command)
        self.assertEqual(['Hello Hello2', 'Hello Hello1', 'Hello Hello0'],
                         str(client.out).splitlines()[-3:])
Ejemplo n.º 5
0
    def test_reuse_complete_urls(self):
        # This test can be removed in conan 2.0 when the complete_urls is removed
        test_server = TestServer(complete_urls=True)
        servers = {"default": test_server}
        client = TestClient(servers=servers,
                            users={"default": [("lasote", "mypass")]})

        ref = ConanFileReference.loads("Hello0/0.1@lasote/stable")
        files = cpp_hello_conan_files("Hello0", "0.1", build=False)
        client.save(files)
        client.run("create . lasote/stable")
        self.assertIn(
            "Hello0/0.1@lasote/stable package(): Packaged 1 '.h' file: helloHello0.h",
            client.out)

        # Upload package
        client.run("upload %s --all" % str(ref))
        self.assertIn("Compressing package", client.out)

        # Not needed to tgz again
        client.run("upload %s --all" % str(ref))
        self.assertNotIn("Compressing package", client.out)

        # Now from other "computer" install the uploaded packages with same options
        other_conan = TestClient(servers=servers,
                                 users={"default": [("lasote", "mypass")]})
        other_conan.run("install %s" % str(ref))

        # Now install it but with other options
        other_conan.run('install %s -o language=1 --build missing' %
                        (str(ref)))
        # Should have two packages
        package_ids = other_conan.cache.package_layout(ref).package_ids()
        self.assertEqual(len(package_ids), 2)
Ejemplo n.º 6
0
    def test_reuse_downloaded_tgz(self):
        # Download packages from a remote, then copy to another channel
        # and reupload them. It needs to compress it again, not tgz is kept

        # UPLOAD A PACKAGE
        ref = ConanFileReference.loads("Hello0/0.1@lasote/stable")
        files = cpp_hello_conan_files("Hello0",
                                      "0.1",
                                      need_patch=True,
                                      build=False)
        files["another_export_file.lib"] = "to compress"
        self.client.save(files)
        self.client.run("export . lasote/stable")
        self.client.run("install %s --build missing" % str(ref))
        self.client.run("upload %s --all" % str(ref))
        self.assertIn("Compressing recipe", self.client.out)
        self.assertIn("Compressing package", self.client.out)

        # Other user downloads the package
        # THEN A NEW USER DOWNLOADS THE PACKAGES AND UPLOADS COMPRESSING AGAIN
        # BECAUSE ONLY TGZ IS KEPT WHEN UPLOADING
        other_client = TestClient(servers=self.servers,
                                  users={"default": [("lasote", "mypass")]})
        other_client.run("download Hello0/0.1@lasote/stable")
        other_client.run("upload Hello0/0.1@lasote/stable --all")
        self.assertIn("Compressing recipe", self.client.out)
        self.assertIn("Compressing package", self.client.out)
Ejemplo n.º 7
0
    def test_run_environment(self):
        client = TestClient()
        files = cpp_hello_conan_files("Hello0", "0.1")
        files[CONANFILE] = files[CONANFILE].replace(
            'self.copy(pattern="*.so", dst="lib", keep_path=False)',
            '''self.copy(pattern="*.so", dst="lib", keep_path=False)
        self.copy(pattern="*say_hello*", dst="bin", keep_path=False)''')
        client.save(files)
        client.run("export . lasote/stable")

        reuse = textwrap.dedent("""
            from conans import ConanFile, RunEnvironment, tools

            class HelloConan(ConanFile):
                name = "Reuse"
                version = "0.1"
                build_policy = "missing"
                requires = "Hello0/0.1@lasote/stable"

                def build(self):
                    run_env = RunEnvironment(self)
                    with tools.environment_append(run_env.vars):
                        self.run("say_hello")
        """)

        client.save({"conanfile.py": reuse}, clean_first=True)
        client.run("install . --build missing")
        client.run("build .")
        self.assertIn("Hello Hello0", client.out)
Ejemplo n.º 8
0
    def test_base(self, subsystem_require):

        run("conan remote remove conan-testuite ", ignore_error=True)
        run("conan remote add conan-center https://conan.bintray.com",
            ignore_error=True)

        files = cpp_hello_conan_files(name="Hello",
                                      version="0.1",
                                      deps=None,
                                      language=0,
                                      static=True,
                                      use_cmake=False)
        files["myprofile"] = """
[build_requires]
mingw_installer/1.0@conan/stable
%s
 
[settings]
os_build=Windows
arch_build=x86_64
os=Windows
arch=x86_64
compiler=gcc
compiler.version=5.4
compiler.libcxx=libstdc++11
compiler.exception=seh
compiler.threads=posix
""" % subsystem_require

        save_files(files)
        run("conan create %s conan/testing --profile ./myprofile --update" %
            path_dot())
Ejemplo n.º 9
0
    def test_reuse(self):
        files = cpp_hello_conan_files("Hello0",
                                      "1.0",
                                      build=False,
                                      settings='"os"')

        self.client.save(files)
        self.client.run("export . lasote/stable")
        self.client.run("install Hello0/1.0@lasote/stable --build")
        self.client.run("upload Hello0/1.0@lasote/stable --all")

        client2 = TestClient(servers=self.servers,
                             users={"myremote": [("lasote", "mypass")]})
        client2.run("install Hello0/1.0@lasote/stable")

        self.assertEqual(
            str(client2.out).count("Downloading conaninfo.txt"), 1)

        files["helloHello0.h"] = "//EMPTY!"
        self.client.save(files, clean_first=True)
        sleep(1)
        self.client.run("export . lasote/stable")
        self.client.run("install Hello0/1.0@lasote/stable --build")
        self.client.run("upload Hello0/1.0@lasote/stable --all")

        client2.run("install Hello0/1.0@lasote/stable --update")
        ref = ConanFileReference.loads("Hello0/1.0@lasote/stable")
        package_ids = client2.cache.package_layout(ref).package_ids()
        pref = PackageReference(ref, package_ids[0])
        package_path = client2.cache.package_layout(ref).package(pref)
        header = load(os.path.join(package_path, "include/helloHello0.h"))
        self.assertEqual(header, "//EMPTY!")
Ejemplo n.º 10
0
    def test_trace_command(self):
        from conans.build_info.command import run
        trace_file = os.path.join(temp_folder(), "conan_trace.log")
        # Generate some traces
        with tools.environment_append({"CONAN_TRACE_FILE": trace_file}):
            files = cpp_hello_conan_files("Hello0",
                                          "1.0",
                                          deps=[],
                                          build=False)
            self.client.save(files)
            self.client.run("export . lasote/stable")
            self.client.run("install Hello0/1.0@lasote/stable --build")
            self.client.run("upload '*' --all -c")

        # Get json from file
        output = os.path.join(temp_folder(), "build_info.json")
        sys.argv = ['conan_build_info', trace_file, '--output', output]
        run()

        the_json = json.loads(load(output))
        self.assertTrue(the_json["modules"][0]["id"],
                        "Hello0/1.0@lasote/stable")

        # Now get from stdout
        sys.argv = ['conan_build_info', trace_file]
        run()

        try:  # in IDEs or with --nocapture it will fail
            stdout_value = sys.stdout.getvalue()
        except AttributeError:
            pass
        else:
            the_json = json.loads(stdout_value)
            self.assertTrue(the_json["modules"][0]["id"],
                            "Hello0/1.0@lasote/stable")
Ejemplo n.º 11
0
    def test_fail_when_not_notfound(self):
        """
        If a remote fails with a 404 it has to keep looking in the next remote, but if it fails by
        any other reason it has to stop
        """
        servers = OrderedDict()
        servers["s0"] = TestServer()
        servers["s1"] = TestServer()
        servers["s2"] = TestServer()

        client = TestClient(servers=servers, users=self.users)
        files = cpp_hello_conan_files("MyLib", "0.1", build=False)
        client.save(files)
        client.run("create . lasote/testing")
        client.run("user lasote -p mypass -r s1")
        client.run("upload MyLib* -r s1 -c")

        servers[
            "s1"].fake_url = "http://asdlhaljksdhlajkshdljakhsd.com"  # Do not exist
        client2 = TestClient(servers=servers, users=self.users)
        err = client2.run("install MyLib/0.1@conan/testing --build=missing",
                          assert_error=True)
        self.assertTrue(err)
        self.assertIn("MyLib/0.1@conan/testing: Trying with 's0'...",
                      client2.out)
        self.assertIn("MyLib/0.1@conan/testing: Trying with 's1'...",
                      client2.out)
        self.assertIn(
            "Unable to connect to s1=http://asdlhaljksdhlajkshdljakhsd.com",
            client2.out)
        # s2 is not even tried
        self.assertNotIn("MyLib/0.1@conan/testing: Trying with 's2'...",
                         client2.out)
Ejemplo n.º 12
0
    def test_upload_unmodified_recipe(self):
        client = TestClient(default_server_user=True)

        files = cpp_hello_conan_files("Hello0", "1.2.1", build=False)
        client.save(files)
        client.run("export . frodo/stable")
        client.run("upload Hello0/1.2.1@frodo/stable")
        self.assertIn("Uploading conanmanifest.txt", client.out)
        self.assertIn("Uploaded conan recipe 'Hello0/1.2.1@frodo/stable' to 'default'",
                      client.out)

        client2 = TestClient(servers=client.servers, users=client.users)
        client2.save(files)
        client2.run("export . frodo/stable")
        ref = ConanFileReference.loads("Hello0/1.2.1@frodo/stable")
        manifest = client2.cache.package_layout(ref).recipe_manifest()
        manifest.time += 10
        manifest.save(client2.cache.package_layout(ref).export())
        client2.run("upload Hello0/1.2.1@frodo/stable")
        self.assertNotIn("Uploading conanmanifest.txt", client2.out)
        self.assertNotIn("Uploaded conan recipe 'Hello0/1.2.1@frodo/stable' to 'default'",
                         client2.out)
        self.assertIn("Recipe is up to date, upload skipped", client2.out)

        # first client tries to upload again
        client.run("upload Hello0/1.2.1@frodo/stable")
        self.assertNotIn("Uploading conanmanifest.txt", client.out)
        self.assertNotIn("Uploaded conan recipe 'Hello0/1.2.1@frodo/stable' to 'default'",
                         client.out)
        self.assertIn("Recipe is up to date, upload skipped", client.out)
Ejemplo n.º 13
0
    def test_check_upload_confirm_question(self):
        self.client.users = {"default": [("lasote", "mypass")]}
        files = cpp_hello_conan_files("Hello1", "1.2.1")
        self.client.save(files)
        self.client.run("export . frodo/stable")
        with patch.object(sys.stdin, "readline", return_value="y"):
            self.client.run("upload Hello*")
        self.assertIn("Uploading Hello1/1.2.1@frodo/stable", self.client.out)

        files = cpp_hello_conan_files("Hello2", "1.2.1")
        self.client.save(files)
        self.client.run("export . frodo/stable")

        with patch.object(sys.stdin, "readline", return_value="n"):
            self.client.run("upload Hello*")
        self.assertNotIn("Uploading Hello2/1.2.1@frodo/stable",
                         self.client.out)
Ejemplo n.º 14
0
 def _export(self, name=0, version=None, deps=None):
     client = TestClient(servers=self.servers, users={"default": [("lu", "mypass")]})
     self.clients[name] = client
     # Not necessary to actually build binaries
     files = cpp_hello_conan_files(name, version, deps, build=False)
     client.save(files, clean_first=True)
     client.run("export . lu/st")
     client.run("upload %s/%s@lu/st" % (name, version))
Ejemplo n.º 15
0
 def test_case_sensitive(self):
     self.files = cpp_hello_conan_files("hello0", "0.1")
     self.ref = ConanFileReference("hello0", "0.1", "lasote", "stable")
     self.client.save(self.files)
     self.client.run("export . lasote/stable", assert_error=True)
     self.assertIn(
         "ERROR: Cannot export package with same name but different case",
         self.client.out)
Ejemplo n.º 16
0
    def test_check_upload_confirm_question(self):
        user_io = MockedUserIO({"default": [("lasote", "mypass")]}, out=TestBufferConanOutput())
        files = cpp_hello_conan_files("Hello1", "1.2.1")
        self.client.save(files)
        self.client.run("export . frodo/stable")

        user_io.request_string = lambda _: "y"
        self.client.run("upload Hello*", user_io=user_io)
        self.assertIn("Uploading Hello1/1.2.1@frodo/stable", self.client.out)

        files = cpp_hello_conan_files("Hello2", "1.2.1")
        self.client.save(files)
        self.client.run("export . frodo/stable")

        user_io.request_string = lambda _: "n"
        self.client.run("upload Hello*", user_io=user_io)
        self.assertNotIn("Uploading Hello2/1.2.1@frodo/stable", self.client.out)
Ejemplo n.º 17
0
    def test_upload_with_pattern_and_package_error(self):
        files = cpp_hello_conan_files("Hello1", "1.2.1")
        self.client.save(files)
        self.client.run("export . frodo/stable")

        self.client.run("upload Hello* --confirm -p 234234234", assert_error=True)
        self.assertIn("-p parameter only allowed with a valid recipe reference",
                      self.client.out)
Ejemplo n.º 18
0
    def test_install_outdated_dep(self):
        # A new recipe that depends on Hello0/0.1
        new_client = TestClient(servers=self.servers,
                                users={"default": [("lasote", "mypass")]})
        files = cpp_hello_conan_files("Hello1",
                                      "0.1", ["Hello0/0.1@lasote/stable"],
                                      build=False)
        new_client.save(files)
        new_client.run("export . lasote/stable")
        self.assertIn("A new conanfile.py version was exported",
                      new_client.out)
        # It will retrieve from the remote Hello0 and build Hello1
        new_client.run("install Hello1/0.1@lasote/stable --build missing")

        # Then modify REMOTE Hello0 recipe files (WITH THE OTHER CLIENT)
        files = cpp_hello_conan_files("Hello0", "0.1", build=False)
        files["conanfile.py"] += "\n#MODIFIED RECIPE"
        self.client.save(files)
        self.client.run("export . lasote/stable")
        self.assertIn("A new conanfile.py version was exported",
                      self.client.out)
        self.client.run("install Hello0/0.1@lasote/stable --build missing")
        # Upload only the recipe, so the package is outdated in the server
        self.client.run("upload Hello0/0.1@lasote/stable")

        # Now, with the new_client, remove only the binary package from Hello0
        rmdir(new_client.cache.package_layout(self.ref).packages())
        # And try to install Hello1 again, should not complain because the remote
        # binary is in the "same version" than local cached Hello0
        new_client.run("install Hello1/0.1@lasote/stable --build outdated")
        self.assertIn("Downloading conan_package.tgz", new_client.out)
        self.assertIn("Hello0/0.1@lasote/stable: Package is up to date",
                      new_client.out)

        # With revisions makes no sense, it won't download an outdated package, it belongs to
        # a different recipe
        if not new_client.cache.config.revisions_enabled:
            # But if we remove the full Hello0 local package, will retrieve the updated
            # recipe and the outdated package
            new_client.run("remove Hello0* -f")
            new_client.run("install Hello1/0.1@lasote/stable --build outdated")
            self.assertIn("Hello0/0.1@lasote/stable: Outdated package!",
                          new_client.out)
            self.assertIn("Hello0/0.1@lasote/stable: Building your package",
                          new_client.out)
Ejemplo n.º 19
0
 def _export(self, name=0, version=None, deps=None):
     files = cpp_hello_conan_files(name,
                                   version,
                                   deps,
                                   private_includes=True,
                                   build=False,
                                   cmake_targets=True)
     self.client.save(files, clean_first=True)
     self.client.run("export . lasote/stable")
Ejemplo n.º 20
0
    def setUp(self):
        self.client = TestClient()
        files = cpp_hello_conan_files(name="MinGWBuild",
                                      version="0.1",
                                      build=False)
        self._patch_build_to_print_compiler(files)

        self.client.save(files)
        self.client.run("export . lasote/testing")
Ejemplo n.º 21
0
    def test_build_policies_in_conanfile(self):

        client = TestClient(servers=self.servers,
                            users={"default": [("lasote", "mypass")]})
        files = cpp_hello_conan_files("Hello0",
                                      "1.0", [],
                                      config=False,
                                      build=False)

        #  --- Build policy to missing ---
        files[CONANFILE] = files[CONANFILE].replace(
            "exports = '*'", "exports = '*'\n    build_policy = 'missing'")
        client.save(files, clean_first=True)
        client.run("export . lasote/stable")

        # Install, it will build automatically if missing (without the --build missing option)
        client.run("install Hello0/1.0@lasote/stable")
        self.assertIn("Building", client.out)
        self.assertNotIn("Generator txt created conanbuildinfo.txt",
                         client.out)

        # Try to do it again, now we have the package, so no build is done
        client.run("install Hello0/1.0@lasote/stable")
        self.assertNotIn("Building", client.out)
        self.assertNotIn("Generator txt created conanbuildinfo.txt",
                         client.out)

        # Try now to upload all packages, should not crash because of the "missing" build policy
        client.run("upload Hello0/1.0@lasote/stable --all")

        #  --- Build policy to always ---
        files[CONANFILE] = files[CONANFILE].replace("build_policy = 'missing'",
                                                    "build_policy = 'always'")
        client.save(files, clean_first=True)
        client.run("export . lasote/stable")

        # Install, it will build automatically if missing (without the --build missing option)
        client.run("install Hello0/1.0@lasote/stable")
        self.assertIn(
            "Detected build_policy 'always', trying to remove source folder",
            client.out)
        self.assertIn("Building", client.out)
        self.assertNotIn("Generator txt created conanbuildinfo.txt",
                         client.out)

        # Try to do it again, now we have the package, but we build again
        client.run("install Hello0/1.0@lasote/stable")
        self.assertIn("Building", client.out)
        self.assertIn(
            "Detected build_policy 'always', trying to remove source folder",
            client.out)
        self.assertNotIn("Generator txt created conanbuildinfo.txt",
                         client.out)

        # Try now to upload all packages, should crash because of the "always" build policy
        client.run("upload Hello0/1.0@lasote/stable --all", assert_error=True)
        self.assertIn("no packages can be uploaded", client.out)
Ejemplo n.º 22
0
    def test_msbuild_generator(self):
        client = TestClient()
        files = cpp_hello_conan_files("Hello0", "1.0")
        client.save(files)
        client.run("create . ")
        files = cpp_hello_conan_files("Hello3", "1.0")
        client.save(files, clean_first=True)
        client.run("create . ")
        files = cpp_hello_conan_files("Hello1", "1.0", deps=["Hello0/1.0"])
        client.save(files, clean_first=True)
        client.run("create . ")

        conanfile = textwrap.dedent("""
            from conans import ConanFile, MSBuild
            class HelloConan(ConanFile):
                settings = "os", "build_type", "compiler", "arch"
                requires = "Hello1/1.0", "Hello3/1.0"
                generators = "MSBuildDeps"
                def build(self):
                    msbuild = MSBuild(self)
                    msbuild.build("MyProject.sln")
            """)
        myapp_cpp = gen_function_cpp(name="main", msg="MyApp",
                                     includes=["helloHello1"], calls=["helloHello1"])
        myproject_cpp = gen_function_cpp(name="main", msg="MyProject", includes=["helloHello3"],
                                         calls=["helloHello3"])
        files = {"MyProject.sln": sln_file,
                 "MyProject/MyProject.vcxproj": myproject_vcxproj,
                 "MyProject/MyProject.cpp": myproject_cpp,
                 "MyApp/MyApp.vcxproj": myapp_vcxproj,
                 "MyApp/MyApp.cpp": myapp_cpp,
                 "conanfile.py": conanfile}

        client.save(files, clean_first=True)
        client.run("install .")
        client.run("build .")
        self.assertNotIn("warning MSB4011", client.out)
        client.run_command(r"x64\Release\MyProject.exe")
        self.assertIn("MyProject: Release!", client.out)
        self.assertIn("Hello Hello3", client.out)
        client.run_command(r"x64\Release\MyApp.exe")
        self.assertIn("MyApp: Release!", client.out)
        self.assertIn("Hello Hello1", client.out)
        self.assertIn("Hello Hello0", client.out)
Ejemplo n.º 23
0
 def _export(self, client, libname, depsname):
     files = cpp_hello_conan_files(
         libname,
         "0.1", ["%s/0.1@conan/stable" % name for name in depsname],
         build=six.PY3,
         pure_c=True)
     client.save(files, clean_first=True)
     files[CONANFILE] = files[CONANFILE].replace(
         'generators = "cmake", "gcc"', "")
     client.run("export %s conan/stable" % path_dot())
Ejemplo n.º 24
0
 def _create(client, number, version, deps=None, export=True, modifier=""):
     files = cpp_hello_conan_files(number, version, deps, build=False)
     # To avoid building
     files = {
         CONANFILE:
         files[CONANFILE].replace("config(", "config2(") + modifier
     }
     client.save(files, clean_first=True)
     if export:
         client.run("export . lasote/stable")
Ejemplo n.º 25
0
 def test_basic(self):
     hello_files = cpp_hello_conan_files("Hello")
     client = TestClient()
     client.save(hello_files)
     client.run("export . lasote/stable")
     path = os.path.join(client.storage_folder, "Hello/0.1/lasote/stable")
     self.assertTrue(os.path.exists(path))
     client.run("remove Hello* -f")
     path = os.path.join(client.storage_folder, "Hello")
     self.assertFalse(os.path.exists(path))
Ejemplo n.º 26
0
    def _create(self, number, version, deps=None, export=True):
        files = cpp_hello_conan_files(number, version, deps, build=False)

        files[CONANFILE] = files[CONANFILE] + """    def build(self):
        self.output.info("Settings %s" % self.settings.values.dumps())
        self.output.info("Options %s" % self.options.values.dumps())
        """
        self.client.save(files, clean_first=True)
        if export:
            self.client.run("export . lasote/stable")
Ejemplo n.º 27
0
    def test_try_upload_bad_recipe(self):
        files = cpp_hello_conan_files("Hello0", "1.2.1")
        self.client.save(files)
        self.client.run("export . frodo/stable")
        ref = ConanFileReference.loads("Hello0/1.2.1@frodo/stable")
        os.unlink(os.path.join(self.client.cache.package_layout(ref).export(), CONAN_MANIFEST))
        with six.assertRaisesRegex(self, Exception, "Command failed"):
            self.client.run("upload %s" % str(ref))

        self.assertIn("Cannot upload corrupted recipe", self.client.out)
Ejemplo n.º 28
0
    def _create(self, client, number, version, deps=None, export=True):
        files = cpp_hello_conan_files(number,
                                      version,
                                      deps,
                                      build=False,
                                      config=False)

        client.save(files, clean_first=True)
        if export:
            client.run("export . lasote/stable")
Ejemplo n.º 29
0
    def test_upload_without_cleaned_user(self):
        """ When a user is not authenticated, uploads failed first time
        https://github.com/conan-io/conan/issues/5878
        """
        class EmptyCapabilitiesResponse(object):
            def __init__(self):
                self.ok = False
                self.headers = {
                    "X-Conan-Server-Capabilities": "",
                    "Content-Type": "application/json"
                }
                self.status_code = 401
                self.content = b''

        class ErrorApiResponse(object):
            def __init__(self):
                self.ok = False
                self.status_code = 400
                self.content = "Unsupported Conan v1 repository request for 'conan'"

        class ServerCapabilitiesRequester(TestRequester):
            def __init__(self, *args, **kwargs):
                self._first_ping = True
                super(ServerCapabilitiesRequester,
                      self).__init__(*args, **kwargs)

            def get(self, url, **kwargs):
                app, url = self._prepare_call(url, kwargs)
                if app:
                    if url.endswith("ping") and self._first_ping:
                        self._first_ping = False
                        return EmptyCapabilitiesResponse()
                    elif "Hello0" in url and "1.2.1" in url and "v1" in url:
                        return ErrorApiResponse()
                    else:
                        response = app.get(url, **kwargs)
                        return TestingResponse(response)
                else:
                    return requests.get(url, **kwargs)

        server = TestServer(users={"user": "******"},
                            write_permissions=[("*/*@*/*", "*")],
                            server_capabilities=[REVISIONS])
        servers = {"default": server}
        client = TestClient(requester_class=ServerCapabilitiesRequester,
                            servers=servers,
                            revisions_enabled=True)
        files = cpp_hello_conan_files("Hello0", "1.2.1", build=False)
        client.save(files)
        client.run("create . user/testing")
        client.run("user -c")
        client.run("upload Hello0/1.2.1@user/testing --all -r default")
        self.assertIn(
            "Uploaded conan recipe 'Hello0/1.2.1@user/testing' to 'default'",
            client.out)
Ejemplo n.º 30
0
    def test_cmake_lock_target_redefinition(self):
        client = TestClient()
        files = cpp_hello_conan_files(
            name="Hello0", settings='"os", "compiler", "arch", "build_type"')
        client.save(files)
        client.run("create . user/channel -s build_type=Release")

        # Consume the previous Hello0 with auto generated FindHello0.cmake
        # The module path will point to the "install" folder automatically (CMake helper)
        files = cpp_hello_conan_files(
            name="Hello1",
            deps=["Hello0/0.1@user/channel"],
            settings='"os", "compiler", "arch", "build_type"')
        files["conanfile.py"] = files["conanfile.py"].replace(
            'generators = "cmake", "gcc"', 'generators = "cmake_find_package"')
        files["CMakeLists.txt"] = """
set(CMAKE_CXX_COMPILER_WORKS 1)
set(CMAKE_CXX_ABI_COMPILED 1)
project(MyHello CXX)
cmake_minimum_required(VERSION 3.1)

# Add fake library
add_library(fake)
# Create an alias target to check if it is not redefined.
# Only IMPORTED and ALIAS libraries may use :: as part of the
# target name (See CMake policy CMP0037). This ALIAS target
# fakes the IMPORTED targets used in the generated FindXXXX.cmake files
add_library(CONAN_LIB::Hello0_helloHello0 ALIAS fake)

find_package(Hello0 REQUIRED)

get_target_property(tmp Hello0::Hello0 INTERFACE_LINK_LIBRARIES)
message("Target libs: ${tmp}")

"""
        client.save(files, clean_first=True)
        client.run("create . user/channel -s build_type=Release",
                   assert_error=True)
        self.assertIn(
            "Skipping already existing target: CONAN_LIB::Hello0_helloHello0",
            client.out)
        self.assertIn("Target libs: CONAN_LIB::Hello0_helloHello0", client.out)