Пример #1
0
    def run_in_windows_bash_inject_env_test(self):
        if Version(conan_version) < Version(
                "1.0.0-beta.4") or platform.system() != "Windows":
            raise nose.SkipTest('Only windows test')
        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):
        vs_path = tools.vcvars_dict(self.settings)["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",
                           ignore_error=True)  # Link will fail, but run
                self.assertIn("Microsoft (R) Incremental Linker Version",
                              client.user_io.out)
Пример #2
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())
Пример #3
0
    def run_in_windows_bash_test(self):
        if Version(conan_version) < Version(
                "1.0.0-beta.1") or platform.system() != "Windows":
            raise nose.SkipTest('Only windows test')
        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)
Пример #4
0
    def test_base(self, subsystem_require):
        if Version(conan_version) < Version(
                "1.0.0-beta.1") or platform.system() != "Windows":
            raise nose.SkipTest('Only windows test')
        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())
Пример #5
0
    def run_in_windows_bash_env_var_test(self):
        if Version(conan_version) < Version(
                "1.0.0-beta.1") or platform.system() != "Windows":
            raise nose.SkipTest('Only windows test')
        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)
Пример #6
0
 def diamond_mingw_test(self):
     if Version(client_version) < Version("0.31"):
         raise nose.SkipTest('Only >= 1.0 version')
     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.diamond_tester.test(install=install, use_cmake=False)
Пример #7
0
    def large_project_test(self):
        client = TestClient()
        num = 250
        use_additional_infos = 20

        deep = True  # True for N ... -> 3 -> 2 -> 1 -> 0, False for N -> 0, 3-> 0, 2->0, 1->0
        for i in range(num):
            if i == 0:
                files = cpp_hello_conan_files("Hello0", "0.1", build=False)
            else:
                if not deep:
                    files = cpp_hello_conan_files(
                        "Hello%d" % i,
                        "0.1", ["Hello0/0.1@lasote/stable"],
                        build=False,
                        use_additional_infos=use_additional_infos)
                else:
                    files = cpp_hello_conan_files(
                        "Hello%d" % i,
                        "0.1", ["Hello%s/0.1@lasote/stable" % (i - 1)],
                        build=False,
                        use_additional_infos=use_additional_infos)

            client.save(files, clean_first=True)
            client.run("export %s lasote/stable" % path_dot())

        # Now lets depend on it
        if deep:
            files = cpp_hello_conan_files(
                "HelloFinal",
                "0.1", ["Hello%s/0.1@lasote/stable" % (num - 1)],
                build=False,
                use_additional_infos=use_additional_infos)
        else:
            files = cpp_hello_conan_files(
                "HelloFinal",
                "0.1", ["Hello%s/0.1@lasote/stable" % (i) for i in range(num)],
                build=False,
                use_additional_infos=use_additional_infos)

        client.save(files, clean_first=True)
        t1 = time.time()
        client.run("install --build")
        print("Final time with build %s" % (time.time() - t1))
        t1 = time.time()
        client.run("install")
        print("Final time %s" % (time.time() - t1))
Пример #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")
Пример #9
0
    def build_mingw_test(self):
        if Version(client_version) < Version("0.31"):
            raise nose.SkipTest('Only >= 1.0 version')

        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.integration.basic_build_test import build
                    build(self,
                          cmd,
                          static,
                          pure_c,
                          use_cmake=False,
                          lang=lang)
Пример #10
0
    def run_in_windows_bash_relative_path_test(self):
        if Version(conan_version) < Version(
                "1.0.0-beta.1") or platform.system() != "Windows":
            raise nose.SkipTest('Only windows test')
        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)