Beispiel #1
0
    def diamond_mingw_test(self):
        use_cmake = cmake_targets = False
        self._export("Hello0", "0.1", use_cmake=use_cmake, cmake_targets=cmake_targets)
        self._export("Hello1", "0.1", ["Hello0/0.1@lasote/stable"], use_cmake=use_cmake,
                     cmake_targets=cmake_targets)
        self._export("Hello2", "0.1", ["Hello0/0.1@lasote/stable"], use_cmake=use_cmake,
                     cmake_targets=cmake_targets)
        self._export("Hello3", "0.1", ["Hello1/0.1@lasote/stable", "Hello2/0.1@lasote/stable"],
                     use_cmake=use_cmake, cmake_targets=cmake_targets)

        files3 = cpp_hello_conan_files("Hello4", "0.1", ["Hello3/0.1@lasote/stable"],
                                       language=1, use_cmake=use_cmake,
                                       cmake_targets=cmake_targets)

        self.client.save(files3)

        with tools.remove_from_path("bash.exe"):
            with mingw_in_path():
                not_env = os.system("g++ --version > nul")
                if not_env != 0:
                    raise Exception("This platform does not support G++ command")
                install = "install %s -s compiler=gcc -s compiler.libcxx=libstdc++ " \
                          "-s compiler.version=4.9" % path_dot()

                self.client.run("install %s -s compiler=gcc -s compiler.libcxx=libstdc++ " 
                                "-s compiler.version=4.9 --build=missing" % path_dot())
                self.client.run("build .")
                
                command = os.sep.join([".", "bin", "say_hello"])
                self.client.run_command(command)
                self.assertEqual(['Hola Hello4', 'Hola Hello3', 'Hola Hello1', 'Hola Hello0',
                                'Hola Hello2', 'Hola Hello0'],
                                str(self.client.out).splitlines()[-6:])
Beispiel #2
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())
Beispiel #3
0
    def run_in_windows_bash_inject_env_test(self):

        with tools.remove_from_path("bash.exe"):
            with msys2_in_path():
                conanfile = '''
import os
from conans import ConanFile, tools, __version__ as conan_version

class ConanBash(ConanFile):
    name = "bash"
    version = "0.1"
    settings = "os", "compiler", "build_type", "arch"

    def build(self):
        vs_path = tools.vcvars_dict(self.settings)["PATH"]
        if conan_version >= "1.7.0":
            vs_path = os.pathsep.join(vs_path)
        tools.run_in_windows_bash(self, "link", env={"PATH": vs_path})

'''
                client = TestClient()
                client.save({CONANFILE: conanfile})
                client.run("export %s lasote/stable" % path_dot())
                client.run("install bash/0.1@lasote/stable --build"
                           )  # Link will fail, but run
                self.assertIn("Microsoft (R) Incremental Linker Version",
                              client.user_io.out)
Beispiel #4
0
    def run_in_windows_bash_test(self):
        with tools.remove_from_path("bash.exe"):
            with msys2_in_path():
                conanfile = '''
from conans import ConanFile, tools

class ConanBash(ConanFile):
    name = "bash"
    version = "0.1"
    settings = "os", "compiler", "build_type", "arch"

    def build(self):
        tools.run_in_windows_bash(self, "pwd")

        '''
                client = TestClient()
                client.save({CONANFILE: conanfile})
                client.run("export %s lasote/stable" % path_dot())
                client.run("install bash/0.1@lasote/stable --build")
                if Version(conan_version) < Version("1.12.0"):
                    cache = client.client_cache
                else:
                    cache = client.cache
                ref = ConanFileReference.loads("bash/0.1@lasote/stable")
                if Version(conan_version) > Version("1.14.10"):
                    tmp = cache.package_layout(ref).base_folder()
                else:
                    tmp = cache.conan(ref)
                expected_curdir_base = unix_path(tmp)
                self.assertIn(expected_curdir_base, client.out)
Beispiel #5
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())
Beispiel #6
0
 def build_mingw_test(self):
     with tools.remove_from_path("bash.exe"):
         with mingw_in_path():
             not_env = os.system("c++ --version > nul")
             if not_env != 0:
                 raise Exception("This platform does not support G++ command")
             install = "install %s -s compiler=gcc -s compiler.libcxx=libstdc++ " \
                       "-s compiler.version=4.9" % path_dot()
             for cmd, lang, static, pure_c in [(install, 0, True, True),
                                               (install + " -o language=1 -o static=False", 1, False, False)]:
                 from conans.test.functional.basic_build_test import build
                 build(self, cmd, static, pure_c, use_cmake=False, lang=lang)
Beispiel #7
0
    def run_in_windows_bash_env_var_test(self):
        with tools.remove_from_path("bash.exe"):
            with msys2_in_path():
                conanfile = '''
from conans import ConanFile, tools
import os

class ConanBash(ConanFile):
    name = "THEPACKAGE"
    version = "0.1"

    def package_info(self):
        self.env_info.PATH.append(self.package_folder)
        tools.save(os.path.join(self.package_folder, "myrun.bat"), 'echo "HELLO PARENT!')
'''
                client = TestClient()
                client.save({CONANFILE: conanfile})
                client.run("create %s lasote/stable" % path_dot())

                conanfile = '''
from conans import ConanFile, tools

class ConanBash(ConanFile):
    name = "bash"
    version = "0.1"
    settings = "os", "compiler", "build_type", "arch"
    requires = "THEPACKAGE/0.1@lasote/stable"

    def build(self):
        with tools.environment_append({"MYVAR": "Hello MYVAR"}):
            tools.run_in_windows_bash(self, "echo $MYVAR")
            tools.run_in_windows_bash(self, 'myrun.bat')
        '''
                client.save({CONANFILE: conanfile}, clean_first=True)
                client.run("export %s lasote/stable" % path_dot())
                client.run("install bash/0.1@lasote/stable --build")
                self.assertIn("Hello MYVAR", client.user_io.out)
                self.assertIn("HELLO PARENT!", client.user_io.out)
Beispiel #8
0
    def basic_test(self, no_copy_source):

        # meson > py 3.4
        if sys.version_info[0] < 3 or sys.version_info[1] < 5:
            return

        client = TestClient()
        conanfile = """from conans import ConanFile, Meson, load
import os
class Conan(ConanFile):
    settings = "os", "compiler", "arch", "build_type"
    exports_sources = "src/*"
    no_copy_source = {}
    def build(self):
        meson = Meson(self)
        meson.configure(source_folder="src",
                        cache_build_folder="build")
        meson.build()
    def package(self):
        self.copy("*.h", src="src", dst="include")

    def package_info(self):
        self.output.info("HEADER %s" % load(os.path.join(self.package_folder, "include/header.h")))
    """.format(no_copy_source)
        meson = """project('hello', 'cpp', version : '0.1.0',
		default_options : ['cpp_std=c++11'])
"""
        client.save({
            "conanfile.py": conanfile,
            "src/meson.build": meson,
            "src/header.h": "//myheader.h"
        })
        client.run("create %s Hello/0.1@lasote/channel" % path_dot())
        self.assertIn("Hello/0.1@lasote/channel: HEADER //myheader.h",
                      client.out)
        # Now local flow
        build_folder = os.path.join(client.current_folder, "build")
        mkdir(build_folder)
        client.current_folder = build_folder
        client.run("install ..")
        client.run("build ..")
        client.run("package ..")
        self.assertTrue(
            os.path.exists(os.path.join(build_folder, "conaninfo.txt")))
        self.assertTrue(
            os.path.exists(os.path.join(build_folder, "conanbuildinfo.txt")))
        self.assertEqual(
            load(os.path.join(build_folder, "package/include/header.h")),
            "//myheader.h")
Beispiel #9
0
    def run_in_windows_bash_relative_path_test(self):
        with tools.remove_from_path("bash.exe"):
            with msys2_in_path():
                conanfile = '''
import os
from conans import ConanFile, tools

class ConanBash(ConanFile):
    name = "bash"
    version = "0.1"

    def build(self):
        tools.mkdir("relative")
        tools.run_in_windows_bash(self, "pwd", "relative")
'''
                client = TestClient()
                client.save({CONANFILE: conanfile})
                client.run("create %s bash/0.1@lasote/stable" % path_dot())
                self.assertIn(
                    "build/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/relative",
                    client.user_io.out)
Beispiel #10
0
    def run_in_windows_bash_test(self):
        with tools.remove_from_path("bash.exe"):
            with msys2_in_path():
                conanfile = '''
from conans import ConanFile, tools

class ConanBash(ConanFile):
    name = "bash"
    version = "0.1"
    settings = "os", "compiler", "build_type", "arch"

    def build(self):
        tools.run_in_windows_bash(self, "pwd")

        '''
                client = TestClient()
                client.save({CONANFILE: conanfile})
                client.run("export %s lasote/stable" % path_dot())
                client.run("install bash/0.1@lasote/stable --build")
                expected_curdir_base = unix_path(
                    client.client_cache.conan(
                        ConanFileReference.loads("bash/0.1@lasote/stable")))
                self.assertIn(expected_curdir_base, client.user_io.out)