Beispiel #1
0
 def _get_env_values(env, package_env):
     env_values = EnvValues()
     for name, value in env:
         env_values.add(name, EnvValues.load_value(value))
     for package, data in package_env.items():
         for name, value in data:
             env_values.add(name, EnvValues.load_value(value), package)
     return env_values
Beispiel #2
0
 def _get_env_values(env, package_env):
     env_values = EnvValues()
     for name, value in env:
         env_values.add(name, EnvValues.load_value(value))
     for package, data in package_env.items():
         for name, value in data:
             env_values.add(name, EnvValues.load_value(value), package)
     return env_values
Beispiel #3
0
 def env_test(self):
     env_values = EnvValues()
     env_values.add("PREPEND_PATH", ["hello", "bye"])
     env_values.add("VAR", ["var_value"])
     self.profile._env_values = env_values
     save(self.conanfile_txt_path, "")
     conanfile = self.loader.load_conanfile_txt(self.conanfile_txt_path,
                                                self.profile)
     self.assertEqual(conanfile.env, {
         "PREPEND_PATH": ["hello", "bye"],
         "VAR": ["var_value"]
     })
Beispiel #4
0
 def env_test(self):
     env_values = EnvValues()
     env_values.add("PREPEND_PATH", ["hello", "bye"])
     env_values.add("VAR", ["var_value"])
     self.profile.env_values = env_values
     conanfile_txt_path = os.path.join(temp_folder(), "conanfile.txt")
     save(conanfile_txt_path, "")
     conanfile = self.loader.load_conanfile_txt(conanfile_txt_path,
                                                self.profile)
     self.assertEqual(conanfile.env, {
         "PREPEND_PATH": ["hello", "bye"],
         "VAR": ["var_value"]
     })
Beispiel #5
0
    def setUpClass(cls):
        env = EnvValues()
        env.add("USER_FLAG", "user_value")
        env.add("CL", ["cl1", "cl2"])
        env.add("PATH", [
            "another_path",
        ])
        env.add("PATH2", ["p1", "p2"])
        env.add("PATH3", ["p1", "p2", "p1", "p3", "p4", "p2"])
        conanfile = ConanFile(TestBufferConanOutput(), None)
        conanfile.initialize(Settings({}), env)

        cls.generator = VirtualEnvGenerator(conanfile)
        cls.generator.output_path = "not-used"
        cls.result = cls.generator.content
Beispiel #6
0
    def test_update_concat(self):
        env_info = EnvInfo()
        env_info.path.append("SOME/PATH")
        deps_info = DepsEnvInfo()
        deps_info.update(env_info, "lib")

        deps_info2 = DepsEnvInfo()
        deps_info2.update(env_info, "lib2")

        env = EnvValues()
        env.add("PATH", ["MYPATH"])
        env.update(deps_info)

        self.assertEquals(env.env_dicts(None), ({}, {'PATH': ['MYPATH', 'SOME/PATH']}))

        env.update(deps_info2)

        self.assertEquals(env.env_dicts(None), ({}, {'PATH': ['MYPATH', 'SOME/PATH', 'SOME/PATH']}))
Beispiel #7
0
    def test_update_concat(self):
        env_info = EnvInfo()
        env_info.path.append("SOME/PATH")
        deps_info = DepsEnvInfo()
        deps_info.update(env_info, "lib")

        deps_info2 = DepsEnvInfo()
        deps_info2.update(env_info, "lib2")

        env = EnvValues()
        env.add("PATH", ["MYPATH"])
        env.update(deps_info)

        self.assertEqual(env.env_dicts(None), ({}, {'PATH': ['MYPATH', 'SOME/PATH']}))

        env.update(deps_info2)

        self.assertEqual(env.env_dicts(None), ({}, {'PATH': ['MYPATH', 'SOME/PATH', 'SOME/PATH']}))
Beispiel #8
0
    def env_test(self):
        env_values = EnvValues()
        env_values.add("PREPEND_PATH", ["hello", "bye"])
        env_values.add("VAR", ["var_value"])
        self.profile._env_values = env_values
        save(
            self.conanfile_path,
            textwrap.dedent("""
                from conans import ConanFile

                class TestConan(ConanFile):
                    name = "hello"
                    version = "1.0"
             """))
        ref = ConanFileReference("hello", "1.0", "user", "channel")
        conanfile = self.loader.load_conanfile(self.conanfile_path,
                                               self.profile, ref)
        self.assertEqual(conanfile.env, {
            "PREPEND_PATH": ["hello", "bye"],
            "VAR": ["var_value"]
        })
Beispiel #9
0
    def test_update_concat(self):
        env_info = EnvInfo()
        env_info.path.append("SOME/PATH")
        deps_info = DepsEnvInfo()
        deps_info.update(env_info,
                         ConanFileReference.loads("lib/1.0@lasote/stable"))

        deps_info2 = DepsEnvInfo()
        deps_info2.update(env_info,
                          ConanFileReference.loads("lib2/1.0@lasote/stable"))

        env = EnvValues()
        env.add("PATH", ["MYPATH"])
        env.update(deps_info)

        self.assertEquals(env.env_dicts(None), ({}, {
            'PATH': ['MYPATH', 'SOME/PATH']
        }))

        env.update(deps_info2)

        self.assertEquals(env.env_dicts(None), ({}, {
            'PATH': ['MYPATH', 'SOME/PATH', 'SOME/PATH']
        }))
Beispiel #10
0
    def test_update_priority(self):

        env = EnvValues()
        env.add("VAR", "VALUE1")

        env2 = EnvValues()
        env2.add("VAR", "VALUE2")

        env.update(env2)

        # Already set by env, discarded new value
        self.assertEqual(env.env_dicts(None), ({'VAR': 'VALUE1'}, {}))

        # Updates with lists and values
        env = EnvValues()
        env.add("VAR", ["1"])
        env.add("VAR", "2")
        self.assertEqual(env.env_dicts(None), ({}, {'VAR': ['1', '2']}))

        # If the first value is not a list won't append
        env = EnvValues()
        env.add("VAR", "1")
        env.add("VAR", ["2"])
        self.assertEqual(env.env_dicts(None), ({'VAR': '1'}, {}))
Beispiel #11
0
    def test_model(self):
        env = EnvValues()
        env.add("Z", "1")
        self.assertEqual(env.env_dicts(""), ({"Z": "1"}, {}))
        env.add("Z", "2")
        self.assertEqual(env.env_dicts(""), ({"Z": "1"}, {}))
        env.add("B", "223")
        self.assertEqual(env.env_dicts(""), ({"Z": "1", "B": "223"}, {}))
        env.add("B", "224", "package1")
        self.assertEqual(env.env_dicts(""), ({"Z": "1", "B": "223"}, {}))
        self.assertEqual(env.env_dicts("package1"), ({
            "Z": "1",
            "B": "224"
        }, {}))
        env.add("A", "1", "package1")
        self.assertEqual(env.env_dicts("package1"), ({
            "Z": "1",
            "B": "224",
            "A": "1"
        }, {}))
        self.assertEqual(env.env_dicts(""), ({"Z": "1", "B": "223"}, {}))
        env.add("J", "21", "package21")
        self.assertEqual(env.env_dicts(""), ({"Z": "1", "B": "223"}, {}))
        self.assertEqual(env.env_dicts("package1"), ({
            "Z": "1",
            "B": "224",
            "A": "1"
        }, {}))
        env.add("A", ["99"], "package1")
        self.assertEqual(env.env_dicts("package1"), ({
            "Z": "1",
            "B": "224",
            "A": "1"
        }, {}))
        env.add("M", ["99"], "package1")
        self.assertEqual(env.env_dicts("package1"), ({
            "Z": "1",
            "B": "224",
            "A": "1"
        }, {
            "M": ["99"]
        }))
        env.add("M", "100", "package1")
        self.assertEqual(env.env_dicts("package1"), ({
            "Z": "1",
            "B": "224",
            "A": "1"
        }, {
            "M": ["99", "100"]
        }))

        self.assertEqual(env.env_dicts(""), ({"Z": "1", "B": "223"}, {}))
Beispiel #12
0
    def test_model(self):
        env = EnvValues()
        env.add("Z", "1")
        self.assertEquals(env.env_dicts(""), ({"Z": "1"}, {}))
        env.add("Z", "2")
        self.assertEquals(env.env_dicts(""), ({"Z": "1"}, {}))
        env.add("B", "223")
        self.assertEquals(env.env_dicts(""), ({"Z": "1", "B": "223"}, {}))
        env.add("B", "224", "package1")
        self.assertEquals(env.env_dicts(""), ({"Z": "1", "B": "223"}, {}))
        self.assertEquals(env.env_dicts("package1"), ({"Z": "1", "B": "224"}, {}))
        env.add("A", "1", "package1")
        self.assertEquals(env.env_dicts("package1"), ({"Z": "1", "B": "224", "A": "1"}, {}))
        self.assertEquals(env.env_dicts(""), ({"Z": "1", "B": "223"}, {}))
        env.add("J", "21", "package21")
        self.assertEquals(env.env_dicts(""), ({"Z": "1", "B": "223"}, {}))
        self.assertEquals(env.env_dicts("package1"), ({"Z": "1", "B": "224", "A": "1"}, {}))
        env.add("A", ["99"], "package1")
        self.assertEquals(env.env_dicts("package1"), ({"Z": "1", "B": "224", "A": "1"}, {}))
        env.add("M", ["99"], "package1")
        self.assertEquals(env.env_dicts("package1"), ({"Z": "1", "B": "224", "A": "1"}, {"M": ["99"]}))
        env.add("M", "100", "package1")
        self.assertEquals(env.env_dicts("package1"), ({"Z": "1", "B": "224", "A": "1"}, {"M": ["99", "100"]}))

        self.assertEquals(env.env_dicts(""), ({"Z": "1", "B": "223"}, {}))
Beispiel #13
0
    def update_priority_test(self):

        env = EnvValues()
        env.add("VAR", "VALUE1")

        env2 = EnvValues()
        env2.add("VAR", "VALUE2")

        env.update(env2)

        # Already set by env, discarded new value
        self.assertEquals(env.env_dicts(None),  ({'VAR': 'VALUE1'}, {}))

        # Updates with lists and values
        env = EnvValues()
        env.add("VAR", ["1"])
        env.add("VAR", "2")
        self.assertEquals(env.env_dicts(None), ({}, {'VAR': ['1', '2']}))

        # If the first value is not a list won't append
        env = EnvValues()
        env.add("VAR", "1")
        env.add("VAR", ["2"])
        self.assertEquals(env.env_dicts(None), ({'VAR': '1'}, {}))