示例#1
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)
示例#2
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)
示例#3
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)
示例#4
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)
示例#5
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)